|> >By the way, if you want to statically link in a library (or a series
|> >of them), on the linking "cc" command (or "ld" if that's what you use),
|> >surround the library with -Bstatic ... -Bdynamic. I was able to build
|> >an executable with statically linked X libraries this way. But it still
|> >had dynamic dependencies on libc, libnsl, libw, libintl, and a few others.
|> You can link a program more statically if you wish:
|> cc -o program *.o -Bstatic -lc .. -Bdynamic -ldl -Bstatic
|> The last -Bstatic will make sure that all libs added by cc are linked
|> statically too. You may need to add -lw and -lintl to your link command
When I link our program this way on SunOS 4.1.3 system we cannot execute
it under Solaris 2.. We immediately (where immediately means before we get to main) get a core dump with an illegal system call message. Using truss I find that it is system call 64. In the Solaris /usr/include/sys/syscall.h it says:
/* 64-69 reserved for UNIX PC */
In the SunOS /usr/include/sys/syscall.h it says:
#define SYS_getpagesize 64
For our purposes, when executing under Solaris it is ok if calls to dlopen do not work since it is an optional feature of the program and access to the feature can be disabled at runtime. But I do want to allow dynamic linking when running under SunOS. I want to be able to build a single SunOS executable that will run in both environments. Can this be done?
A related question: How do you debug a SunOS application under Solaris? Solaris de*s (adb and dbx) don't seem to understand Sunos object file formats and Sunos de*s apparently don't use the right debugging interface.
Truss was the best I was able to do in this situation but it wasn't really what I wanted.
A last question: On SunOS, how do you build a C++ shared library (using Sun's 3.0.1 C++) that gets static initialization to happen with it is loaded via a call to dlopen? I have not found any documentation on how to build a shared library and it was only by trial and error that I hit upon:
ld -o foo.so -Bdynamic foo.o
This builds a shared library that can be loaded with dlopen but static variables are not properly initialized. Eg, where bar is a file scope static var
static int bar = initbar();
does not result in a call to initbar() at load time. This works fine under Solaris 2.4 (using C++ 4.0) and HPUX 9.0.1. On the hp you have to call a special version of their shared library loader (cxxshl_load rather than the usual shl_load) to get this behavior. Is there something similar for SunOS?
Where is the building of shared libraries documented for SunOS?
PS Please do NOT reply to this via email - our incoming email is currently
broken and it will bounce.
84 Sherman St.
Cambridge, Mass. 02140