Mac OS X Sierra:未定义的体系结构符号 x86_64

Mac OS X Sierra : Undefined symbols for architecture x86_64

我正在尝试在 Mac OS X Sierra 中构建基于 Linphone 的 C 源文件,但出现以下错误。

这是 C 源文件的 link。 http://www.linphone.org/docs/liblinphone/group__basic__call__tutorials.html

已编辑:

我正在尝试用这个命令编译源代码

clang -o tt tt.c -I/Users/softdev/Downloads/linphone-sdk-3.11.1-mac/include/

错误:

Undefined symbols for architecture x86_64
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我尝试更改目标 cpu 但没有成功。

我的系统有 XCode8。如有任何帮助,我们将不胜感激。

已编辑:完成输出

Undefined symbols for architecture x86_64:
  "_linphone_call_get_state", referenced from:
      _main in tt-ca2045.o
  "_linphone_call_ref", referenced from:
      _main in tt-ca2045.o
  "_linphone_call_unref", referenced from:
      _main in tt-ca2045.o
  "_linphone_core_destroy", referenced from:
      _main in tt-ca2045.o
  "_linphone_core_invite", referenced from:
      _main in tt-ca2045.o
  "_linphone_core_iterate", referenced from:
      _main in tt-ca2045.o
  "_linphone_core_new", referenced from:
      _main in tt-ca2045.o
  "_linphone_core_terminate_call", referenced from:
      _main in tt-ca2045.o
  "_ms_usleep", referenced from:
      _main in tt-ca2045.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我得到了使用这个编译的示例代码:

clang -o hello hello.c -Ilinphone-sdk-3/include -Llinphone-sdk-3/lib -llinphone -lmediastreamer_base

Clang 的 -I 参数指向 header (.h) 文件所在的位置

至于我的补充,-L 指定 路径 让 clang 到达 lib 文件所在的位置。在您的情况下,它可能位于 -L/Users/softdev/Downloads/linphone-sdk-3.11.1-mac/lib

然后 -l 指定要包含的动态库(去掉 lib 前缀和 dylib 后缀)。

最后,您需要在您指向的示例代码中添加一个缺失的行。添加:

#include <unistd.h>

signal.h

之后