链接器命令失败,退出代码为 1 在 Xcode

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11704448/
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 01:03:14  来源:igfitidea点击:

Linker command failed with exit code 1 In Xcode

cxcodelinker-errors

提问by saleh

I'm writing C program in Xcode, and I got this problem:

我正在 Xcode 中编写 C 程序,但遇到了这个问题:

ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any idea to solve it?

任何想法来解决它?

Note: I've just update my OS to Mountain Lion yesterday.

注意:我昨天刚刚将我的操作系统更新到 Mountain Lion。

回答by Nikolai Ruhe

A common error is to definea symbol in a header when you wanted to declareit:

一个常见的错误是当你想声明它时在头文件中定义一个符号:

When you for instance declare a global variable and forget the externor you define an inline function and forget the inline. In these cases the compiler emits the symbol in each compile unit that includes this header and you end up with multiple definitions of a symbol.

例如,当您声明一个全局变量而忘记了extern或者您定义了一个内联函数而忘记了inline. 在这些情况下,编译器在包含此头文件的每个编译单元中发出符号,最终会得到一个符号的多个定义。

Anyway you should just look for the symbol in question.

无论如何,您应该只查找有问题的符号。