Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Location
    Mexico City
    Posts
    2

    Unanswered: Pro*c problem: can't connect through shared object

    Hi, I am A DBA but recently got involved in some pro*c development. I have hit a dead end trying to use a dynamic shared library containing pro*c code.

    I've searched a lot but cannot find a way around this.

    Here is an example of my problem :

    I have a simple pro*c program with 2 functions
    plus main,the source is called alan.pc :
    ---------------------------------------------------------------------
    #include <alan.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <sqlca.h>


    void ConnectToDataBase()
    {
    char *username = "SYSADM";
    char *password = "BSCS_U2";
    EXEC SQL CONNECT :username IDENTIFIED BY assword;
    }

    void print_int()
    {
    printf("1\n");
    }

    void main()
    {
    print_int();
    ConnectToDataBase();
    }
    ---------------------------------------------------------------------



    The file alan.h is simply :
    ---------------------------------------------------------------------
    void ConnectToDataBase();
    void print_int();
    ----------------------------------------------------------------------



    I compile using the oracle supplied makefile and env_precomp
    the executable alan is created and runs with no error :
    -----------------------------------------------------------------------
    $ alan
    1
    $
    -----------------------------------------------------------------------

    I copy the file alan.pc to libalan.pc and alan.h to libalan.h

    Now I remove the main function from libalan.pc and alter the env_precomp
    to use the -b option so as to create a shared object instead of an exe

    I compile again and create the library libalan.sl
    checking the file type shows me :
    -----------------------------------------------------------------------------
    $ file libalan.sl
    libalan.sl: ELF-64 shared object file - PA-RISC 2.0 (LP64)
    $
    ------------------------------------------------------------------------------



    now I create a simple c program i called use_my_lib.c :
    -----------------------------------------------------------------------------
    #include <libalan.h>

    void main()
    {
    print_int();
    ConnectToDataBase();
    }
    -----------------------------------------------------------------------------



    I compile this with the following command :
    -----------------------------------------------------------------------------
    cc +DA2.0W use_my_lib.c -o use_my_lib -I./include -L./lib -lalan -dynamic
    -----------------------------------------------------------------------------

    running the executable gives me :

    ------------------------------------------------------------------------------
    $ use_my_lib
    1
    Bus error(coredump)
    $
    ------------------------------------------------------------------------------

    So from the above it can be seen that the library is being dynamically linked and works properly with a simple c function, but not for the pro*c connect part.

    The result of ldd on my executable and the library is as I would expect :

    ---------------------------------------------------------------------------
    $ ldd libalan.sl
    libclntsh.sl.9.0 => /u01/oracle/product/9.2/lib/libclntsh.sl.9.0
    libcl.2 => /usr/lib/pa20_64/libcl.2
    librt.2 => /usr/lib/pa20_64/librt.2
    libpthread.1 => /usr/lib/pa20_64/libpthread.1
    libnss_dns.1 => /usr/lib/pa20_64/libnss_dns.1
    libdl.1 => /usr/lib/pa20_64/libdl.1
    libm.2 => /usr/lib/pa20_64/libm.2
    libwtc9.sl => /u01/oracle/product/9.2/lib/libwtc9.sl
    librt.2 => /lib/pa20_64/librt.2
    libpthread.1 => /lib/pa20_64/libpthread.1
    libnss_dns.1 => /lib/pa20_64/libnss_dns.1
    libdl.1 => /lib/pa20_64/libdl.1
    libm.2 => /lib/pa20_64/libm.2
    libc.2 => /lib/pa20_64/libc.2
    libcl.2 => /lib/pa20_64/libcl.2
    libdl.1 => /usr/lib/pa20_64/libdl.1
    libdl.1 => /usr/lib/pa20_64/libdl.1
    libdl.1 => /usr/lib/pa20_64/libdl.1
    libdl.1 => /usr/lib/pa20_64/libdl.1

    $ ldd use_my_lib
    libalan.sl => ./lib/libalan.sl
    libc.2 => /usr/lib/pa20_64/libc.2
    libclntsh.sl.9.0 => /u01/oracle/product/9.2/lib/libclntsh.sl.9.0
    libcl.2 => /usr/lib/pa20_64/libcl.2
    librt.2 => /usr/lib/pa20_64/librt.2
    libpthread.1 => /usr/lib/pa20_64/libpthread.1
    libnss_dns.1 => /usr/lib/pa20_64/libnss_dns.1
    libdl.1 => /usr/lib/pa20_64/libdl.1
    libm.2 => /usr/lib/pa20_64/libm.2
    libdl.1 => /usr/lib/pa20_64/libdl.1
    libwtc9.sl => /u01/oracle/product/9.2/lib/libwtc9.sl
    librt.2 => /lib/pa20_64/librt.2
    libpthread.1 => /lib/pa20_64/libpthread.1
    libnss_dns.1 => /lib/pa20_64/libnss_dns.1
    libdl.1 => /lib/pa20_64/libdl.1
    libm.2 => /lib/pa20_64/libm.2
    libc.2 => /lib/pa20_64/libc.2
    libcl.2 => /lib/pa20_64/libcl.2
    libdl.1 => /usr/lib/pa20_64/libdl.1
    libdl.1 => /usr/lib/pa20_64/libdl.1
    libdl.1 => /usr/lib/pa20_64/libdl.1
    --------------------------------------------------------------------------


    I'm sure this is a simple thing but its driving me upthe wall! So I'd really appreciate any help that a real pro*c developer could give me.

    Thanks,
    Alan Formstone

  2. #2
    Join Date
    Oct 2004
    Location
    Mexico City
    Posts
    2
    well i didn't get a reply, but worked it out anyway!

    I needed to include the threads library. Why I have no idea, but it works!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •