Getting Thread Building Blocks (Intel TBB) running on Linux with gcc
Asked Answered
S

2

5

I'm trying to build some tests for threading building blocks. Unfortunately, I'm unable to configure the tbb library. The linker cannot find the library tbb. I've tried running the scripts in bin directory which has not helped. I've even tried moving the library files to /usr/local/lib/ which was again a flop. Any suggestions would be helpful.

Satterlee answered 7/4, 2011 at 19:20 Comment(0)
M
6
  • Determine where you have put the tbb/lib folder, and then add the path to the library to the LD_LIBRARY_PATH environment variable, either manually or in ~/.bashrc.

    Example:

    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/tbb/lib/intel64/gcc4.4
    
  • Then, compile the program using g++

    • with the -I flag pointing at the header files directory
    • the -L flag pointing at the library directory
    • and -ltbb

    Example:

    g++ program.cpp -o program -I/usr/local/lib/tbb/include -L/usr/local/lib/tbb/lib/intel64/gcc4.4 -ltbb
    
Mutineer answered 12/3, 2014 at 4:38 Comment(0)
Z
0

After building/installing and making sure that /etc/ld.so.conf has the proper listing for the directories pointing to where your libraries are stored, you might want to try and run sudo ldconfig on the command-line and see if that changes anything.

Hope this helps,

Jason

Zoosperm answered 7/4, 2011 at 19:35 Comment(17)
Well that seemed to work until the linker said "error while loading shared libraries : libtbb.so.2 : cannot open shared object file : no such file or directory" Make any sense ?Satterlee
That error typically means 'libtbb.so.2` a symbolic link, and ld is not able to follow the symbolic link to the directory it's actually contained in. You may need to manually update the symbolic link so it properly points to the correct library, and/or make sure the correct library file is in a directory that ld can find it in after following the symbolic link (per /etc/ld.so.conf).Zoosperm
Also you might be able to find some answers at this link if none of the above helps: tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.htmlZoosperm
@Satterlee were you able to get it running?Zoosperm
NOP. I tried all of the above and am not getting it to run . I,ve the library in ldconfig cache but still ltbb not foundSatterlee
One question : How does the linker know which library (.so file to use ) when i pass it the value tbb .Satterlee
BTW, I'm assuming you're on some flavor of Linux? As for the linker, when you compile with gcc -ltbb ..., it will look inside the directories for libtbb.so, and since that file will probably be a symbolic link, it will point ld to the proper version (in this case to libtbb.so.2). So I would again make sure that all the symbolic links are pointing in the right spot. In a worst-case scenario, get rid of the symbolic links, rename libtbb.so.2 to libtbb.so and re-run sudo ldconfig. You could also try to manually include the entire path to libtbb.so.2 when compiling with gcc.Zoosperm
Well I'm using centOS . and my libtbb.so contains just 'INPUT(libtbb.so.2)' . Is that a symbolic link ?Satterlee
Yes, your libtbb.so is just a symbolic link to libtbb.so.2. So you can try deleting libtbb.so, renaming libtbb.so.2 to libtbb.so, and see if that helps. Otherwise you can actually try putting in the entire path when invoking gcc, i.e., gcc -l/usr/lib/.../libtbb.so.2. I'm assuming you compiled this library yourself, and it's for the correct processor/platform, right?Zoosperm
Actaully id id both . first i compiled from source and then i tried installing from an rpmSatterlee
So I guess removing the symbolic links, renaming the libtbb.so.2 file to libtbb.so and then running sudo ldconfig again doesn't work?Zoosperm
None of them works . it's present in ldconfig cache but still ld says can't find ltbbSatterlee
Are you trying to statically or dynamically link the library? Also are the permissions on the file in a state that might block you from having access to it (without being the super-user)? I'm sorry if it seems like I'm stabbing in the dark at this point, unfortunately I'm getting to the point where I'm not sure what the problem is, because typically when I've had this issue in the past, these steps have resolved the issue.Zoosperm
statically or dynamically - i don't know . Won't ld sort that out by itself ? and i tried running ld as super user . it's all same resultsSatterlee
What version of gcc and ld are you using? If you' haven't upgraded them lately, and you're not on the latest version, that might be worth a try ...Zoosperm
well i've dropped it on cent OS for now . I'm getting it alright on centos . Got a binary package for archlinux that works perfect .Satterlee
Cool, glad to hear you got it working. Sorry I couldn't offer you some better advice.Zoosperm

© 2022 - 2024 — McMap. All rights reserved.