1827817 Members
1590 Online
109969 Solutions
New Discussion

Shared library behavior

 
Terry Dabbs
Occasional Contributor

Shared library behavior

I have a shared library (for HPUX10.2) that I am using with a Command interpreter to call the functions. I am trying to use glut utilities with the OpenGL to draw graphics during a test program.

The problem:
Some of the functions of the glut toolkit use user defined functions as arguments. These work well in a standard (non-library) C program, but are ignored when used in the shared library!

Standard C example:.
.
.
void display(void)
{
Code ......
}
int main(int argc, char** argv)
{
glutDisplayFunct(display);
}

In the shared lib:
void display(void)
{
Code....
}
void glmain(int arg1, char** arg2)
{
glutDisplayFunct(display);
}

The shared library (after much work on the Makefile)
works for all other functions called except these functions that are taking another function as an argument. I don't have a main function in the shared library, so it doesn't fit exactly the code examples in the toolkit, which I can modify all day long without a problem.

I am sure someone has run into this before. Please help!

Terr
4 REPLIES 4

Re: Shared library behavior


You did not mention how you link the application, or what the error looks like. Is is a coredump or unsatisfied symbols? Are you linking statically, dynamically, or are you loading the shared lib explicitly with shl_load()?


Terry Dabbs
Occasional Contributor

Re: Shared library behavior

The following is the output from the Makefile:

cc -Ae +Z -I /opt/hp83000/f330/pws/lib -I /opt/hp83000/f330/prod_com/include -I /opt/hp83000/f330/com/include -I /opt/graphics/OpenGl/include -I /opt/X11R6incs/include -I /opt/X11R6includes/X11/Xmu -I /usr/include/Motif1.2 -I /opt/graphics/GLUT/include -b -c functions.c || (rm -f functions.o)
ld -a shared -B nonfatal -B symbolic -L/opt/hp83000/f330/prod_com/C++/lib -L/opt/graphics/GLUT/lib/glut -lglut -L/opt/graphics/OpenGL/lib -lGLU -lGL -L/usr/lib/X11R6 -lXmu -lXi -lXext -lXhp11 -lX11 -L/usr/lib/Motif1.2 -b -o libcifset.sl functions.o -dld -lMrm -Xm -lm

The library I am creating is libcifset, the source is functions.c; This compiles with no errors and all the source libraries are shared. I had to download the source for the glut library and compile from scratch as hp's native version was not shared, and the 10.2 install package from the UK mirror had a shared library, but that one did not work (the archive file it was made from had a corrupt symbol). In any case my current glut library compiled with no errors and works on regular C files with the .sl as the library.
No errors are reported during compilation and no errors are reported during runtime, the problem is that when I pass a function name to "glutDisplayFunct()" or other functions requiring a function name as a parameter it accepts it, but it does not show any evidence that it read the function (No window opens and no graphics!). I am rather new at this kind of thing. But I am very persistant. Would seeing the functions.c file help? I can edit it down to eliminate the parts that don't matter (it is quite large).
Thanks for the reply.
Terry
Terry Dabbs
Occasional Contributor

Re: Shared library behavior

I will attach a sample C file please check it out.
Terry Dabbs
Occasional Contributor

Re: Shared library behavior

I couldn't read the attachment so here's another attempt