Dynamicly Shared librarys

I have reviewed all of the threads of discussion on dynamically loaded
librarys but I can not get it to work.

I have two files. A main “server” file and a “utility” file. I want to
make the utility file a library (.so) and use it in the server. It compiles
but after I load the library (dlopen("/path/utility.so", RTLD_NOW)) it seems
that It returns a handle to the library and I check the dlerror and it is
NULL. I then load the functions:

typedef void (*funct1) (void);
typedef int (*funct2) (Request *);

void* handle=NULL;
func1 loadTables=NULL;
func2 reqRes=NULL;

handle = dlopen("/path/utility.so", RTLD_NOW);
loadTables = (*funct1)

tried both of these:
a.
loadTables = (func1)dlsym( handle, “readTableData” );
reqRes = (func2)dlsym( handle, “requestReservation” );
b.
loadTables = (func1)dlsym( RTLD_DEFAULT, “readTableData” );
reqRes = (func2)dlsym( RTLD_DEFAULT, “requestReservation” );

(*loadTables)(); // it core dumps here


I have used the dlerror() function after each stage and no errors are
returned. Here are my compiler directives:


INC_ALL = -I/usr/include -I/usr/include/g+±3
CC=qcc
CFLAGS = -Vgcc_ntox86 -N128k -O -DUSE_LOGGER=1 -shared -fPIC
LDFLAGS = $(CFLAGS) -lang-c++ -lsocket -shared -fPIC

I have tried to use all of the options of -shared, -Bdynamic, and -fPIC.

Any suggestions would be greatly appreciated.


Kevin Hykin

After much searching I found this reference that has proved to be very
helpful.
http://docs.linux.cz/howto/Program-Library-HOWTO.html

“Kevin Hykin” <kevin.hykin@bepco.com> wrote in message
news:9alc67$j6a$1@inn.qnx.com

I have reviewed all of the threads of discussion on dynamically loaded
librarys but I can not get it to work.

I have two files. A main “server” file and a “utility” file. I want to
make the utility file a library (.so) and use it in the server. It
compiles
but after I load the library (dlopen("/path/utility.so", RTLD_NOW)) it
seems
that It returns a handle to the library and I check the dlerror and it is
NULL. I then load the functions:

typedef void (*funct1) (void);
typedef int (*funct2) (Request *);

void* handle=NULL;
func1 loadTables=NULL;
func2 reqRes=NULL;

handle = dlopen("/path/utility.so", RTLD_NOW);
loadTables = (*funct1)

tried both of these:
a.
loadTables = (func1)dlsym( handle, “readTableData” );
reqRes = (func2)dlsym( handle, “requestReservation” );
b.
loadTables = (func1)dlsym( RTLD_DEFAULT, “readTableData” );
reqRes = (func2)dlsym( RTLD_DEFAULT, “requestReservation” );

(*loadTables)(); // it core dumps here


I have used the dlerror() function after each stage and no errors are
returned. Here are my compiler directives:


INC_ALL = -I/usr/include -I/usr/include/g+±3
CC=qcc
CFLAGS = -Vgcc_ntox86 -N128k -O -DUSE_LOGGER=1 -shared -fPIC
LDFLAGS = $(CFLAGS) -lang-c++ -lsocket -shared -fPIC

I have tried to use all of the options of -shared, -Bdynamic, and -fPIC.

Any suggestions would be greatly appreciated.


Kevin Hykin




\