views:

33

answers:

1

Hi,

I have two C static libraries libA and libB that I link against my executable E.

libA has a function that makes a call to a function that is in libB:

myLibAFunctionThatCallsAfunctionInLibB( ... )
{ libB_function(...); }

Both libraries compile fine. My executable E also compiles fine. E is compiled with gcc using -lA -lB flags with the proper -I and -L paths.

The problem occurs at runtime when myLibAFunctionThatCallsAfunctionInLibB is called. I get the following error:

dyld: lazy symbol binding failed: Symbol not found: _libB_function
  Referenced from: libA.dylib
  Expected in: flat namespace

I have checked that all architectures are the same (i386). Also nm -a libB.a shows that libB_function is actually part of libB. I have tried declaring libB_function(...); as extern in libA with no difference. I am using gcc 4.2.1 on osx 10.6 if that's of any incidence.

Is it just not possible to cross reference libraries the way I am trying to do it? Do I HAVE to include the implementation code for libB_function in my libA library?

Thanks

Baba

A: 

ok I found a work around. I rewrote my function in libB instead of libA. In short I now call libA from libB instead of libB from libA. In this case it works. I guess it has to do with the fact that libA is dynamic loaded library and B is static ... but I do not understand why. Any expert light is welcomed.

Thanks.

Baba