新手求助,xcode编译c++出错,build failed。
xcode吧
全部回复
仅看楼主
level 2
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
std::cout << "Enter two numbers:" << std::endl;
int v1=0,v2=0;
std::cin >> v1>>v2;
std::cout << "The sum of "<<v1<<"and "<<v2<<"is" <<v1+v2 <<std::endl;
return 0;
}
运行以后出现错误提示:
duplicate symbol _main in:
/Users/guokairui/Library/Developer/Xcode/DerivedData/cpp-bkvtklkrghfimsghpbbkiqyxgrbl/Build/Intermediates/cpp.build/Debug/cpp.build/Objects-normal/x86_64/cpp0.o
/Users/guokairui/Library/Developer/Xcode/DerivedData/cpp-bkvtklkrghfimsghpbbkiqyxgrbl/Build/Intermediates/cpp.build/Debug/cpp.build/Objects-normal/x86_64/main.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
2014年11月30日 07点11分 1
level 1
应该是没啥问题的 我用我的Xcode运行得了你的程序
可能是环境出了问题
2015年02月19日 06点02分 2
level 2
解决了吗?我也有同样的问题
2023年06月03日 12点06分 3
是不是你的项目里有多个main函数 想在一个项目写多个文件是新建一个new target 或者改下main函数名
2023年08月26日 16点08分
1