I’m writing a shared object library which will eventually be used across
multiple processes. It seems to be quite a bit more complicated to
build a shared object in QNX than Linux or Windows NT. Does anyone
know exactly how to build a shared object? I found a utilty called
mkshlib on the ftp site which seems to work fine. However, when the
share object binds to the application at run time it causes a sigsegv
violation. Please help!
David Gibbs wrote:
Steve <> stlang@vt.edu> > wrote:
I’m writing a shared object library which will eventually be used across
multiple processes. It seems to be quite a bit more complicated to
build a shared object in QNX than Linux or Windows NT. Does anyone
know exactly how to build a shared object? I found a utilty called
mkshlib on the ftp site which seems to work fine. However, when the
share object binds to the application at run time it causes a sigsegv
violation. Please help!mkshlib is how you do it.
Have you tried just setting up a small test shared object and getting
that to work ok?
Yup, the mkshlib program comes with a demo. I built and ran their demo
successfully.
When you compile the program that binds to the shared object, do you
make sure you cc to invoke the link, specifying the link library on
the command line? If you use wlink directly, you will likely not get
the correct options to it.
This might be where I’m having the problem. Right now all I’m doing is
linking the library on the command line as in: cc file.c -o file -l
sharedlib_s
Are you using any other shared libraries – Photon,X,Qwindows,TCP/IP?
If so, have you made sure that the address range you are using for your
shared library doesn’t overlap with the address range used by one of
those shared libraries?
Nope, I’m not using any other shared or static libraries!
Are you sure it dies at bind time? Have you tried explicitly running
the shared object before running the application?
Actually, it doesn’t die at bind time. I tested this by putting a “getchar()”
call prior to my shared object accesses. It fails at the first call into the
shared object - with the error sigsegv.
-David
Steve <stlang@vt.edu> wrote:
I’m writing a shared object library which will eventually be used across
multiple processes. It seems to be quite a bit more complicated to
build a shared object in QNX than Linux or Windows NT. Does anyone
know exactly how to build a shared object? I found a utilty called
mkshlib on the ftp site which seems to work fine. However, when the
share object binds to the application at run time it causes a sigsegv
violation. Please help!
mkshlib is how you do it.
Have you tried just setting up a small test shared object and getting
that to work ok?
When you compile the program that binds to the shared object, do you
make sure you cc to invoke the link, specifying the link library on
the command line? If you use wlink directly, you will likely not get
the correct options to it.
Are you using any other shared libraries – Photon,X,Qwindows,TCP/IP?
If so, have you made sure that the address range you are using for your
shared library doesn’t overlap with the address range used by one of
those shared libraries?
Are you sure it dies at bind time? Have you tried explicitly running
the shared object before running the application?
-David
Steve <stlang@vt.edu> wrote:
Yup, the mkshlib program comes with a demo. I built and ran their demo
successfully.
Good.
When you compile the program that binds to the shared object, do you
make sure you cc to invoke the link, specifying the link library on
the command line? If you use wlink directly, you will likely not get
the correct options to it.
This might be where I’m having the problem. Right now all I’m doing is
linking the library on the command line as in: cc file.c -o file -l
sharedlib_s
That looks right – you’re using cc, not trying to run the wlink yourself.
Are you sure it dies at bind time? Have you tried explicitly running
the shared object before running the application?
Actually, it doesn’t die at bind time. I tested this by putting
a “getchar()” call prior to my shared object accesses. It fails
at the first call into the shared object - with the error sigsegv.
Ah, that is a bit different.
You’ve probably tried this – but does the function work properly if
you compile & link against it as a regular (static) function?
Beyond that, I don’t know much more, I’ve only really used the mkshlib
as a tool myself.
Hm… might be one other thing – I think you have to do some setup to
make sure the shared library can call your version of things like malloc(),
free(), printf(), etc.
My library has a header that does things like:
#define malloc (*_qw_malloc)
Then, in the .sl file, it does something like:
#init wind_options.o
_qw_malloc malloc ##function
(Where, if I remember properly the wind_options.o has to be any .o
included, not a particular one.)
I do it for the malloc() family of functions, stdio functions and
getenv(). I think it needs to be done for anything you call that
needs to look at global or static local data – but I’m not sure.
The docs for mkshlib might talk about this… but this is a possible
place to start looking.
-David