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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43070123/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:51:47  来源:igfitidea点击:

Mac OS X Sierra : Undefined symbols for architecture x86_64

cxcodemacosclanglinphone-sdk

提问by SoftDev

I am trying to build a C source file based on Linphone in Mac OS X Sierra but getting the following error.

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

This is the link for the C source file. http://www.linphone.org/docs/liblinphone/group__basic__call__tutorials.html

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

Edited:

编辑:

I am trying to compile the source code with this command

我正在尝试使用此命令编译源代码

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

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

Error:

错误:

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)

体系结构 x86_64
ld 的未定义符号:未找到体系结构 x86_64
clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

I have tried to change the target cpu but didn't work.

我曾尝试更改目标 cpu 但没有奏效。

My system has XCode 8. Any help regarding this will be appreciated.

我的系统有 XCode 8。对此的任何帮助将不胜感激。

Edited: Complete Output

编辑:完成输出

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)

采纳答案by Michael Dautermann

I got the sample code to compile using this:

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

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

Clang's -Iparameter points to the where the header (.h) files live

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

And as for my additions, -Lspecifies the pathfor clang to get to where the lib files live. In your case, it might live in -L/Users/softdev/Downloads/linphone-sdk-3.11.1-mac/lib

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

then -lspecifies which dylibs you want to include (strip off the libprefix and the dylibsuffix).

然后-l指定要包含哪些 dylib(去掉lib前缀和dylib后缀)。

Lastly, you need to add a missing line to the sample code you pointed to. Add:

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

#include <unistd.h>

after signal.h

signal.h