shared library and statics

I am trying to build a shared library which links to a static library. I
use the following sequence in the linker command to link to the static
lib: “-Bstatic -Wl,–start-group -l libname -Wl,–end-group”. The shared
library seems to build correctly, and when I look at its contents with nm,
I see that all of the symbols which came from the static library are of
type T. I assume that this means that the code has been copied into the
shared library. Now the problem is that I get a memory fault when I try
to execute any of this code. I also tried to do a dlopen() on this shared
library, and this call causes a memory fault before completion. Can
anyone offer any advice? I have a feeling that I’m missing something very
basic here.

thanks
Charlie

The static lib must be compiled with -fpic if it is to be linked into a shared
lib.

Charlie_Surface@oti.com wrote:

I am trying to build a shared library which links to a static library. I
use the following sequence in the linker command to link to the static
lib: “-Bstatic -Wl,–start-group -l libname -Wl,–end-group”. The shared
library seems to build correctly, and when I look at its contents with nm,
I see that all of the symbols which came from the static library are of
type T. I assume that this means that the code has been copied into the
shared library. Now the problem is that I get a memory fault when I try
to execute any of this code. I also tried to do a dlopen() on this shared
library, and this call causes a memory fault before completion. Can
anyone offer any advice? I have a feeling that I’m missing something very
basic here.

thanks
Charlie


cburgess@qnx.com

I’m using ar to build the static lib. Are there any necessary options for
it? Also, do I need to use -fpic when compiling the shared lib?

thanks
Charlie

Charlie_Surface@oti.com wrote:

I’m using ar to build the static lib. Are there any necessary options for
it? Also, do I need to use -fpic when compiling the shared lib?

I’m talking about the compilation, eg

$ qcc -Vgcc_ntox86 -fpic -c a.c
$ ar rv libtest.a a.o


cburgess@qnx.com