如何在带有 GCC 的 Mac OS X 上链接到 Intel TBB?

发布于 2024-08-29 09:22:49 字数 553 浏览 5 评论 0原文

我一生都无法弄清楚如何在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

↙温凉少女 2024-09-05 09:22:49

由于您使用的是框架而不是传统的库,因此您需要使用 -framework,例如:

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

而不是:

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

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
謸气贵蔟 2024-09-05 09:22:49

根据 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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文