对于使用块的 clang 程序,您需要链接哪些库

2024-02-19

我发现(如下)在编译使用块的代码时需要使用 -fblocks 。

我需要链接哪个库才能让链接器解析 _NSConcreteStackBlock? (在 Ubuntu 9.10 AMD64 上。)

chris@chris-desktop:~$ clang ctest.c 

ctest.c:3:25: error: blocks support disabled - compile with -fblocks or pick a
      deployment target that supports them
void call_a_block(void (^blockptr)(int)) {
                        ^
ctest.c:11:19: error: blocks support disabled - compile with -fblocks or pick a
      deployment target that supports them
    call_a_block( ^(int y) { 
                  ^
2 diagnostics generated.
chris@chris-desktop:~$ clang ctest.c -fblocks
/tmp/cc-4sPSeO.o: In function `main':
ctest.c:(.text+0x79): undefined reference to `_NSConcreteStackBlock'
collect2: ld returned 1 exit status
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Clang 尚未提供在没有内置操作系统支持的平台(例如 SnowLeopard)上使用块的简单方法。您可以在此处找到有关 libdispatch 项目的更多信息:http://libdispatch.macosforge.org/ http://libdispatch.macosforge.org/以及这里的 compiler-rt 项目(提供块运行时):http://compiler-rt.llvm.org/ http://compiler-rt.llvm.org/但这还没有为 Clang 最终用户很好地打包。

如果你想深入了解一下,compiler-rt 项目中确实有块运行时,你可以使用它来构建一个提供 NSConcreteStackBlock 的库。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

对于使用块的 clang 程序,您需要链接哪些库 的相关文章

随机推荐