Hi guys.
So I am trying to compile my project using a version of RooAbsArg, that I copied into my local directory and has a tiny modification. I am trying to get rid of the following error message:
duplicate symbol 'vtable for RooRefArray' in:
libRooAbsArg.a(RooAbsArg.cxx.o)
libRooAbsArg.a(G__RooAbsArg.cxx.o)
duplicate symbol 'typeinfo name for RooRefArray' in:
libRooAbsArg.a(RooAbsArg.cxx.o)
libRooAbsArg.a(G__RooAbsArg.cxx.o)
duplicate symbol 'typeinfo for RooRefArray' in:
libRooAbsArg.a(RooAbsArg.cxx.o)
libRooAbsArg.a(G__RooAbsArg.cxx.o)
duplicate symbol 'RooRefArray::Streamer(TBuffer&)' in:
libRooAbsArg.a(RooAbsArg.cxx.o)
libRooAbsArg.a(G__RooAbsArg.cxx.o)
ld: 4 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [StandardHypoTestInv] Error 1
make[2]: *** [CMakeFiles/StandardHypoTestInv.dir/all] Error 2
make[1]: *** [CMakeFiles/StandardHypoTestInv.dir/rule] Error 2
make: *** [StandardHypoTestInv] Error 2
I know the problem has to do with pragma commands in my cmake file. This is how the ADD_LIBRARY_DEF function in my CMakeLists looks
function(ADD_LIBRARY_LINK_DEF1 NAME)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/RootDict/${NAME}Dict_LinkDef.h"
"#ifdef __CINT__\n"
"#pragma link C++ nestedclasses;\n"
"#pragma link C++ nestedtypedefs;\n"
"#pragma link C++ class RooAbsArg- ;\n"
"pragma link C++ class RooRefArray- ;\n"
"#pragma link C++ defined_in \"${CMAKE_CURRENT_SOURCE_DIR}/inc/${NAME}.h\";\n"
# "#pragma link C++ class RooSTLRefCountList<RooAbsArg>-;\n"
"#endif\n")
root_generate_dictionary(
G__${NAME}
${NAME}.h
LINKDEF
"${CMAKE_CURRENT_BINARY_DIR}/RootDict/${NAME}Dict_LinkDef.h"
)
link_libraries(RooFit)
option(BUILD_SHARED_LIBS ON)
# find_library(RooFit /Users/cashcrusaders/Applications/root-6.18.04_hist/root-6.18.04-builddir/lib/ )
add_library(${NAME} G__${NAME}.cxx ${NAME}.cxx )
# add_library(${NAME}_DYN SHARED G__${NAME}.cxx ${NAME}.cxx)
# set(SOURCE_FILE RooWorkspace.cxx)
target_link_libraries(${NAME} PUBLIC ${ROOT_LIBRARIES})
# Link to ROOT's Minuit 2 if available, otherwise standalone edition
if(TARGET ROOT::Minuit2)
target_link_libraries(${NAME} PUBLIC ROOT::Minuit2)
else()
target_link_libraries(${NAME} PUBLIC Minuit2::Minuit2)
endif()
endfunction()
Please help!