# Root on freebsd, again

**URL:** <https://root-forum.cern.ch/t/root-on-freebsd-again/26806>\
**Category:** ROOT\
**Created:** [November 6, 2017, 10:31am UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806 "2017-11-06T10:31:34Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roger\_Mason](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/a88e57/32.png) [@Roger\_Mason](https://root-forum.cern.ch/u/Roger_Mason)\
**Post date:** [November 6, 2017, 10:31am UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/1 "2017-11-06T10:31:34Z")

</div>

Hello root users,

I am trying to build root-6.10.08 on freebsd 10.3. I set up a script to run the configuration step:

# Configure

#!/usr/local/bin/zsh

cmake …/root-6.10.08/ -G Ninja   
-DCMAKE\_INSTALL\_PREFIX=/opt/root   
-DBUILD\_SHARED\_LIBS:bool=ON   
-DCMAKE\_CXX\_COMPILER:string=/usr/local/bin/g++6   
-DCMAKE\_C\_COMPILER:string=/usr/local/bin/gcc6   
-DCMAKE\_EXE\_LINKER\_FLAGS:string="-lm -lcrypt"   
-Dcxx14:bool=ON   
-Dccache:bool=ON

# Fix cmake

wd=$(pwd)  
cd ./LZ4-prefix/src/LZ4-stamp  
sed -I.orig ‘s/make cmake/gmake cmake/’ LZ4-configure-RelWithDebInfo.cmake  
sed -I.orig ‘s/MOREFLAGS=-fPIC make/MOREFLAGS=-fPIC gmake/’ LZ4-build-RelWithDebInfo.cmake  
sed -I.orig ‘s/make install/gmake install/’ LZ4-install-RelWithDebInfo.cmake  
cd ${wd}

# Build

I then build thus:  
cmake --build . – -j8

# Error

The build fails with several messages like this:

[5064/6803] Generating G\_\_std\_valarray.cxx, …/…/lib/libvalarrayDict.rootmap  
FAILED: core/clingutils/G\_\_std\_valarray.cxx lib/libvalarrayDict.rootmap  
cd /home/rmason/Software/Root/64-bit/core/clingutils && /home/rmason/Software/Root/64-bit/core/rootcling\_stage1/src/rootcling\_stage1 -f G\_\_std\_valarray.cxx -s  
/home/rmason/Software/Root/64-bit/lib/libvalarrayDict.so -excludePath /home/rmason/Software/Root/root-6.10.08 -excludePath /home/rmason/Software/Root/64-bit  
-rml [libvalarrayDict.so](http://libvalarrayDict.so) -rmf /home/rmason/Software/Root/64-bit/lib/libvalarrayDict.rootmap -I/home/rmason/Software/Root/root-6.10.08 -I/home/rmason/Software/R  
oot/root-6.10.08/interpreter/cling/include -I/home/rmason/Software/Root/64-bit/include -I/home/rmason/Software/Root/root-6.10.08/interpreter/llvm/src/include  
-I/home/rmason/Software/Root/64-bit/interpreter/llvm/src/include -I/home/rmason/Software/Root/root-6.10.08/interpreter/llvm/src/tools/clang/include -I/home/rm  
ason/Software/Root/64-bit/interpreter/llvm/src/tools/clang/include -I/home/rmason/Software/Root/root-6.10.08/core/clingutils/res -I/home/rmason/Software/Root/  
root-6.10.08/core/clingutils/…/foundation/res -I/home/rmason/Software/Root/64-bit/etc/cling/cint valarray /home/rmason/Software/Root/root-6.10.08/core/clingu  
tils/src/valarrayLinkdef.h  
terminate called after throwing an instance of 'std::logic\_error’  
what(): basic\_string::\_M\_construct null not valid

Based on some searching, this may be caused by an attempt to assign a null pointer to a string. Unfortunately I have no idea where in the code this is happening. I would appreciate some help in tracking the problem down.

Thanks,  
Roger

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [November 8, 2017, 7:53am UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/2 "2017-11-08T07:53:11Z")

</div>

Hi,

I tried a build with GCC6 and C++14 on Linux, but I cannot reproduce the issue you have.  
Could you please try with the master branch instead of 6.10/08? Also, if C++14 fails, please try with C++11.  
We do not have a FreeBSD machine to test, unfortunately. We’d need to set one up.

---

<div class="post-metadata">

**Author:** ![Roger\_Mason](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/a88e57/32.png) [@Roger\_Mason](https://root-forum.cern.ch/u/Roger_Mason)\
**Post date:** [November 8, 2017, 2:20pm UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/3 "2017-11-08T14:20:23Z")

</div>

Hello,

Thanks for the response.

Using C++14.

During configuration cmake complained that SITypeRewriter.cpp was  
missing from ‘root/interpreter/llvm/src/lib/Target/AMDGPU/CMakeLists.txt’.  
I added it.

The master branch then fails like this:

root/interpreter/llvm/src/lib/Target/AMDGPU/SITypeRewriter.cpp:154:42:  
error: ‘llvm::FunctionPass\* llvm::createSITypeRewriter()’ should have  
been declared inside 'llvm’  
FunctionPass \*llvm::createSITypeRewriter() {

Cheers,  
Roger

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [November 8, 2017, 3:30pm UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/4 "2017-11-08T15:30:05Z")

</div>

We are looking into this. The master branch has an LLVM upgrade and that may be missing some files.

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [November 8, 2017, 3:49pm UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/5 "2017-11-08T15:49:14Z")

</div>

Could you please pull and try again? [This commit](https://github.com/root-project/root/commit/bb3562d90311f56429a76fe41d419bbc30d1f893) should fix the problem you are seeing. Thanks!

---

<div class="post-metadata">

**Author:** ![Roger\_Mason](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/a88e57/32.png) [@Roger\_Mason](https://root-forum.cern.ch/u/Roger_Mason)\
**Post date:** [November 8, 2017, 7:11pm UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/6 "2017-11-08T19:11:10Z")

</div>

The build now proceeds further but fails like this:

FAILED: core/metacling/src/CMakeFiles/MetaCling.dir/TCling.cxx.o  
ccache /usr/local/bin/g++6 -Iinclude -I/home/rmason/Software/Root-Master/root/interpreter/llvm/src/include -Iinterpreter/llvm/src/include -I/home/rmason/Software/Root-Master/root/interpreter/llvm/src/tools/clang/include -Iinterpreter/llvm/src/tools/clang/include -I/home/rmason/Software/Root-Master/root/interpreter/cling/include -I/home/rmason/Software/Root-Master/root/core/metacling/src/…/res -I/home/rmason/Software/Root-Master/root/core/metacling/src/…/…/clingutils/res -I/home/rmason/Software/Root-Master/root/core/metacling/src/…/…/foundation/res -pthread -std=c++14 -fvisibility=hidden -Wno-shadow -fno-strict-aliasing -Wno-unused-parameter -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -DLLVM\_BUILD\_GLOBAL\_ISEL -D\_\_STDC\_CONSTANT\_MACROS -D\_\_STDC\_FORMAT\_MACROS -D\_\_STDC\_LIMIT\_MACROS -Wno-maybe-uninitialized -O2 -g -DNDEBUG -fPIC -MD -MT core/metacling/src/CMakeFiles/MetaCling.dir/TCling.cxx.o -MF core/metacling/src/CMakeFiles/MetaCling.dir/TCling.cxx.o.d -o core/metacling/src/CMakeFiles/MetaCling.dir/TCling.cxx.o -c /home/rmason/Software/Root-Master/root/core/metacling/src/TCling.cxx  
In file included from include/TInterpreter.h:27:0,  
from /home/rmason/Software/Root-Master/root/core/metacling/src/TCling.h:27,  
from /home/rmason/Software/Root-Master/root/core/metacling/src/TCling.cxx:20:  
/home/rmason/Software/Root-Master/root/core/metacling/src/TCling.cxx: In member function ‘virtual Long\_t TCling::ProcessLine(const char\*, TInterpreter::EErrorCode\*)’:  
/home/rmason/Software/Root-Master/root/core/metacling/src/TCling.cxx:2087:65: error: could not convert ‘(void)0’ from ‘void’ to 'bool’  
R\_\_LOCKGUARD(fLockProcessLine ? gInterpreterMutex : 0);  
^  
include/TVirtualMutex.h:160:36: note: in definition of macro ‘R\_\_LOCKGUARD’  
#define R\_\_LOCKGUARD(mutex) (void)mutex; { }

I will change (void)mutex to (bool)mutex and see what happens.

---

<div class="post-metadata">

**Author:** ![Roger\_Mason](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/a88e57/32.png) [@Roger\_Mason](https://root-forum.cern.ch/u/Roger_Mason)\
**Post date:** [November 8, 2017, 7:35pm UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/7 "2017-11-08T19:35:46Z")

</div>

Now the build proceeds until:

```auto
FAILED: core/base/G__Core.cxx lib/libCore.rootmap
cd /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/core/base && /usr/local/bin/cmake -E env LD_LIBRARY_PATH=/home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/lib::/opt/local/lib:/opt/lib/root:/opt/lib:/home/rmason/Software/Scalapack/64-bit-cmake/lib:/opt/local/lib:/opt/lib/root:/opt/lib:/home/rmason/Software/Scalapack/64-bit-cmake/lib:/usr/local/lib/gcc6:/usr/local/lib/gcc6 /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/core/rootcling_stage1/src/rootcling_stage1 -v2 -f G__Core.cxx [snip]

terminate called after throwing an instance of 'std::logic_error'
  what(): basic_string::_M_construct null not valid
Child aborted

```

I got a backtrace from the core dump:

```auto
#0 0x00000008054e339a in thr_kill () from /lib/libc.so.7
#1 0x00000008054e3386 in raise () from /lib/libc.so.7
#2 0x00000008054e3309 in abort () from /lib/libc.so.7
#3 0x0000000805120b2d in __gnu_cxx::__ verbose_terminate_handler () at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.4.0/libstdc++-v3/libsupc++/vterminate.cc:95
#4 0x000000080511db68 in __cxxabiv1::__ terminate (handler=<optimized out>)
    at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.4.0/libstdc++-v3/libsupc++/eh_terminate.cc:47
#5 0x000000080511dbd1 in std::terminate () at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.4.0/libstdc++-v3/libsupc++/eh_terminate.cc:57
#6 0x000000080511dde8 in __cxxabiv1::__ cxa_throw (obj=obj@entry=0x80607f140, tinfo=0x805416a38 <typeinfo for std::logic_error>, 
    dest=0x8051367b0 <std::logic_error::~logic_error()>) at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.4.0/libstdc++-v3/libsupc++/eh_throw.cc:87
#7 0x000000080514ca47 in std::__throw_logic_error (__s=__s@entry=0x2eba0a8 "basic_string::_M_construct null not valid")
    at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.4.0/libstdc++-v3/src/c++11/functexcept.cc:74
#8 0x00000000005e28fa in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
    __end=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>,__ beg=0x0, this=0x7fffffffac20)
    at /usr/local/lib/gcc6/include/c++/bits/basic_string.tcc:212
#9 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char const*> (
    __end=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>,__ beg=0x0, this=0x7fffffffac20)
    at /usr/local/lib/gcc6/include/c++/bits/basic_string.h:196
#10 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
    __end=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>,__ beg=0x0, this=0x7fffffffac20)
    at /usr/local/lib/gcc6/include/c++/bits/basic_string.h:215
#11 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (__a=..., __s=0x0, this=0x7fffffffac20)
    at /usr/local/lib/gcc6/include/c++/bits/basic_string.h:456
#12 GetIncludeDir () at /home/rmason/Software/Root-Master/root/core/rootcling_stage1/src/rootcling_stage1.cxx:26
#13 0x00000000005b99c1 in RootClingMain (argc=<optimized out>, argc@entry=209, argv=argv@entry=0x7fffffffcde0, isDeep=isDeep@entry=false, 
    isGenreflex=isGenreflex@entry=false) at /home/rmason/Software/Root-Master/root/core/dictgen/src/rootcling_impl.cxx:4219
#14 0x00000000005c62e1 in ROOT_rootcling_Driver (argc=209, argv=0x7fffffffcde0, config=...)
    at /home/rmason/Software/Root-Master/root/core/dictgen/src/rootcling_impl.cxx:6099
#15 0x00000000004c7245 in main (argc=<optimized out>, argv=<optimized out>)
    at /home/rmason/Software/Root-Master/root/core/rootcling_stage1/src/rootcling_stage1.cxx:45

Line 26 in root/core/rootcling_stage1/src/rootcling_stage1.cxx is

static std::string incdir = std::string(getenv("ROOTSYS")) + "/include";

```

In my build, ROOTSYS is unset. Running a simple test program with a call to getenv() on an unset environment variable ends with the same error as the call to rootcling\_stage1:

terminate called after throwing an instance of 'std::logic\_error’  
what(): basic\_string::\_M\_construct null not valid

---

<div class="post-metadata">

**Author:** ![teemperor](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/teemperor/32/14099_2.png) [@teemperor](https://root-forum.cern.ch/u/teemperor)\
**Post date:** [November 9, 2017, 11:00am UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/8 "2017-11-09T11:00:56Z")

</div>

You can probably work around this issue by setting ROOTSYS manually to the build folder (e.g. `ROOTSYS=/home/username/root-build/`) and then call make from that. Maybe that’s enough to make your build succeed.

In general CMake is responsible for setting this variable, but I’m not sure why this is not happening in your build setup. I started a FreeBSD build and we’ll see if it also fails there.

---

<div class="post-metadata">

**Author:** ![Roger\_Mason](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/a88e57/32.png) [@Roger\_Mason](https://root-forum.cern.ch/u/Roger_Mason)\
**Post date:** [November 9, 2017, 5:30pm UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/9 "2017-11-09T17:30:34Z")

</div>

Thank you teemperor.

Now the build fails like this:

```auto
FAILED: core/base/G__Core.cxx lib/libCore.rootmap 
cd /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/core/base && /usr/local/bin/cmake -E env LD_LIBRARY_PATH=/home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/lib::/opt/local/lib:/opt/lib/root:/opt/lib:/home/rmason/Software/Scalapack/64-bit-cmake/lib:/opt/local/lib:/opt/lib/root:/opt/lib:/home/rmason/Software/Scalapack/64-bit-cmake/lib:/usr/local/lib/gcc6:/usr/local/lib/gcc6 /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/core/rootcling_stage1/src/rootcling_stage1 -v2 -f G__Core.cxx -s /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/lib/libCore.so -excludePath /home/rmason/Software/Root-Master/root -excludePath /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild -rml libCore.so -rmf /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/lib/libCore.rootmap -DSYSTEM_TYPE_unix -I/home/rmason/Software/Root-Master/root -I/home/rmason/Software/Root-Master/root/interpreter/cling/include -I/home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/include -I/home/rmason/Software/Root-Master/root/core/base/res -I/home/rmason/Software/Root-Master/root/core/base/../foundation/res -I/usr/include TApplication.h TApplicationImp.h TAtt3D.h TAttAxis.h TAttBBox.h TAttBBox2D.h TAttFill.h TAttLine.h TAttMarker.h TAttPad.h TAttText.h TBase64.h TBenchmark.h TBrowser.h TBrowserImp.h TBuffer.h TBuffer3D.h TBuffer3DTypes.h TCanvasImp.h TColor.h TColorGradient.h TContextMenu.h TContextMenuImp.h TControlBarImp.h TDatime.h TDirectory.h TEnv.h TError.h TException.h TExec.h TFileCollection.h TFileInfo.h TFolder.h TGuiFactory.h TInetAddress.h TInspectorImp.h TMD5.h TMacro.h TMathBase.h TMemberInspector.h TMessageHandler.h TNamed.h TObjString.h TObject.h TObjectSpy.h TPRegexp.h TParameter.h TPluginManager.h TPoint.h TProcessID.h TProcessUUID.h TQClass.h TQCommand.h TQConnection.h TQObject.h TROOT.h TRedirectOutputGuard.h TRef.h TRefCnt.h TRegexp.h TRemoteObject.h TRootIOCtor.h TStopwatch.h TStorage.h TString.h TStringLong.h TStyle.h TSysEvtHandler.h TSystem.h TSystemDirectory.h TSystemFile.h TTask.h TThreadSlots.h TTime.h TTimeStamp.h TTimer.h TUUID.h TUri.h TUrl.h TVersionCheck.h TVirtualAuth.h TVirtualFFT.h TVirtualGL.h TVirtualMonitoring.h TVirtualMutex.h TVirtualPS.h TVirtualPad.h TVirtualPadEditor.h TVirtualPadPainter.h TVirtualPerfStats.h TVirtualQConnection.h TVirtualRWMutex.h TVirtualTableInterface.h TVirtualViewer3D.h TVirtualX.h GuiTypes.h MessageTypes.h KeySymbols.h Buttons.h /home/rmason/Software/Root-Master/root/core/base/v7/inc/ROOT/TDirectory.hxx /home/rmason/Software/Root-Master/root/core/base/v7/inc/ROOT/TDirectoryEntry.hxx /home/rmason/Software/Root-Master/root/core/base/v7/inc/ROOT/TDrawable.hxx /home/rmason/Software/Root-Master/root/core/base/v7/inc/ROOT/TIndexIter.hxx /home/rmason/Software/Root-Master/root/core/base/v7/inc/ROOT/TLogger.hxx strlcpy.h snprintf.h TArray.h TArrayC.h TArrayD.h TArrayF.h TArrayI.h TArrayL.h TArrayL64.h TArrayS.h TBits.h TBtree.h TClassTable.h TClonesArray.h TCollection.h TCollectionProxyInfo.h TExMap.h THashList.h THashTable.h TIterator.h TList.h TMap.h TObjArray.h TObjectTable.h TOrdCollection.h TRefArray.h TRefTable.h TSeqCollection.h TSortedList.h TVirtualCollectionProxy.h ESTLType.h RStringView.h TClassEdit.h ROOT/RArrayView.hxx ROOT/RMakeUnique.hxx ROOT/TypeTraits.hxx ROOT/rhysd_array_view.hxx TUnixSystem.h TClingRuntime.h root_std_complex.h TBaseClass.h TClass.h TClassGenerator.h TClassMenuItem.h TClassRef.h TClassStreamer.h TDataMember.h TDataType.h TDictAttributeMap.h TDictionary.h TEnum.h TEnumConstant.h TFileMergeInfo.h TFunction.h TFunctionTemplate.h TGenericClassInfo.h TGlobal.h TInterpreter.h TInterpreterValue.h TIsAProxy.h TListOfDataMembers.h TListOfEnums.h TListOfEnumsWithLock.h TListOfFunctionTemplates.h TListOfFunctions.h TMemberStreamer.h TMethod.h TMethodArg.h TMethodCall.h TProtoClass.h TRealData.h TSchemaHelper.h TSchemaRule.h TSchemaRuleSet.h TStatusBitsChecker.h TStreamer.h TStreamerElement.h TToggle.h TToggleGroup.h TVirtualIsAProxy.h TVirtualRefProxy.h TVirtualStreamerInfo.h Getline.h /home/rmason/Software/Root-Master/root/core/base/inc/LinkDef.h
Disabling gnu++: clang has no __float128 support on this target!
In file included from input_line_4:2:
In file included from /usr/local/lib/gcc6/include/c++/stdlib.h:36:
In file included from /usr/local/lib/gcc6/include/c++/cstdlib:75:
In file included from /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/etc/cling/lib/clang/5.0.0/include/stdlib.h:8:
/usr/include/stdlib.h:84:6: error: 'atexit' is missing exception specification 'throw()'
int atexit(void (*)(void));
         ^
input_line_2:3:16: note: previous declaration is here
extern "C" int atexit(void(*f)()) throw () ;

```

---

<div class="post-metadata">

**Author:** ![teemperor](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/teemperor/32/14099_2.png) [@teemperor](https://root-forum.cern.ch/u/teemperor)\
**Post date:** [November 11, 2017, 7:47am UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/10 "2017-11-11T07:47:19Z")

</div>

I see, the problem is that you have a GNU C++ library but the BSD C library, and we assume people that use the GNU C++ also use the GNU C library. Can you test this patch if it fixes it?

```diff
diff --git a/interpreter/cling/lib/Interpreter/Interpreter.cpp b/interpreter/cling/lib/Interpreter/Interpreter.cpp
index 291ac70418..569076e73e 100644
--- a/interpreter/cling/lib/Interpreter/Interpreter.cpp
+++ b/interpreter/cling/lib/Interpreter/Interpreter.cpp
@@ -404,7 +404,7 @@ namespace cling {

     // Intercept all atexit calls, as the Interpreter and functions will be long
     // gone when the -native- versions invoke them.
-#if defined( __GLIBCXX__ ) && !defined( __APPLE__ )
+#if defined( __GLIBC__ ) && !defined( __APPLE__ )
     const char* LinkageCxx = "extern \"C++\"";
     const char* Attr = LangOpts.CPlusPlus ? " throw () " : "";
     const char* cxa_atexit_is_noexcept = LangOpts.CPlusPlus ? " noexcept" : "";

```

The next error I’ve encountered is that you’ll need to link with `-lelf` and then I get:

```auto
[8/2325] Linking CXX shared library lib/libCling.so
FAILED: lib/libCling.so 
: && /usr/bin/c++ -fPIC -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion -pthread -std=c++14 -fvisibility=hidden -Wno-shadow -fno-strict-aliasing -Wno-unused-parameter -Wwrite-strings -Wno-long-long -DLLVM_BUILD_GLOBAL_ISEL -D __STDC_CONSTANT_MACROS -D__ STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Wno-conditional-uninitialized -O2 -g -DNDEBUG -shared -Wl,-soname,libCling.so -o lib/libCling.so core/clingutils/CMakeFiles/ClingUtils.dir/src/RStl.cxx.o core/clingutils/CMakeFiles/ClingUtils.dir/src/TClingUtils.cxx.o core/dictgen/CMakeFiles/Dictgen.dir/src/BaseSelectionRule.cxx.o core/dictgen/CMakeFiles/Dictgen.dir/src/ClassSelectionRule.cxx.o core/dictgen/CMakeFiles/Dictgen.dir/src/DictSelectionReader.cxx.o core/dictgen/CMakeFiles/Dictgen.dir/src/LinkdefReader.cxx.o core/dictgen/CMakeFiles/Dictgen.dir/src/Scanner.cxx.o core/dictgen/CMakeFiles/Dictgen.dir/src/SelectionRules.cxx.o core/dictgen/CMakeFiles/Dictgen.dir/src/TModuleGenerator.cxx.o core/dictgen/CMakeFiles/Dictgen.dir/src/VariableSelectionRule.cxx.o core/dictgen/CMakeFiles/Dictgen.dir/src/XMLReader.cxx.o core/dictgen/CMakeFiles/Dictgen.dir/src/rootcling_impl.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TCling.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TClingBaseClassInfo.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TClingCallFunc.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TClingCallbacks.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TClingClassInfo.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TClingDataMemberInfo.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TClingMethodArgInfo.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TClingMethodInfo.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TClingTypeInfo.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TClingTypedefInfo.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/TClingValue.cxx.o core/metacling/src/CMakeFiles/MetaCling.dir/rootclingTCling.cxx.o core/metacling/src/CMakeFiles/Cling.dir/dummy.cxx.o -L/usr/local/lib -Wl,-rpath,/usr/local/lib: interpreter/llvm/src/lib/libclingInterpreter.a interpreter/llvm/src/lib/libclingMetaProcessor.a interpreter/llvm/src/lib/libclingUtils.a -lelf -Wl,--unresolved-symbols=ignore-in-object-files interpreter/llvm/src/lib/libclingInterpreter.a interpreter/llvm/src/lib/libclangCodeGen.a interpreter/llvm/src/lib/libclangFrontend.a interpreter/llvm/src/lib/libclangDriver.a interpreter/llvm/src/lib/libclangSerialization.a interpreter/llvm/src/lib/libLLVMCoroutines.a interpreter/llvm/src/lib/libLLVMCoverage.a interpreter/llvm/src/lib/libLLVMLTO.a interpreter/llvm/src/lib/libLLVMObjCARCOpts.a interpreter/llvm/src/lib/libLLVMPasses.a interpreter/llvm/src/lib/libLLVMOption.a interpreter/llvm/src/lib/libLLVMOrcJIT.a interpreter/llvm/src/lib/libLLVMExecutionEngine.a interpreter/llvm/src/lib/libLLVMRuntimeDyld.a interpreter/llvm/src/lib/libLLVMAArch64CodeGen.a interpreter/llvm/src/lib/libLLVMAArch64AsmParser.a interpreter/llvm/src/lib/libLLVMAArch64Disassembler.a interpreter/llvm/src/lib/libLLVMAArch64Desc.a interpreter/llvm/src/lib/libLLVMAArch64AsmPrinter.a interpreter/llvm/src/lib/libLLVMAArch64Info.a interpreter/llvm/src/lib/libLLVMAArch64Utils.a interpreter/llvm/src/lib/libLLVMAMDGPUCodeGen.a interpreter/llvm/src/lib/libLLVMAMDGPUAsmParser.a interpreter/llvm/src/lib/libLLVMAMDGPUDisassembler.a interpreter/llvm/src/lib/libLLVMAMDGPUDesc.a interpreter/llvm/src/lib/libLLVMAMDGPUAsmPrinter.a interpreter/llvm/src/lib/libLLVMAMDGPUInfo.a interpreter/llvm/src/lib/libLLVMAMDGPUUtils.a interpreter/llvm/src/lib/libLLVMARMCodeGen.a interpreter/llvm/src/lib/libLLVMARMAsmParser.a interpreter/llvm/src/lib/libLLVMARMDisassembler.a interpreter/llvm/src/lib/libLLVMARMDesc.a interpreter/llvm/src/lib/libLLVMARMAsmPrinter.a interpreter/llvm/src/lib/libLLVMARMInfo.a interpreter/llvm/src/lib/libLLVMBPFCodeGen.a interpreter/llvm/src/lib/libLLVMBPFDesc.a interpreter/llvm/src/lib/libLLVMBPFAsmPrinter.a interpreter/llvm/src/lib/libLLVMBPFDisassembler.a interpreter/llvm/src/lib/libLLVMBPFInfo.a interpreter/llvm/src/lib/libLLVMHexagonCodeGen.a interpreter/llvm/src/lib/libLLVMHexagonAsmParser.a interpreter/llvm/src/lib/libLLVMHexagonDisassembler.a interpreter/llvm/src/lib/libLLVMHexagonDesc.a interpreter/llvm/src/lib/libLLVMHexagonInfo.a interpreter/llvm/src/lib/libLLVMLanaiCodeGen.a interpreter/llvm/src/lib/libLLVMLanaiAsmParser.a interpreter/llvm/src/lib/libLLVMLanaiDisassembler.a interpreter/llvm/src/lib/libLLVMLanaiDesc.a interpreter/llvm/src/lib/libLLVMLanaiAsmPrinter.a interpreter/llvm/src/lib/libLLVMLanaiInfo.a interpreter/llvm/src/lib/libLLVMMipsCodeGen.a interpreter/llvm/src/lib/libLLVMMipsAsmParser.a interpreter/llvm/src/lib/libLLVMMipsDesc.a interpreter/llvm/src/lib/libLLVMMipsAsmPrinter.a interpreter/llvm/src/lib/libLLVMMipsDisassembler.a interpreter/llvm/src/lib/libLLVMMipsInfo.a interpreter/llvm/src/lib/libLLVMMSP430CodeGen.a interpreter/llvm/src/lib/libLLVMMSP430Desc.a interpreter/llvm/src/lib/libLLVMMSP430AsmPrinter.a interpreter/llvm/src/lib/libLLVMMSP430Info.a interpreter/llvm/src/lib/libLLVMNVPTXCodeGen.a interpreter/llvm/src/lib/libLLVMipo.a interpreter/llvm/src/lib/libLLVMIRReader.a interpreter/llvm/src/lib/libLLVMAsmParser.a interpreter/llvm/src/lib/libLLVMInstrumentation.a interpreter/llvm/src/lib/libLLVMLinker.a interpreter/llvm/src/lib/libLLVMVectorize.a interpreter/llvm/src/lib/libLLVMNVPTXDesc.a interpreter/llvm/src/lib/libLLVMNVPTXAsmPrinter.a interpreter/llvm/src/lib/libLLVMNVPTXInfo.a interpreter/llvm/src/lib/libLLVMPowerPCCodeGen.a interpreter/llvm/src/lib/libLLVMPowerPCAsmParser.a interpreter/llvm/src/lib/libLLVMPowerPCDesc.a interpreter/llvm/src/lib/libLLVMPowerPCAsmPrinter.a interpreter/llvm/src/lib/libLLVMPowerPCDisassembler.a interpreter/llvm/src/lib/libLLVMPowerPCInfo.a interpreter/llvm/src/lib/libLLVMSparcCodeGen.a interpreter/llvm/src/lib/libLLVMSparcAsmParser.a interpreter/llvm/src/lib/libLLVMSparcDesc.a interpreter/llvm/src/lib/libLLVMSparcAsmPrinter.a interpreter/llvm/src/lib/libLLVMSparcDisassembler.a interpreter/llvm/src/lib/libLLVMSparcInfo.a interpreter/llvm/src/lib/libLLVMSystemZCodeGen.a interpreter/llvm/src/lib/libLLVMSystemZAsmParser.a interpreter/llvm/src/lib/libLLVMSystemZDisassembler.a interpreter/llvm/src/lib/libLLVMSystemZDesc.a interpreter/llvm/src/lib/libLLVMSystemZAsmPrinter.a interpreter/llvm/src/lib/libLLVMSystemZInfo.a interpreter/llvm/src/lib/libLLVMX86CodeGen.a interpreter/llvm/src/lib/libLLVMGlobalISel.a interpreter/llvm/src/lib/libLLVMX86AsmParser.a interpreter/llvm/src/lib/libLLVMX86Desc.a interpreter/llvm/src/lib/libLLVMX86AsmPrinter.a interpreter/llvm/src/lib/libLLVMX86Disassembler.a interpreter/llvm/src/lib/libLLVMX86Info.a interpreter/llvm/src/lib/libLLVMX86Utils.a interpreter/llvm/src/lib/libLLVMXCoreCodeGen.a interpreter/llvm/src/lib/libLLVMAsmPrinter.a interpreter/llvm/src/lib/libLLVMDebugInfoCodeView.a interpreter/llvm/src/lib/libLLVMDebugInfoMSF.a interpreter/llvm/src/lib/libLLVMSelectionDAG.a interpreter/llvm/src/lib/libLLVMCodeGen.a interpreter/llvm/src/lib/libLLVMScalarOpts.a interpreter/llvm/src/lib/libLLVMInstCombine.a interpreter/llvm/src/lib/libLLVMTarget.a interpreter/llvm/src/lib/libLLVMTransformUtils.a interpreter/llvm/src/lib/libLLVMBitWriter.a interpreter/llvm/src/lib/libLLVMAnalysis.a interpreter/llvm/src/lib/libLLVMProfileData.a interpreter/llvm/src/lib/libLLVMObject.a interpreter/llvm/src/lib/libLLVMBitReader.a interpreter/llvm/src/lib/libLLVMXCoreDesc.a interpreter/llvm/src/lib/libLLVMXCoreAsmPrinter.a interpreter/llvm/src/lib/libLLVMXCoreDisassembler.a interpreter/llvm/src/lib/libLLVMXCoreInfo.a interpreter/llvm/src/lib/libLLVMMCDisassembler.a interpreter/llvm/src/lib/libclingUtils.a interpreter/llvm/src/lib/libclangParse.a interpreter/llvm/src/lib/libLLVMMCParser.a interpreter/llvm/src/lib/libclangSema.a interpreter/llvm/src/lib/libclangEdit.a interpreter/llvm/src/lib/libclangAnalysis.a interpreter/llvm/src/lib/libclangAST.a interpreter/llvm/src/lib/libclangLex.a interpreter/llvm/src/lib/libclangBasic.a interpreter/llvm/src/lib/libLLVMMC.a interpreter/llvm/src/lib/libLLVMCore.a interpreter/llvm/src/lib/libLLVMBinaryFormat.a interpreter/llvm/src/lib/libLLVMSupport.a -lrt /usr/lib/libexecinfo.so -ltinfo -lpthread /usr/lib/libz.so -lm interpreter/llvm/src/lib/libLLVMDemangle.a && :
/lib/libc.so.7: undefined reference to `__progname'
c++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

```

But I haven’t figured out why we reference `__progname` from libc, which means we would need to link this into an executable.

---

<div class="post-metadata">

**Author:** ![Roger\_Mason](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/a88e57/32.png) [@Roger\_Mason](https://root-forum.cern.ch/u/Roger_Mason)\
**Post date:** [November 12, 2017, 11:57am UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/11 "2017-11-12T11:57:58Z")

</div>

With your patch applied it now fails like this:

```auto
FAILED: core/base/G__Core.cxx lib/libCore.rootmap
cd /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/core/base && /usr/local/bin/cmake -E env LD_LIBRARY_PATH=/home/rmason/Software/Root-Master/gcc
6-c++14-build/thebuild/lib::/opt/local/lib:/opt/lib/root:/opt/lib:/home/rmason/Software/Scalapack/64-bit-cmake/lib:/opt/local/lib:/opt/lib/root:/opt/lib:/hom
e/rmason/Software/Scalapack/64-bit-cmake/lib:/usr/local/lib/gcc6:/usr/local/lib/gcc6 /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/core/rootcli
ng_stage1/src/rootcling_stage1 -v2 -f G__Core.cxx -s /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/lib/libCore.so -excludePath /home/rmason/Sof
tware/Root-Master/root -excludePath /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild -rml libCore.so -rmf /home/rmason/Software/Root-Master/gcc6-c
++14-build/thebuild/lib/libCore.rootmap -DSYSTEM_TYPE_unix -I/home/rmason/Software/Root-Master/root -I/home/rmason/Software/Root-Master/root/interpreter/clin
g/include -I/home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/include -I/home/rmason/Software/Root-Master/root/core/base/res -I/home/rmason/Softwar
e/Root-Master/root/core/base/../foundation/res -I/usr/include TApplication.h TApplicationImp.h TAtt3D.h TAttAxis.h TAttBBox.h TAttBBox2D.h TAttFill.h TAttLin
e.h TAttMarker.h TAttPad.h TAttText.h TBase64.h TBenchmark.h TBrowser.h TBrowserImp.h TBuffer.h TBuffer3D.h TBuffer3DTypes.h TCanvasImp.h TColor.h TColorGrad
ient.h TContextMenu.h TContextMenuImp.h TControlBarImp.h TDatime.h TDirectory.h TEnv.h TError.h TException.h TExec.h TFileCollection.h TFileInfo.h TFolder.h 
TGuiFactory.h TInetAddress.h TInspectorImp.h TMD5.h TMacro.h TMathBase.h TMemberInspector.h TMessageHandler.h TNamed.h TObjString.h TObject.h TObjectSpy.h TP
Regexp.h TParameter.h TPluginManager.h TPoint.h TProcessID.h TProcessUUID.h TQClass.h TQCommand.h TQConnection.h TQObject.h TROOT.h TRedirectOutputGuard.h TR
ef.h TRefCnt.h TRegexp.h TRemoteObject.h TRootIOCtor.h TStopwatch.h TStorage.h TString.h TStringLong.h TStyle.h TSysEvtHandler.h TSystem.h TSystemDirectory.h
 TSystemFile.h TTask.h TThreadSlots.h TTime.h TTimeStamp.h TTimer.h TUUID.h TUri.h TUrl.h TVersionCheck.h TVirtualAuth.h TVirtualFFT.h TVirtualGL.h TVirtualM
onitoring.h TVirtualMutex.h TVirtualPS.h TVirtualPad.h TVirtualPadEditor.h TVirtualPadPainter.h TVirtualPerfStats.h TVirtualQConnection.h TVirtualRWMutex.h T
VirtualTableInterface.h TVirtualViewer3D.h TVirtualX.h GuiTypes.h MessageTypes.h KeySymbols.h Buttons.h /home/rmason/Software/Root-Master/root/core/base/v7/i
nc/ROOT/TDirectory.hxx /home/rmason/Software/Root-Master/root/core/base/v7/inc/ROOT/TDirectoryEntry.hxx /home/rmason/Software/Root-Master/root/core/base/v7/i
nc/ROOT/TDrawable.hxx /home/rmason/Software/Root-Master/root/core/base/v7/inc/ROOT/TIndexIter.hxx /home/rmason/Software/Root-Master/root/core/base/v7/inc/ROO
T/TLogger.hxx strlcpy.h snprintf.h TArray.h TArrayC.h TArrayD.h TArrayF.h TArrayI.h TArrayL.h TArrayL64.h TArrayS.h TBits.h TBtree.h TClassTable.h TClonesArr
ay.h TCollection.h TCollectionProxyInfo.h TExMap.h THashList.h THashTable.h TIterator.h TList.h TMap.h TObjArray.h TObjectTable.h TOrdCollection.h TRefArray.
h TRefTable.h TSeqCollection.h TSortedList.h TVirtualCollectionProxy.h ESTLType.h RStringView.h TClassEdit.h ROOT/RArrayView.hxx ROOT/RMakeUnique.hxx ROOT/Ty
peTraits.hxx ROOT/rhysd_array_view.hxx TUnixSystem.h TClingRuntime.h root_std_complex.h TBaseClass.h TClass.h TClassGenerator.h TClassMenuItem.h TClassRef.h 
TClassStreamer.h TDataMember.h TDataType.h TDictAttributeMap.h TDictionary.h TEnum.h TEnumConstant.h TFileMergeInfo.h TFunction.h TFunctionTemplate.h TGeneri
cClassInfo.h TGlobal.h TInterpreter.h TInterpreterValue.h TIsAProxy.h TListOfDataMembers.h TListOfEnums.h TListOfEnumsWithLock.h TListOfFunctionTemplates.h T
ListOfFunctions.h TMemberStreamer.h TMethod.h TMethodArg.h TMethodCall.h TProtoClass.h TRealData.h TSchemaHelper.h TSchemaRule.h TSchemaRuleSet.h TStatusBits
Checker.h TStreamer.h TStreamerElement.h TToggle.h TToggleGroup.h TVirtualIsAProxy.h TVirtualRefProxy.h TVirtualStreamerInfo.h Getline.h /home/rmason/Softwar
e/Root-Master/root/core/base/inc/LinkDef.h
Disabling gnu++: clang has no __float128 support on this target!
In file included from input_line_4:2:
In file included from /usr/local/lib/gcc6/include/c++/stdlib.h:36:
/usr/local/lib/gcc6/include/c++/cstdlib:223:20: error: exception specification in declaration does not match previous declaration
  extern "C" void (_Exit)(int) throw () _GLIBCXX_NORETURN;
                   ^
/usr/include/stdlib.h:151:17: note: previous declaration is here
_Noreturn void _Exit(int);

In file included from input_line_4:2:
In file included from /usr/local/lib/gcc6/include/c++/stdlib.h:36:
/usr/local/lib/gcc6/include/c++/cstdlib:226:11: error: target of using declaration conflicts with declaration already in scope
  using ::_Exit;
          ^
/usr/include/stdlib.h:151:17: note: target of using declaration
_Noreturn void _Exit(int);
                 ^
/usr/local/lib/gcc6/include/c++/cstdlib:223:20: note: conflicting declaration
  extern "C" void (_Exit)(int) throw () _GLIBCXX_NORETURN;
                   ^
/usr/local/lib/gcc6/include/c++/cstdlib:240:29: error: exception specification in declaration does not match previous declaration
  extern "C" long long int (atoll)(const char *) throw ();
                            ^
/usr/include/stdlib.h:137:3: note: previous declaration is here
         atoll(const char *);
         ^
In file included from input_line_4:2:
In file included from /usr/local/lib/gcc6/include/c++/stdlib.h:36:
/usr/local/lib/gcc6/include/c++/cstdlib:242:6: error: exception specification in declaration does not match previous declaration
    (strtoll)(const char * __restrict, char **__ restrict, int) throw ();
     ^
/usr/include/stdlib.h:145:3: note: previous declaration is here
         strtoll(const char * __restrict, char **__ restrict, int);
         ^
In file included from input_line_4:2:
In file included from /usr/local/lib/gcc6/include/c++/stdlib.h:36:
/usr/local/lib/gcc6/include/c++/cstdlib:244:6: error: exception specification in declaration does not match previous declaration
    (strtoull)(const char * __restrict, char **__ restrict, int) throw ();
     ^
/usr/include/stdlib.h:148:3: note: previous declaration is here
         strtoull(const char * __restrict, char **__ restrict, int);

(+ a few more lines with similar errors)

```

I’m not seeing the \_\_progname error, although that one has appeared in previous compilation attempts.

---

<div class="post-metadata">

**Author:** ![teemperor](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/teemperor/32/14099_2.png) [@teemperor](https://root-forum.cern.ch/u/teemperor)\
**Post date:** [November 16, 2017, 8:08am UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/12 "2017-11-16T08:08:47Z")

</div>

I think your problems appear from the mix of FreeBSD libc and the GNU STL. The problem is that the GNU STL expects to get a glibc where these functions have a different signature (glibc is in this regard really broken and clang has usually some hacks to get this somehow working).

What I would recommend is using clang and the libc++ from LLVM, not the stdlibc++ from GNU. This should get you to the state where `__progname` is the problem.

However, I haven’t progressed beyond this error so far. The FreeBSD mailing list doesn’t seem to have any advice on the issue and I don’t have an (easy) solution for fixing this.

I think ROOT could support FreeBSD in the future, but it seems to be a bit more work than just a few lines here and there. The only thing I can think of for getting this to work in the neare future is that you could try getting [ROOT running in a Linux docker](https://root.cern.ch/root-docker-container-alpha-version) that’s hosted by FreeBSD.

---

<div class="post-metadata">

**Author:** ![sbinet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sbinet/32/13166_2.png) [@sbinet](https://root-forum.cern.ch/u/sbinet)\
**Post date:** [November 16, 2017, 8:36am UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/13 "2017-11-16T08:36:19Z")

</div>

depending on what is needed to work from ROOT, one could try (perhaps) [hep/rootio](https://godoc.org/go-hep.org/x/hep/rootio).

here is a (cross-compiled) `root-ls` for FreeBSD:

- [https://cern.ch/binet/go-hep/rootio/root-ls-freebsd-amd64.exe](https://cern.ch/binet/go-hep/rootio/root-ls-freebsd-amd64.exe)

of course, if you don’t trust downloading random binaries from the internet, you can always rebuild from sources:

```auto
$> go get go-hep.org/x/hep/rootio/cmd/root-ls

```

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [November 30, 2017, 8:36am UTC](https://root-forum.cern.ch/t/root-on-freebsd-again/26806/14 "2017-11-30T08:36:21Z")

</div>

Closed on November 30, 2017, 8:36am UTC

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