Shared libraries

Hi all;

I’ve had trouble getting shared libraries to work properly using QNX6
and GCC.

I’m compiling and linking my library with the “-shared” option, and it
produces “baselib.so”.

I’m then linking my application specifying “baselib.so” on the link
command line. It links without error, but immediately SIGSEGV’s when
it runs.

If I compile the library and use “ar rcs …” to build a “baselib.a”
and link against that, everything runs perfectly.

I’m sure this is an easy one. Can anyone point me in the right
direction?

Thanks,
Andrew.

All functions that are used by your shared library baselib.so must be in
shared libraries as well.
Did you use -Bdynamic for your linker line, to instruct the linker to only
use shared libaries?
The SIGSEGV’s even before main() is called usually indicates that not all
called is compiled with -shared
Markus


“Andrew Lighten” <andrew.lighten@actapps.com.au> wrote in message
news:3a9ee381.45797140@inn.qnx.com

Hi all;

I’ve had trouble getting shared libraries to work properly using QNX6
and GCC.

I’m compiling and linking my library with the “-shared” option, and it
produces “baselib.so”.

I’m then linking my application specifying “baselib.so” on the link
command line. It links without error, but immediately SIGSEGV’s when
it runs.

If I compile the library and use “ar rcs …” to build a “baselib.a”
and link against that, everything runs perfectly.

I’m sure this is an easy one. Can anyone point me in the right
direction?

Thanks,
Andrew.

Markus Loffler <loffler@ces.clemson.edu> wrote:

All functions that are used by your shared library baselib.so must be in
shared libraries as well.

This is not true. The shared library may called non-shared functions
in your executable.

Did you use -Bdynamic for your linker line, to instruct the linker to only
use shared libaries?

This is redundant, since the linker always looks for .so versions of libraries
before .a, unless you pass a -Bstatic. You would need a -Bdynamic to
ask the linker to look for .so libraries again after that.

The SIGSEGV’s even before main() is called usually indicates that not all
called is compiled with -shared

This is correct. I would check that you are not linking your shared
object against any non-shared objects/libraries.

“Andrew Lighten” <> andrew.lighten@actapps.com.au> > wrote in message
news:> 3a9ee381.45797140@inn.qnx.com> …
Hi all;

I’ve had trouble getting shared libraries to work properly using QNX6
and GCC.

I’m compiling and linking my library with the “-shared” option, and it
produces “baselib.so”.

I’m then linking my application specifying “baselib.so” on the link
command line. It links without error, but immediately SIGSEGV’s when
it runs.

If I compile the library and use “ar rcs …” to build a “baselib.a”
and link against that, everything runs perfectly.

I’m sure this is an easy one. Can anyone point me in the right
direction?

Thanks,
Andrew.


cburgess@qnx.com

I’m compiling and linking my library with the “-shared” option, and it
produces “baselib.so”.

If you are compiling with GCC, you need to also use -fPIC in order
for it to produce position-independent code.

Cheers,
Andrew Thomas

On Sun, 4 Mar 2001 09:03:45 -0500, “Andrew Thomas”
<andrew.nospam@cogent.ca> wrote:

If you are compiling with GCC, you need to also use -fPIC in order
for it to produce position-independent code.

Thanks, Andrew. That did the trick.