SCons to make a shared library (.so) with a static library (.a)

xavjuan picture xavjuan · Feb 11, 2010 · Viewed 12.2k times · Source

I'm trying to get SCons to make a shared library. One of the items going into the .so is a .a static lib.

I have a line like:

env_2.SharedLibrary('libstuff.so', \
  Split("""stuff.cxx mylib/libMine.a""")

And upon running it, I get this error:

scons: *** Source file: mylib/libMine.a \
is static and is not compatible with shared target: libstuff.so

However, I know that a shared library can be made from the .a via a command like:

g++ -m32 -shared -o libstuff.so stuff.o mylib/libMine.a

Any ideas on getting this to work or any workarounds would be greatly appreciated.


Related question: How do I get scons to put an additional string -shared on the LINK command line for the Program() call? If I could do this, I think it would meet my needs.

Answer

Liang Wul picture Liang Wul · Nov 2, 2010

Try to set env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME']=1 in your SConstruct.