Root on FreeBSD 10

Hello,

I wish to build root-6.06.00 on FreeBSD10.2. I am building with clang 3.4.1 and root was configured like this:

cmake -G Ninja …/root-6.06.00 -DCMAKE_INSTALL_PREFIX=/opt/local -Dgnuinstall:bool=ON -Dlibcxx:bool=ON

Compilation fails like this:

[17/1483] Linking CXX executable bin/rootnb.exe
FAILED: : && /usr/bin/CC   -pthread -std=c++11 -Wno-deprecated-declarations -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion -stdlib=libc++ -DR__HAVE_CONFIG -O2 -g -DNDEBUG   main/CMakeFiles/rootnb.exe.dir/src/nbmain.cxx.o  -o bin/rootnb.exe  lib/libCore.so -Wl,-rpath,/home/rmason/Software/Root/64-bit/lib: && :
lib/libCore.so: undefined reference to `__cxa_thread_atexit'

I appreciate any suggestions and help.

Thanks,
Roger

Do you need to use libc++? (the option ‘libcxx’)
If this is still the case it seems that we need to add -lstdc++ in the link statement.

Hello Mato,

Yes, I link against libc++.

Thanks,
Roger

I ran into this problem also. It seems it is a known issue of FreeBSD.

bugs.freebsd.org/bugzilla/show_ … ?id=192320

There might be a fix following this thread

stackoverflow.com/questions/2932 … -with-libc

but I haven’t tried yet.

Just a quick note: I ran into the same problem. As of FreeBSD 10.3 this is still an issue, at least when I do cmake --build .

In the thread there is a suggestion that perhaps you can follow. The alternative is to avoid building this executable (it is not essential) by commenting this line:

diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt
index 22f5ea0..0bff4ce 100644
--- a/main/CMakeLists.txt
+++ b/main/CMakeLists.txt
@@ -11,7 +11,7 @@ endif()
 ROOT_EXECUTABLE(root.exe rmain.cxx LIBRARIES Core Rint)
 ROOT_EXECUTABLE(proofserv.exe pmain.cxx LIBRARIES Core MathCore)
 ROOT_EXECUTABLE(hadd hadd.cxx LIBRARIES Core RIO Net Hist Graf Graf3d Gpad Tree Matrix MathCore Thread)
-ROOT_EXECUTABLE(rootnb.exe nbmain.cxx LIBRARIES Core)
+#ROOT_EXECUTABLE(rootnb.exe nbmain.cxx LIBRARIES Core)
 
 if(CMAKE_Fortran_COMPILER)
   ROOT_EXECUTABLE(g2root g2root.f LIBRARIES minicern)

Thanks for the hint and your help.
Trying that, I noticed that, while I have the same error message, the cause is with another part of the code (I think), namely something in TCling.cxx that makes build fail after reaching 50%. Here’s the error message I get:

[ 50%] Linking CXX executable ../../bin/rootcling ../meta/CMakeFiles/MetaLLVM.dir/src/TCling.cxx.o: In function `TCling::MapCppName(char const*) const': /home/zatoichi/downloads/root/6.06.02/src/core/meta/src/TCling.cxx:6141: undefined reference to `__cxa_thread_atexit' ../meta/CMakeFiles/MetaLLVM.dir/src/TCling.cxx.o: In function `TCling::ClassInfo_FullName(ClassInfo_t*) const': /home/zatoichi/downloads/root/6.06.02/src/core/meta/src/TCling.cxx:6960: undefined reference to `__cxa_thread_atexit' ../meta/CMakeFiles/MetaLLVM.dir/src/TCling.cxx.o: In function `TCling::BaseClassInfo_FullName(BaseClassInfo_t*) const': /home/zatoichi/downloads/root/6.06.02/src/core/meta/src/TCling.cxx:7089: undefined reference to `__cxa_thread_atexit' ../meta/CMakeFiles/MetaLLVM.dir/src/TCling.cxx.o: In function `TCling::DataMemberInfo_ValidArrayIndex(DataMemberInfo_t*) const': /home/zatoichi/downloads/root/6.06.02/src/core/meta/src/TCling.cxx:7249: undefined reference to `__cxa_thread_atexit' ../meta/CMakeFiles/MetaLLVM.dir/src/TCling.cxx.o: In function `TCling::MethodInfo_GetMangledName(MethodInfo_t*) const': /home/zatoichi/downloads/root/6.06.02/src/core/meta/src/TCling.cxx:7607: undefined reference to `__cxa_thread_atexit' ../meta/CMakeFiles/MetaLLVM.dir/src/TClingClassInfo.cxx.o:/home/zatoichi/downloads/root/6.06.02/src/core/meta/src/TClingClassInfo.cxx:1296: more undefined references to `__cxa_thread_atexit' follow c++: error: linker command failed with exit code 1 (use -v to see invocation) core/utils/CMakeFiles/rootcling.dir/build.make:785: recipe for target 'bin/rootcling' failed gmake[2]: *** [bin/rootcling] Error 1 CMakeFiles/Makefile2:16798: recipe for target 'core/utils/CMakeFiles/rootcling.dir/all' failed gmake[1]: *** [core/utils/CMakeFiles/rootcling.dir/all] Error 2 Makefile:149: recipe for target 'all' failed gmake: *** [all] Error 2

[quote=“mato”]In the thread there is a suggestion that perhaps you can follow. The alternative is to avoid building this executable (it is not essential) by commenting this line:

[code]
diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt
index 22f5ea0…0bff4ce 100644
— a/main/CMakeLists.txt
+++ b/main/CMakeLists.txt
@@ -11,7 +11,7 @@ endif()
ROOT_EXECUTABLE(root.exe rmain.cxx LIBRARIES Core Rint)
ROOT_EXECUTABLE(proofserv.exe pmain.cxx LIBRARIES Core MathCore)
ROOT_EXECUTABLE(hadd hadd.cxx LIBRARIES Core RIO Net Hist Graf Graf3d Gpad Tree Matrix MathCore Thread)
-ROOT_EXECUTABLE(rootnb.exe nbmain.cxx LIBRARIES Core)
+#ROOT_EXECUTABLE(rootnb.exe nbmain.cxx LIBRARIES Core)

if(CMAKE_Fortran_COMPILER)
ROOT_EXECUTABLE(g2root g2root.f LIBRARIES minicern)
[/code][/quote]