Link mlogger to root libs if you build midas as submodule

Issue #217 resolved
Marius Köppel created an issue

If you want to build midas as an submodule you need to add root to target_link_libraries.

@@ -40,6 +40,9 @@ foreach(PROG ${PROGS} ${TESTPROGS})
    target_include_directories(${PROG} PRIVATE ${DRV_DIR} ${PROJECT_SOURCE_DIR}/mxml ${PROJECT_SOURCE_DIR}/mscb/include)
    target_include_directories(${PROG} PRIVATE ${PROJECT_SOURCE_DIR}/drivers)
    target_link_libraries(${PROG} midas ${LIBS} ${DB_LIBS})
+   if (HAVE_ROOT)
+    target_link_libraries(${PROG} ${ROOT_LIBRARIES})
+   endif (HAVE_ROOT)
 endforeach()

Comments (6)

  1. dd1

    Hi, please take a look again. we build rmana and rmlogger with ROOT and all normal midas programs (mlogger, etc) without ROOT.

    This is because historically we have too many build failures (wrong root installed in the wrong place, etc) and run time failures (ROOT libraries updated but mlogger not rebuilt resulting in shared library mismatch and mlogger cannot run). For these reasons we consider removing rmana and rmlogger from the normal build (users complain “cannot build MIDAS” when the actual problem is they have the wrong ROOT in the wrong place, so rmlogger and/or rmana do not build - and with cmake, nothing gets installed into …/bin, so complete build failure even though the user does not even use rmlogger and rmana).

    For more discussion on this, I recommend that you use the midas forum where more stakeholders can contribute.

    K.O.

  2. Marius Köppel reporter

    Okay but then there is maybe a problem with linking root to mlogger bcz in the case I have root mlogger is trying to link root somehow:

    [ 55%] Linking CXX executable mlogger
    /usr/bin/ld: CMakeFiles/mlogger.dir/mlogger.cxx.o: in function `root_book_trees(TREE_STRUCT*)':
    /home/makoeppe/mu3e/mutrigana-base/packages/midas/progs/mlogger.cxx:3207: undefined reference to `TDirectory::CurrentDirectory()'
    /usr/bin/ld: CMakeFiles/mlogger.dir/mlogger.cxx.o: in function `TObject::operator new(unsigned long)':
    /usr/include/TObject.h:152: undefined reference to `TStorage::ObjectAlloc(unsigned long)'
    /usr/bin/ld: CMakeFiles/mlogger.dir/mlogger.cxx.o: in function `root_book_trees(TREE_STRUCT*)':
    /home/makoeppe/mu3e/mutrigana-base/packages/midas/progs/mlogger.cxx:3207: undefined reference to `TTree::TTree(char const*, char const*, int, TDirectory*)'
    /usr/bin/ld: CMakeFiles/mlogger.dir/mlogger.cxx.o: in function `TObject::operator new(unsigned long)':
    /usr/include/TObject.h:152: undefined reference to `TStorage::ObjectAlloc(unsigned long)'
    /usr/bin/ld: CMakeFiles/mlogger.dir/mlogger.cxx.o: in function `root_log_open(LOG_CHN*, int)':
    /home/makoeppe/mu3e/mutrigana-base/packages/midas/progs/mlogger.cxx:3498: undefined reference to `TFile::TFile(char const*, char const*, char const*, int)'
    /usr/bin/ld: /home/makoeppe/mu3e/mutrigana-base/packages/midas/progs/mlogger.cxx:3499: undefined reference to `TFile::IsOpen() const'
    /usr/bin/ld: CMakeFiles/mlogger.dir/mlogger.cxx.o: in function `root_book_trees(TREE_STRUCT*)':
    /home/makoeppe/mu3e/mutrigana-base/packages/midas/progs/mlogger.cxx:3207: undefined reference to `TObject::operator delete(void*)'
    /usr/bin/ld: CMakeFiles/mlogger.dir/mlogger.cxx.o: in function `main.cold':
    /home/makoeppe/mu3e/mutrigana-base/packages/midas/progs/mlogger.cxx:6053: undefined reference to `TApplication::~TApplication()'
    /usr/bin/ld: CMakeFiles/mlogger.dir/mlogger.cxx.o: in function `root_log_open(LOG_CHN*, int)':
    /home/makoeppe/mu3e/mutrigana-base/packages/midas/progs/mlogger.cxx:3498: undefined reference to `TObject::operator delete(void*)'
    /usr/bin/ld: CMakeFiles/mlogger.dir/mlogger.cxx.o: in function `_GLOBAL__sub_I__Z11new_LOG_CHNPKc':
    /usr/include/TVersionCheck.h:42: undefined reference to `TVersionCheck::TVersionCheck(int)'
    /usr/bin/ld: CMakeFiles/mlogger.dir/mlogger.cxx.o: in function `main':
    /home/makoeppe/mu3e/mutrigana-base/packages/midas/progs/mlogger.cxx:6053: undefined reference to `TApplication::TApplication(char const*, int*, char**, void*, int)'
    /usr/bin/ld: /home/makoeppe/mu3e/mutrigana-base/packages/midas/progs/mlogger.cxx:6053: undefined reference to `TApplication::~TApplication()'
    

    but only if I link ROOT_LIBRARIES to mlogger this one builds while rmlogger is building fine. I will post this to the forum.

    Cheers,

    Marius

  3. dd1

    Hi, the output you posted hides all the necessary debug information. Please post the output of “make cmake” (“make cmake3”, depending where you cmake3 is). I need to see the command line of the compiler for mlogger.cxx and of the linker for mlogger.exe. For building mlogger, HAVE_ROOT should be off, for building rmlogger, it should be on.

    K.O.

  4. dd1

    I just checked the current “develop” branch. “make cmake” does not define HAVE_ROOT for building mlogger.o, so all the ROOT code is excluded and linking mlogger.exe does not require ROOT libraries. (rmlogger is does have -DHAVE_ROOT=1, includes the ROOT code, and does link ROOT libraries, which are provided). There is one anomaly with cmake, ROOT include path and link path is added to all compilations (not just rmlogger.o and rmana.o), this is a mistake and I asked Stefan to look into this. But it should not affect what you see. Now waiting for the full output of “make cclean; make cmake”. K.O.

  5. Marius Köppel reporter

    Okay I found my mistake…. I had add_compile_options(-DHAVE_ROOT) in my CMakeList and after this add_subdirectory(packages/midas). This compile options were set then also to midas which leaded to the problem that everything tries to build with root.

  6. Log in to comment