xcode吧 关注:8,402贴子:34,049
  • 3回复贴,共1

新手求助,xcode编译c++出错,build failed。

只看楼主收藏回复

#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)


IP属地:重庆1楼2014-11-30 15:57回复
    应该是没啥问题的 我用我的Xcode运行得了你的程序
    可能是环境出了问题


    2楼2015-02-19 14:25
    回复
      解决了吗?我也有同样的问题


      IP属地:浙江3楼2023-06-03 20:13
      收起回复