代码之家  ›  专栏  ›  技术社区  ›  fadedbee

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

  •  5
  • fadedbee  · 技术社区  · 15 年前

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

    我需要针对哪个库进行链接以让链接器解决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)
    
    3 回复  |  直到 9 年前
        3
  •  0
  •   Lucas Holt    9 年前

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

    clang ctest.c -fblocks -lBlocksRuntime