CMake: Link via Macports installed Root library

I successfully installed ROOT via macports. Now I want add the library to my C++ program (for MINUIT2).
Following the Root CMake Guide I added the following lines to my cmake code:

# SET UP ROOT https://root.cern.ch/how/integrate-root-my-project-cmake
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} /opt/local/libexec/root6/etc/root/cmake)
find_package(ROOT REQUIRED COMPONENTS MATH MINUIT2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -std=c++1y -m64")

include_directories(program program_test frameworks/boost_1_64_0 ${ROOT_INCLUDE_DIRS})

...

target_link_libraries(program_run program ${ROOT_LIBRARIES} )

but get missing symbols e.g.

Undefined symbols for architecture x86_64:
  "ROOT::Minuit2::MnStrategy::MnStrategy(unsigned int)", referenced from:
      ROOT::Minuit2::MnMigrad::MnMigrad(ROOT::Minuit2::FCNBase const&, ROOT::Minuit2::MnUserParameters const&, unsigned int) in main.cpp.o
...

What am I missing?

P.S. I checked the output of the ROOT cmake variables:

-- ROOT_INCLUDE_DIRS: /opt/local/libexec/root6/include/root
--
 ROOT_LIBRARIES: /opt/local/libexec/root6/lib/root/libCore.so/opt/local/libexec/root6/lib/root/libRIO.so/opt/local/libexec/root6/lib/root/libNet.so/opt/local/libexec/root6/lib/root/libHist.so/opt/local/libexec/root6/lib/root/libGraf.so/opt/local/libexec/root6/lib/root/libGraf3d.so/opt/local/libexec/root6/lib/root/libGpad.so/opt/local/libexec/root6/lib/root/libTree.so/opt/local/libexec/root6/lib/root/libRint.so/opt/local/libexec/root6/lib/root/libPostscript.so/opt/local/libexec/root6/lib/root/libMatrix.so/opt/local/libexec/root6/lib/root/libPhysics.so/opt/local/libexec/root6/lib/root/libMathCore.so/opt/local/libexec/root6/lib/root/libThread.so/opt/local/libexec/root6/lib/root/libMinuit2.so
-- ROOT_CXX_FLAGS: -pthread -stdlib=libc++ -std=c++1y -m64

aswell as the folders and can see all needed .so libraries.

It looks like the ROOT_LIBRARIES variable is populated with everything concatenated, and that could be breaking your linking stage. Either that or the -m64 flag in your CMAKE_CXX_FLAGS is conflicting with the binary version of ROOT you have installed.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.