开发者

How do I link against Intel TBB on Mac OS X with GCC?

开发者 https://www.devze.com 2022-12-26 16:24 出处:网络
I can\'t for the life of me figure out how to compile and link against the Intel TBB library on my Mac. I\'ve run the commercial installer and the tbbvars.sh script but I can\'t figure this out. I hav

I can't for the life of me figure out how to compile and link against the Intel TBB library on my Mac. I've run the commercial installer and the tbbvars.sh script but I can't figure this out. I have a feeling it is something really obvious and it's just been a bit too long si开发者_运维百科nce I've done this kind of thing.

tbb_test.cpp

#include <tbb/concurrent_queue.h>

int main() {
    tbb::concurrent_queue<int> q;
}

g++ tbb_test.cpp -I /Library/Frameworks/TBB.framework/Headers -ltbb

...can't find the symbols.

Cheers!

UPDATE:

g++ tbb_test.cpp -I /Library/Frameworks/TBB.framework/Headers -L /Library/Frameworks/TBB.framework/Libraries/libtbb.dylib

works!


Since you are using a framework instead of a traditional library, you need to use -framework, like:

g++ tbb_test.cpp -o tbb_test -framework TBB

Instead of:

g++ tbb_test.cpp -o tbb_test -I /Library/Frameworks/TBB.framework/Headers -ltbb


According to the TBB Getting Started Guide (page 3 of the current version), there are some scripts in the $INSTALL/bin directory that will set the right environment variables if you run source on them (e.g. source bin/tbbvars.sh). Once you do that, you no longer need to specify -I and -L in your g++ command line, which is tedious, error prone, and most of all ugly. But you still have to use -ltbb :'(. This advice also applies to those using other Unix-like OSs, such as Linux.

0

精彩评论

暂无评论...
验证码 换一张
取 消