c++ - CMAKE Linking dynamic library to module, but not showing as link dependency -


point me in right direction if has been asked before. have lib1 , mod2, must linked together. project spread couple of folders , couple of cmakelists.txt files. cmake commands using such:

cmake file 1 (base dir):

# set c/c++ compile , linking flags set(gcc_coverage_compile_flags "-fpic -wno-as-needed")  set(gxx_coverage_compile_flags "-std=c++11")  set(gxx_coverage_link_flags "-wl,--no-undefined -wno-as-needed")  set(cmake_cxx_flags "${cmake_cxx_flags} ${gcc_coverage_compile_flags} ${gxx_coverage_compile_flags}") set(cmake_c_flags "${cmake_c_flags} ${gcc_coverage_compile_flags}") set(cmake_shared_linker_flags "${cmake_shared_linker__flags} ${gcc_coverage_link_flags}") 

cmake file 2 (lib1 dir):

pybind11_add_module(elka_comm__common     shared     pyelka_common.cpp     elka.cpp     elka_comm.cpp )  set_target_properties(elka_comm__common properties     library_output_directory ${elka_binary_dir}/python )  set(cmake_cxx_flags "${cmake_cxx_flags} ${gcc_coverage_compile_flags} ${gxx_coverage_compile_flags}") set(cmake_c_flags "${cmake_c_flags} ${gcc_coverage_compile_flags}") set(cmake_shared_linker_flags "${cmake_shared_linker__flags} ${gcc_coverage_link_flags}")  add_dependencies(elka_comm__common msg_gen) 

cmake file 3 (mod2 dir):

#fixme ldd not showing elka_comm__common link dependency #            -> commport undefined symbol upon module import target_link_libraries(   elka_comm__gnd_station     public   elka_comm__common )  set_target_properties(elka_comm__gnd_station properties     library_output_directory ${elka_binary_dir}/python )  set(cmake_cxx_flags "${cmake_cxx_flags} ${gcc_coverage_compile_flags} ${gxx_coverage_compile_flags}") set(cmake_c_flags "${cmake_c_flags} ${gcc_coverage_compile_flags}") set(cmake_module_linker_flags "${cmake_module_linker__flags} ${gcc_coverage_link_flags}")  add_dependencies(elka_comm__gnd_station     elka_comm__common     msg_gen ) 

a few of steps redundant sanity checks (e.g. setting flags w/cmake variables).

the following partial output of ldd -r <path-to-mod2.so>/mod2.so:

    linux-vdso.so.1 =>  (0x00007fff777fe000)     libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fadfe690000)     libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fadfe479000)     libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fadfe0b0000)     libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fadfddaa000)     /lib64/ld-linux-x86-64.so.2 (0x000055f1e6b2c000) undefined symbol: _ztin4elka8commporte  (build_elka_data_collection/python/elka_comm__gnd_station.so) 

lib1 called elka_comm__common.so, , should show library dependency in ldd, right?

partial output of cmake/make commands:

[100%] linking cxx shared module ../../../python/elka_comm__gnd_station.so cd /home/programs/elka/elka_data_collection/build_elka_data_collection/src/elka_comm/gnd_station && /opt/cmake-3.4.3-linux-x86_64/bin/cmake -e cmake_link_script cmakefiles/elka_comm__gnd_station.dir/link.txt --verbose=1 /usr/bin/c++  -fpic  -fpic -wno-as-needed -std=c++11 -fpic -wno-as-needed -std=c++11 -g   -shared  -o ../../../python/elka_comm__gnd_station.so cmakefiles/elka_comm__gnd_station.dir/pyelka_gnd_station.cpp.o cmakefiles/elka_comm__gnd_station.dir/elka_devices.cpp.o `cmakefiles/elka_comm__gnd_station.dir/inet_comm.cpp.o  -l/home/programs/elka/elka_data_collection/build_elka_data_collection/src/elka_comm/common  -l/home/programs/elka/elka_data_collection/build_elka_data_collection/src/elka_comm/gnd_station  -l/home/programs/elka/elka_data_collection/build_elka_data_collection/python  -l/home/programs/elka/elka_data_collection/python ../../../python/elka_comm__common.so -wl,-rpath,/home/programs/elka/elka_data_collection/build_elka_data_collection/src/elka_comm/common:/home/programs/elka/elka_data_collection/build_elka_data_collection/src/elka_comm/gnd_station:/home/programs/elka/elka_data_collection/build_elka_data_collection/python:/home/programs/elka/elka_data_collection/python` 

from this, seems me linking done correctly. best intuition ordering in cmake generated link command incorrect, can't justify other knowing link commands particular ordering.

solved adding -wl,--no-as-needed cmake_cxx_flags. mindful adding cmake_shared_linker_flags|cmake_module_linker_flags doesn't work, , neither adding -wno-as-needed cmake_cxx_flags.

other issues persist, though. if experienced w/binding c++ code python pm me.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -