[SOLVED] "Symbol lookup error" when trying to use MCH mapping together with QC

I am trying to include the official MCH mapping package into the QC framework, but I am getting a “symbol lookup error” at runtime.

The corresponding header file is

/root/alice/sw/slc7_x86-64/O2/0_O2_DATAFLOW-1/include/MCHMappingInterface/Segmentation.h

on my system, and it is correctly found at compilation time if I do

#include "MCHMappingInterface/Segmentation.h"

Therefore I guess that the O2-dataflow paths are set correctly.

However, when I run the QC I get the following:

[78834:QC-TASK-RUNNER-QcTaskMCH]: o2-qc-run-qc: symbol lookup error: /home/alice/sw/slc7_x86-64/QualityControl/master-1/lib/libQcMuonChambers.so: undefined symbol: mchCathodeSegmentationConstruct

Could it be that the required library does not get properly installed when building the O2-dataflow defaults?

Ping @laphecet as he might have some idea of what’s going on…

Hi Andrea,

Could you point me to your CMakeLists.txt ?
I suspect you miss the actual library implementation (which is separated from the interface itself) O2::MCHMappingImpl3 in your target_link_libraries command

Here is my CMakeLists.txt (it is not on git yet):

set(MODULE_NAME "QcMuonChambers")

# ---- Files ----

set(SRCS
  src/MuonChambersMapping.cxx
  src/MuonChambersDataDecoder.cxx
  src/RawDataProcessor.cxx
  src/PhysicsDataProcessor.cxx
  src/MCHCheckPedestals.cxx
)

set(HEADERS
  include/MuonChambers/MuonChambersMapping.h
  include/MuonChambers/MuonChambersDataDecoder.h
  include/MuonChambers/RawDataProcessor.h
  include/MuonChambers/PhysicsDataProcessor.h
  include/MuonChambers/MCHCheckPedestals.h
)

# ---- Library ----

add_library(${MODULE_NAME} SHARED ${SRCS})

target_include_directories(
  ${MODULE_NAME}
  PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_link_libraries(${MODULE_NAME} PUBLIC QualityControl O2MCHMappingImpl3)

install(
        TARGETS ${MODULE_NAME}
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# ---- ROOT dictionary ----

#generate_root_dict(MODULE_NAME ${MODULE_NAME} LINKDEF "include/MuonChambers/LinkDef.h" DICT_CLASS "${MODULE_NAME}Dict")

add_root_dictionary(${MODULE_NAME}
                    HEADERS include/MuonChambers/MuonChambersMapping.h
                            include/MuonChambers/MuonChambersDataDecoder.h
                            include/MuonChambers/RawDataProcessor.h
                            include/MuonChambers/PhysicsDataProcessor.h
                            include/MuonChambers/MCHCheckPedestals.h
                            include/MuonChambers/sampa_header.h
                    LINKDEF include/MuonChambers/LinkDef.h
                    BASENAME ${MODULE_NAME})

# ---- Tests ----

set(
  TEST_SRCS
)

foreach(test ${TEST_SRCS})
  get_filename_component(test_name ${test} NAME)
  string(REGEX REPLACE ".cxx" "" test_name ${test_name})

  add_executable(${test_name} ${test})
  target_link_libraries(${test_name} PRIVATE ${MODULE_NAME} Boost::unit_test_framework)
  add_test(NAME ${test_name} COMMAND ${test_name})
  set_tests_properties(${test_name} PROPERTIES TIMEOUT 60)
endforeach()

I have added O2MCHMappingImpl3 to the target_link_libraries command, however the library is not found at link time:

[ 93%] Linking CXX shared library ../../lib/libQcMuonChambers.so
/home/alice/sw/slc7_x86-64/GCC-Toolchain/v7.3.0-alice1-11/bin/../lib/gcc/x86_64-unknown-linux-gnu/7.3.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lO2MCHMappingImpl3

However, I checked and the library is present in the good place:

$> find ~/alice/sw/slc7_x86-64/ -name "*MCHMappingImpl*"
/root/alice/sw/slc7_x86-64/O2/0_O2_DATAFLOW-1/lib/libO2MCHMappingImpl3.so

It seems that QC is not including this folder in the library search path when compiling modules. here is the compilation output in verbose mode:

[ 93%] Linking CXX shared library ../../lib/libQcMuonChambers.so
cd /root/alice/sw/BUILD/553566a6afd50c8f106c5df182a724542ad8e71a/QualityControl/Modules/MuonChambers && /root/alice/sw/slc7_x86-64/CMake/v3.13.1-6/bin/cmake -E cmake_link_script CMakeFiles/QcMuonChambers.dir/link.txt --verbose=1
/root/alice/sw/slc7_x86-64/GCC-Toolchain/v7.3.0-alice1-11/bin/c++ -fPIC -fPIC -O2 -std=c++17 -Wall -pedantic -Wextra -O2 -g -DNDEBUG  -shared -Wl,-soname,libQcMuonChambers.so -o ../../lib/libQcMuonChambers.so CMakeFiles/QcMuonChambers.dir/src/MuonChambersMapping.cxx.o CMakeFiles/QcMuonChambers.dir/src/MuonChambersDataDecoder.cxx.o CMakeFiles/QcMuonChambers.dir/src/RawDataProcessor.cxx.o CMakeFiles/QcMuonChambers.dir/src/PhysicsDataProcessor.cxx.o CMakeFiles/QcMuonChambers.dir/src/MCHCheckPedestals.cxx.o CMakeFiles/QcMuonChambers.dir/G__QcMuonChambers.cxx.o  -L/root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib -Wl,-rpath,/root/alice/sw/BUILD/553566a6afd50c8f106c5df182a724542ad8e71a/QualityControl/lib:/root/alice/sw/slc7_x86-64/O2/0_O2_DATAFLOW-1/lib:/root/alice/sw/slc7_x86-64/libInfoLogger/v1.3.2-11/lib:/root/alice/sw/slc7_x86-64/Configuration/v2.2.1-27/lib:/root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib:/root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib:/root/alice/sw/slc7_x86-64/protobuf/v3.7.1-5/lib:/root/alice/sw/slc7_x86-64/zlib/v1.2.8-49/lib:/root/alice/sw/slc7_x86-64/arrow/v0.12.0-alice6-30/lib:/root/alice/sw/slc7_x86-64/FairRoot/c672f280ec-71/lib:/root/alice/sw/slc7_x86-64/Monitoring/v2.6.3-1/lib:/root/alice/sw/slc7_x86-64/FairMQ/v1.4.2-29/lib:/root/alice/sw/slc7_x86-64/FairLogger/v1.5.0-2/lib:/root/alice/sw/slc7_x86-64/Common-O2/v1.4.5-1/lib: ../../lib/libQualityControl.so -lO2MCHMappingImpl3 /root/alice/sw/slc7_x86-64/O2/0_O2_DATAFLOW-1/lib/libO2Framework.so /root/alice/sw/slc7_x86-64/libInfoLogger/v1.3.2-11/lib/libInfoLogger.so /root/alice/sw/slc7_x86-64/Configuration/v2.2.1-27/lib/libConfiguration.so /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libROOTDataFrame.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libTreePlayer.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libGraf3d.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libMultiProc.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libROOTVecOps.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libvdt.so /root/alice/sw/slc7_x86-64/O2/0_O2_DATAFLOW-1/lib/libO2DebugGUI.so /root/alice/sw/slc7_x86-64/fmt/5.3.0-2/lib64/libfmt.a /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_serialization.so /root/alice/sw/slc7_x86-64/O2/0_O2_DATAFLOW-1/lib/libO2CCDB.so /usr/lib64/libcurl.so /root/alice/sw/slc7_x86-64/O2/0_O2_DATAFLOW-1/lib/libO2CommonUtils.so /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libTree.so.6.16.00 /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_iostreams.so /root/alice/sw/slc7_x86-64/protobuf/v3.7.1-5/lib/libprotobuf.so.3.7.1.0 /root/alice/sw/slc7_x86-64/zlib/v1.2.8-49/lib/libz.so /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libXMLParser.so.6.16.00 /root/alice/sw/slc7_x86-64/arrow/v0.12.0-alice6-30/lib/libarrow.so.12.0.0 -lpthread /root/alice/sw/slc7_x86-64/FairRoot/c672f280ec-71/lib/libParMQ.so /root/alice/sw/slc7_x86-64/FairRoot/c672f280ec-71/lib/libParBase.so /root/alice/sw/slc7_x86-64/FairRoot/c672f280ec-71/lib/libFairTools.so /root/alice/sw/slc7_x86-64/O2/0_O2_DATAFLOW-1/lib/libO2Device.so /root/alice/sw/slc7_x86-64/Monitoring/v2.6.3-1/lib/libO2Monitoring.so /root/alice/sw/slc7_x86-64/O2/0_O2_DATAFLOW-1/lib/libO2Headers.so /root/alice/sw/slc7_x86-64/O2/0_O2_DATAFLOW-1/lib/libO2MemoryResources.so /root/alice/sw/slc7_x86-64/FairMQ/v1.4.2-29/lib/libFairMQ.so.1.4.2 /root/alice/sw/slc7_x86-64/FairLogger/v1.5.0-2/lib/libFairLogger.so.1.5.0 /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_container.so -ldl -lrt /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_regex.so /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_thread.so /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_chrono.so /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_date_time.so /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_atomic.so ../../lib/libQualityControlTypes.so /root/alice/sw/slc7_x86-64/Common-O2/v1.4.5-1/lib/libCommon.so /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_program_options.so /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_filesystem.so /root/alice/sw/slc7_x86-64/boost/v1.68.0-51/lib/libboost_system.so /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libNet.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libGpad.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libGraf.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libHist.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libRIO.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libMatrix.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libMathCore.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libImt.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libThread.so.6.16.00 /root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib/libCore.so.6.16.00 -lpthread -ltbb -Wl,-rpath-link,/root/alice/sw/slc7_x86-64/ROOT/v6-16-00-58/lib 
/home/alice/sw/slc7_x86-64/GCC-Toolchain/v7.3.0-alice1-11/bin/../lib/gcc/x86_64-unknown-linux-gnu/7.3.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lO2MCHMappingImpl3

In the target_link_libraries command you must use a target name, not a library name, i.e O2::MCHMappingImpl3.

It works, thanks! I have to admit that I am not yet very familiar with the Alice build environment…