views:

515

answers:

1

Hello!

Using bjam on ubuntu, I am building a c++ shared library and trying to use it in an executable. I have to build as shared since it wont link as static (lots of undefined references arise). Thats fine.

Two related problems:

1) Using a heirarchy of Jamfiles, my exe project (testServerHub) has a dependency on the shared library (pythonManager). Here's the Jamfile for the exe:

echo "Compiling serverHub//test" ;

# declare project name
project serverHub//testServerHub
    : build-dir ../_gcc/intermediate 
    ;

# build unit-test using these source files, dependent libraries and settings
exe testServerHub
    : # Source
      ..\\..\\..\\common\\0_8_1\\test\\runner.cpp
      successfulTest.cpp

      # Dependent libraries by path and project name
      ../controller/pythonManager//pythonManager 
      /boost//unit_test_framework

    : # Settings
      <link>shared
    ;

install ..\\bin : testServerHub ; 

And here's my lib Jamfile:

echo "Compiling serverHub/controller//pythonManager" ;

# declare project name
project serverHub/controller//pythonManager     
    : requirements 
      <define>URTH_SERVERHUB
    : build-dir ../../_gcc/intermediate 
    ;

# build library using these source files and settings
lib pythonManager 
    : ../../../../common/0_8_1/controller/pythonManager/pythonManager.cpp
      ../../../../common/0_8_1/controller/pythonManager/cppInterfaceBase.cpp
      cppInterfaceServerHub.cpp
      /boost/python//boost_python
      /user-config//python
    : <link>shared
    ;

# copy and rename
install ../../lib : pythonManager ; 

If I run 'bjam pythonManager' the pythonManager shared library is built and copied to my project lib folder (by the final install command). However if I run 'bjam test', both testServerHub and pythonManager are built, but the libpythonManager.so is not copied to the project lib folder - the install command doens't run!

2) Okay, so as a temporary workaround, I build libpythonManager.so first and then build testServerHub executable. Both compile and link. At runtime, the executable complains about not being able to find libpythonManager.so. Not a great surprise since the runtime linker doesn't know about my project lib folder. How do I tell it to look in a certain directory for shared libraries? or how do I install libpythonManager.so into /usr/local/lib if the install command has no effect on dependent library builds?

Thank you very much

Si

+1  A: 

I think that you could use <install-dependencies>on in the exe Jamfile, like in

install ..\\bin : testServerHub : <install-dependencies>on <install-type>LIB ;

This will install all the libraries (LIB) on which the exe depends.

See eg http://www.boost.org/doc/tools/build/doc/html/bbv2/tasks/installing.html as a reference.

Francesco