xcode 如何修复命令 /Developer/usr/bin/clang 失败,退出代码为 1?

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

How to fix Command /Developer/usr/bin/clang failed with exit code 1?

cxcodeexitclang

提问by user1031894

Hi there I am new to C programming and have been using Xcode to write my simple CS HW. They have been working fine until a couple weeks ago when I keep getting this error code below. I went ahead and try to run some old programs that I know for sure works but still get this error. I looked everywhere and can't find the solution. If you have a solution please help. Although I would love a specific answer, I am very new to this and would hope you take that into consideration when explaining. Thank you very much.

嗨,我是 C 编程的新手,一直在使用 Xcode 编写我的简单 CS 硬件。他们一直工作正常,直到几周前我不断收到下面的错误代码。我继续尝试运行一些我知道肯定有效但仍然出现此错误的旧程序。我到处找,找不到解决办法。如果您有解决方案,请提供帮助。虽然我希望得到一个具体的答案,但我对此很陌生,希望您在解释时考虑到这一点。非常感谢。

Ld /Users/------/Library/Developer/Xcode/DerivedData/Test-gehcspqxloqgaahbdyjslulobzys/Build/Products/Debug/Test normal x86_64
    cd /Users/------/Desktop/Test
    setenv MACOSX_DEPLOYMENT_TARGET 10.7
    /Developer/usr/bin/clang -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -L/Users/------/Library/Developer/Xcode/DerivedData/Test-gehcspqxloqgaahbdyjslulobzys/Build/Products/Debug -F/Users/------/Library/Developer/Xcode/DerivedData/Test-gehcspqxloqgaahbdyjslulobzys/Build/Products/Debug -filelist /Users/------/Library/Developer/Xcode/DerivedData/Test-gehcspqxloqgaahbdyjslulobzys/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/x86_64/Test.LinkFileList -mmacosx-version-min=10.7 -o /Users/------/Library/Developer/Xcode/DerivedData/Test-gehcspqxloqgaahbdyjslulobzys/Build/Products/Debug/Test

ld: duplicate symbol _main in /Users/------/Library/Developer/Xcode/DerivedData/Test-gehcspqxloqgaahbdyjslulobzys/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/x86_64/HW4.o and /Users/------/Library/Developer/Xcode/DerivedData/Test-gehcspqxloqgaahbdyjslulobzys/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/x86_64/HW3.o for architecture x86_64
Command /Developer/usr/bin/clang failed with exit code 1

what is this error code?

这个错误代码是什么?

Command /Developer/usr/bin/clang failed with exit code 1

回答by NickLH

ld: duplicate symbol _main

ld:重复符号_main

This means that you have two main functions inside the same project. Considering the names of your .o files (HW4.o and HW3.o) I am guessing that you are trying to compile two projects at the same time and are somehow linking them, thus having two main functions.

这意味着您在同一个项目中有两个主要功能。考虑到您的 .o 文件(HW4.o 和 HW3.o)的名称,我猜测您正在尝试同时编译两个项目并以某种方式链接它们,因此具有两个主要功能。