小编gis*_*ard的帖子

如何在osx上使用clang编译共享库

源文件

rsetti::fastidio { /tmp }-> cat foo.c

    #include <stdio.h>
    void ACFunction() {
      printf("ACFunction()\n");
      AGoFunction();
    }
Run Code Online (Sandbox Code Playgroud)

编译共享库

rsetti::fastidio { /tmp }-> clang -shared -o libfoo.so foo.c

    foo.c:4:3: warning: implicit declaration of function 'AGoFunction' is invalid in C99 [-Wimplicit-function-declaration]
      AGoFunction();
      ^
    1 warning generated.
    Undefined symbols for architecture x86_64:
      "_AGoFunction", referenced from:
          _ACFunction in foo-lFDQ4g.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

rsetti::fastidio { /tmp }->
Run Code Online (Sandbox Code Playgroud)

linux + …

c macos gcc shared-libraries clang

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

c ×1

clang ×1

gcc ×1

macos ×1

shared-libraries ×1