riebl / artery

OMNeT++ V2X simulation framework for ETSI ITS-G5
GNU General Public License v2.0
204 stars 132 forks source link

Linking against static boost libraries for artery build #76

Closed HBD-BH closed 4 years ago

HBD-BH commented 5 years ago

Hi, I tried to install artery on a clean new VM with Ubuntu 18.04. Building veins, Vanetza, and INET according to the artery build instructions worked just fine. When then performing cmake .. for artery itself, it tells me

-- Found Boost 1.70.0 at /usr/local/lib/cmake/Boost-1.70.0
--   Requested configuration: QUIET COMPONENTS date_time
-- Found boost_headers 1.70.0 at /usr/local/lib/cmake/boost_headers-1.70.0
-- Found boost_date_time 1.70.0 at /usr/local/lib/cmake/boost_date_time-1.70.0
--   libboost_date_time.a

so per my understanding only finding static boost libraries (same for libbboost_system). When I then perform cmake --build ., in the part for building vanetza, it gives me

-- Found Boost 1.70.0 at /usr/local/lib/cmake/Boost-1.70.0
--   Requested configuration: QUIET REQUIRED COMPONENTS date_time
-- Found boost_headers 1.70.0 at /usr/local/lib/cmake/boost_headers-1.70.0
-- Found boost_date_time 1.70.0 at /usr/local/lib/cmake/boost_date_time-1.70.0
--   libboost_date_time.so.1.70.0

so per my understanding it is able to locate the shared libraries for building vanetza (I adjusted BUILD_SHARED_LIBS to ON in the vanetza CMakeLists.txt), and building it terminates successfully.

But then, at 66%, building artery fails with the following error:

/usr/bin/ld: /usr/local/lib/libboost_date_time.a(greg_month.o): relocation R_X86_64_PC32 against symbol `_ZTVN5boost9date_time18all_date_names_putINS_9gregorian17greg_facet_configEcSt19ostreambuf_iteratorIcSt11char_traitsIcEEEE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
src/artery/CMakeFiles/core.dir/build.make:1682: recipe for target 'src/artery/libartery_core.so' failed
make[2]: *** [src/artery/libartery_core.so] Error 1

How can I tell artery to also look for the shared boost libraries instead of the static ones? I already looked into artery/build/CMakeCache.txt, but did not find anything that seemed to fit.

Many thanks for your help.

riebl commented 5 years ago

Have you possibly installed the shared libraries of Boost after setting up Artery's build directory? CMake won't substitute once found libraries (static) by more suitable ones (shared) without further ado then.

HBD-BH commented 5 years ago

No that's not it since I created Artery's build directory after all the previous steps had completed successfully. I even deleted and recreated it several times. However, I might have run make veins before installing boost (shared and static) libraries, could that have set some settings already?

riebl commented 5 years ago

I don't expect make veins to have an influence on this matter. Ultimately, Artery relies on CMake's capabilities to detect the Boost libraries on your system. This is quite similar to Vanetza, though. Which version of CMake are you using? Maybe I can reproduce your setup on my computer then.

HBD-BH commented 5 years ago

I was using 3.10.2 (preinstalled in the Linux image I used), but I will try as next step to update cmake to the latest version and try building again.

riebl commented 5 years ago

Update: I have just tried to replicate your setup by compiling Boost 1.70.0 containing shared and static libraries side by side in its stage/lib directory. Both, Vanetza and Artery select the shared libraries. For reference, my CMake version is 3.13.4 and it only warns about the Boost version being newer than itself. Otherwise, everything is building fine.