如何在带有 GCC 的 Mac OS X 上链接到 Intel TBB?
我一生都无法弄清楚如何在我的 Mac 上编译和链接英特尔 TBB 库。我已经运行了商业安装程序和 tbbvars.sh 脚本,但我无法弄清楚这一点。我有一种感觉,这是一件非常明显的事情,而且自从我做这种事情以来已经有点太久了。
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
...找不到符号。
干杯!
更新:
g++ tbb_test.cpp -I /Library/Frameworks/TBB.framework/Headers -L /Library/Frameworks/TBB.framework/Libraries/libtbb.dylib
有效!
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 since 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您使用的是框架而不是传统的库,因此您需要使用
-framework
,例如:而不是:
Since you are using a framework instead of a traditional library, you need to use
-framework
, like:Instead of:
根据 TBB 入门指南(第当前版本的 3),$INSTALL/bin 目录中有一些脚本,如果您在它们上运行
source
,它们将设置正确的环境变量(例如source bin/tbbvars.sh< /代码>)。完成此操作后,您不再需要在
g++
命令行中指定-I
和-L
,这很乏味且容易出错,最重要的是丑陋。但您仍然必须使用-ltbb
:'(。此建议也适用于使用其他类 Unix 操作系统(例如 Linux)的用户。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 yourg++
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.