Which libraries do you need to link against for a clang program using blocks

不想你离开。 提交于 2019-12-03 17:00:31

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.

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.

Use the instructions at http://mackyle.github.com/blocksruntime/ to build a libBlocksRuntime.a library that you can link with.

Install the libBlocksRuntime on Ubuntu with:

sudo apt-get install llvm
sudo apt-get install clang
sudo apt-get install libblocksruntime-dev

To compile, include the library and -fblocks:

clang ctest.c -fblocks -lBlocksRuntime

This is also available on other operating systems. FreeBSD and MidnightBSD both include clang and libBlocksRuntime.so

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!