Creating a dummy shared object (.so) to depend on other shared objects

I'm trying to create a shared object (.so) that will do this by including one shared object with -lboost, I implicitly include all boost libraries. Here is what I tried:

#!/bin/sh
BOOST_LIBS="-lboost_date_time-gcc43-mt -lboost_filesystem-gcc43-mt"
  #truncated for brevity
g++ $BOOST_LIBS -shared -Wl,-soname,libboost.so.1 -o libboost.so.1.0
ln -si libboost.so.1.0 libboost.so.1
ln -si libboost.so.1 libboost.so

After placing all 3 created files (libboost.so libboost.so.1 libboost.so.1.0) in the same directory as all boost libraries, I tried to compile a test program with it (which depends on -lboost_date_time-gcc43-mt)

g++ -lboost test.cpp

While doing this, I received the same undefined help message that -lboost does not have. Having -lboost_date_time-gcc43-mt works, but this is too verbose :) How do I get -lboost to automatically add to other shared libraries?

+3
3

. , .

, .so .

, , script, , , EXTERN() . , , . , .

+1

'.so', -, ... - make (CMake). CMake :

FIND_PACKAGE(Boost 1.37 COMPONENTS date_time filesystem REQUIRED)
ADD_EXECUTABLE(myexecutable ${myexecutable_SRCS}) 
TARGET_LINK_LIBRARIES(myexecutable ${Boost_LIBRARIES}) 

, "CMakeLists.txt", , :

  •  
  • , Boost 1.37 , "date_time" " ".  
  • "myexecutable" , .  
  • "myexecutable" "date_time" " " boost.

: KDE CMake.

+1

, .so boost.so, ( ). :

$ export BOOST_ROOT=/home/ghost/Work/Boost/boost-svn
$ g++ -shared -Wl,-soname,libboost.so -o libboost.so $BOOST_ROOT/stage/lib/libboost_program_options.so
$ g++ -L . -I $BOOST_ROOT first.cpp -lboost -Wl,-R$BOOST_ROOT/stage/lib
$ LD_LIBRARY_PATH=.:$BOOST_ROOT/stage/lib ./a.out

And it worked. However, note that dances with -R and LD_LIBRARY_PATH. I do not know how you can include the path to Boost.so inside your libboost.so so that they are used both for communication and for the actual launch of the application. I can include rpath inside libboost.so just fine, but it is ignored when resolving characters for the application.

+1
source

Source: https://habr.com/ru/post/1717792/


All Articles