1

I have an executable project which uses a shared library, that includes a static library. Then from the executable, I try to load another shared library with dlopen. That library is found but it cannot find symbols from static library.

Here is the structure:

-- SHARED LIB 1
   -- (compiled with) Static Lib 1

-- EXECUTABLE
   -- SHARED LIB 1
   -- dlopen SHARED LIB 2  XX ERROR: SHARED LIB 2 cannot find symbols of Static Lib 1

Both SHARED LIB 1 and SHARED LIB 2 are linked from /usr/lib.

It seems that I miss some flags.

How could I solve this issue?

Mert Mertce
  • 1,614
  • 3
  • 21
  • 32
  • 1
    Your second shared library needs to load your static library as a shared library, or be compiled with it as a static library. This vitiates the benefits of making it static. – Davislor Sep 18 '15 at 10:23
  • You have to declare the symbols `extern "C"` (or you have to use their mangled names). Are you doing that? – Galik Sep 18 '15 at 10:32

1 Answers1

0

what flags are used to build the "SHARED LIB 1"? AFAIK -fvisibility won't affect static libs.

However if you use --exclude-libs on linking, the "Static Lib 1"s symbol will be removed.

Hope this Question may help: How to apply gcc -fvisibility option to symbols in static libraries?

Community
  • 1
  • 1
crazii
  • 311
  • 1
  • 6