# Undefined Reference Compiling

**URL:** <https://root-forum.cern.ch/t/undefined-reference-compiling/32175>\
**Category:** Newbie\
**Created:** [January 5, 2019, 10:41pm UTC](https://root-forum.cern.ch/t/undefined-reference-compiling/32175 "2019-01-05T22:41:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![profesors](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/profesors/32/17702_2.png) [@profesors](https://root-forum.cern.ch/u/profesors)\
**Post date:** [January 5, 2019, 10:41pm UTC](https://root-forum.cern.ch/t/undefined-reference-compiling/32175/1 "2019-01-05T22:41:48Z")

</div>

* * *

_ROOT Version:_ 6.17/01  
_Platform:_ Ubuntu 16.04  
_Compiler:_ g++ 7.4.0

* * *

Hi there, yesterday I compiled successfully ROOT in my old laptop. Now I just want to compile a first test with this Makefile:

```auto
ROOT_FLAGS = $(shell root-config --glibs) 
ROOT_INC = $(shell root-config --incdir)
ROOT_CFLAGS = $(shell root-config --cflags)
ROOT_LDFLAGS = $(shell root-config --ldflags)
 
test1: test1.cc
    g++ -o test1 test1.cc -I$(ROOT_INC) $(ROOT_FLAGS) $(ROOT_LDFLAGS) $(ROOT_LDFLAGS)

```

The Makefile produces the command line:

`g++ -o test1 test1.cc -I/usr/local/include -L/usr/local/lib -lGui -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -pthread -lm -ldl -rdynamic -m32 -msse -mfpmath=sse -m32 -msse -mfpmath=sse`

and the result is

```auto
/usr/local/lib/libImt.so: undefined reference to `tbb::interface7::internal::isolate_within_arena(tbb::interface7::internal::delegate_base&, int)'
collect2: error: ld returned 1 exit status

```

but I can execute successfully from command line:

`$ root`

and follow the examples from the tutorial. I think is properly installed in the system, so I can’t see any way to solve the problem and compile my first test. This is the code:

```auto
# include <iostream>
# include "TRandom.h"

using namespace std;

int main(void)
{
  TRandom *rnd = new TRandom(time(0));
  return 0;
}

```

Thank you for your help

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [January 7, 2019, 6:54pm UTC](https://root-forum.cern.ch/t/undefined-reference-compiling/32175/2 "2019-01-07T18:54:22Z")

</div>

Hi,

do you have a $ROOTSYS/lib/libtbb.so" file in your build? If not, against what tbb is your ROOT built (the initial cmake output should say that).  
In addition, supposing you linked against the tbb on your system, could you add “-l tbb” to your ROOT\_LDFLAGS variable?

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![zhangxf](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/5e9695/32.png) [@zhangxf](https://root-forum.cern.ch/u/zhangxf)\
**Post date:** [April 25, 2019, 1:57am UTC](https://root-forum.cern.ch/t/undefined-reference-compiling/32175/3 "2019-04-25T01:57:05Z")

</div>

Dear,

I met the similar problem. I built ROOT with python3 support successfully. But I always got the following message when I imported ROOT in python:

```auto
ImportError: /home/zhangxf/.local/root_v6.16/lib/libImt.so: undefined symbol: _ZN3tbb10interface78internal20isolate_within_arenaERNS1_13delegate_baseEl

```

The output of `ldd -r /home/zhangxf/.local/root_v6.16/lib/libImt.so` was:

```auto
linux-vdso.so.1 => (0x00007ffea010c000)
	libThread.so => /home/zhangxf/.local/root_v6.16/lib/libThread.so (0x00007f5e58228000)
	libtbb.so.2 => /opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/intel64/gcc4.7/libtbb.so.2 (0x00007f5e57fce000)
	libCore.so => /home/zhangxf/.local/root_v6.16/lib/libCore.so (0x00007f5e57959000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5e5773d000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f5e57436000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f5e57134000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f5e56f1e000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f5e56b51000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f5e5868e000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f5e5694d000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f5e56745000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f5e564e3000)
	libpcreposix.so.0 => /lib64/libpcreposix.so.0 (0x00007f5e562e0000)
	liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f5e560ba000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f5e55ea4000)
undefined symbol: _ZN3tbb10interface78internal20isolate_within_arenaERNS1_13delegate_baseEl (/home/zhangxf/.local/root_v6.16/lib/libImt.so)

```

And the output of `c++filt _ZN3tbb10interface78internal20isolate_within_arenaERNS1_13delegate_baseEl` was `tbb::interface7::internal::isolate_within_arena(tbb::interface7::internal::delegate_base&, long)`

The list of `locate libtbb.so` is as follows (`$ROOTSYS=/home/zhangxf/.local/root_v6.16`):

```auto
/home/zhangxf/.local/root_v6.16/lib/libtbb.so
/home/zhangxf/.local/root_v6.16/lib/libtbb.so.2
/home/zhangxf/Downloads/root-6.16.00-build/TBB-prefix/src/TBB/build/linux_intel64_gcc_cc4.8.5_libc2.17_kernel3.10.0_release/libtbb.so
/home/zhangxf/Downloads/root-6.16.00-build/TBB-prefix/src/TBB/build/linux_intel64_gcc_cc4.8.5_libc2.17_kernel3.10.0_release/libtbb.so.2
/home/zhangxf/Downloads/root-6.16.00-build/lib/libtbb.so
/home/zhangxf/Downloads/root-6.16.00-build/lib/libtbb.so.2
/opt/intel/advisor_2017.1.5.527008/lib32/libtbb.so
/opt/intel/advisor_2017.1.5.527008/lib32/libtbb.so.2
/opt/intel/advisor_2017.1.5.527008/lib64/libtbb.so
/opt/intel/advisor_2017.1.5.527008/lib64/libtbb.so.2
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/ia32_lin/gcc4.1/libtbb.so
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/ia32_lin/gcc4.1/libtbb.so.2
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/ia32_lin/gcc4.4/libtbb.so
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/ia32_lin/gcc4.4/libtbb.so.2
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/ia32_lin/gcc4.7/libtbb.so
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/ia32_lin/gcc4.7/libtbb.so.2
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/intel64_lin/gcc4.1/libtbb.so
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/intel64_lin/gcc4.1/libtbb.so.2
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/intel64_lin/gcc4.4/libtbb.so
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/intel64_lin/gcc4.4/libtbb.so.2
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/intel64_lin/gcc4.7/libtbb.so
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/intel64_lin/gcc4.7/libtbb.so.2
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/intel64_lin_mic/libtbb.so
/opt/intel/compilers_and_libraries_2017.8.262/linux/tbb/lib/intel64_lin_mic/libtbb.so.2
/opt/intel/inspector_2017.1.4.527006/lib32/libtbb.so
/opt/intel/inspector_2017.1.4.527006/lib32/libtbb.so.2
/opt/intel/inspector_2017.1.4.527006/lib64/libtbb.so
/opt/intel/inspector_2017.1.4.527006/lib64/libtbb.so.2
/opt/intel/vtune_amplifier_xe_2017.6.0.554757/lib32/libtbb.so
/opt/intel/vtune_amplifier_xe_2017.6.0.554757/lib32/libtbb.so.2
/opt/intel/vtune_amplifier_xe_2017.6.0.554757/lib64/libtbb.so
/opt/intel/vtune_amplifier_xe_2017.6.0.554757/lib64/libtbb.so.2

```

Any help will be greatly appreciated.  
ROOT version: v6.16.00  
Compiler: gcc 4.8.5, g++ 4.8.5  
OS: CentOS 7.6, with kernel 3.10.0-957.5.1.el7.x86\_64

---

<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:** [May 2, 2019, 9:09am UTC](https://root-forum.cern.ch/t/undefined-reference-compiling/32175/4 "2019-05-02T09:09:29Z")

</div>

It’s possible that the libtbb.so picked at runtime is an older version and does not have the symbol shown in the error message. Please post the output of `echo $LD_LIBRARY_PATH` here and what versions of TBB you have installed in the various places.

---

<div class="post-metadata">

**Author:** ![zhangxf](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/5e9695/32.png) [@zhangxf](https://root-forum.cern.ch/u/zhangxf)\
**Post date:** [May 5, 2019, 6:57am UTC](https://root-forum.cern.ch/t/undefined-reference-compiling/32175/5 "2019-05-05T06:57:52Z")

</div>

Thanks for your help. I found that the error message resulted from multiple `libtbb.so` in my `$LD_LIBRARY_PATH`. Since Intel compiler was also installed on the server, there are both `libtbb.so` in `$ROOTSYS/lib` and `$IntelEnv/lib64` in my `$LD_LIBRARY_PATH`.

Could you tell me how to set the path for `libtbb.so` if I want to `import ROOT` in python? Now I have to comment `$IntelEnv` in my `~/.bashrc` or execute `source $ROOTSYS/bin/thisroot.sh` again after the export of `$IntelEnv` if I want to do that. Thank you very much.

---

<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:** [May 6, 2019, 5:59am UTC](https://root-forum.cern.ch/t/undefined-reference-compiling/32175/6 "2019-05-06T05:59:35Z")

</div>

I think that you are already doing what you need, i.e. sourcing ROOT environment after everything else, to avoid unwanted TBB installations to be picked up. For using python, you need to `export PYTHONPATH=$ROOTSYS/lib`, but that should already be done by sourcing `thisroot.sh`. You just need to make sure that the python you use to `import ROOT` is the same that ROOT was compiled against. Cheers,

---

<div class="post-metadata">

**Author:** ![myk](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/myk/32/19210_2.png) [@myk](https://root-forum.cern.ch/u/myk)\
**Post date:** [July 11, 2019, 9:57am UTC](https://root-forum.cern.ch/t/undefined-reference-compiling/32175/7 "2019-07-11T09:57:57Z")

</div>

Hi,

I had the same situation … the libtbb.so installed with the system (/usr/lib64) and the other one by the the ROOT installation ($ROOTSYS/lib).  
As @amadio recommended just sourcing the ROOT environment ($ROOTSYS/bin/thisroot.sh) solved the problem.

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [July 11, 2019, 10:09am UTC](https://root-forum.cern.ch/t/undefined-reference-compiling/32175/8 "2019-07-11T10:09:17Z")

</div>

Closed on July 11, 2019, 10:09am UTC


