哪些库需要使用块链接到一个铛程序 [英] Which libraries do you need to link against for a clang program using blocks
问题描述
我发现(下面),我需要在编译使用块的代码时使用-fblocks。
I've discovered (below) that I need to use -fblocks when compiling code which uses blocks.
我需要链接的库,链接器解析_NSConcreteStackBlock? (在Ubuntu 9.10 AMD64上)
What library do I need to link against to let the linker resolve _NSConcreteStackBlock? (On 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/
和编译器-r项目(提供块运行时):
http://compiler-rt.llvm.org/
,但这对于Clang最终用户还不是很好的打包。
Clang doesn't yet provide an easy way to use blocks on platforms that don't have built-in operating system support (e.g., SnowLeopard). You can find some more information on the libdispatch project here: http://libdispatch.macosforge.org/ and on the compiler-rt project (which provides the blocks runtime) here: http://compiler-rt.llvm.org/ but this is not yet well packaged for Clang end users.
如果你想要挖一点,编译器rt项目确实有它的块运行时,你可以使用它来构建一个库,将提供NSConcreteStackBlock。
If you want to dig in a bit, the compiler-rt project does have the blocks runtime in it, and you can use that to build a library which will provide the NSConcreteStackBlock.
这篇关于哪些库需要使用块链接到一个铛程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!