Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/146.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Xcode C++;“错误”;链接器命令失败,退出代码为“1”;_C++_Xcode_Compiler Errors - Fatal编程技术网

C++ Xcode C++;“错误”;链接器命令失败,退出代码为“1”;

C++ Xcode C++;“错误”;链接器命令失败,退出代码为“1”;,c++,xcode,compiler-errors,C++,Xcode,Compiler Errors,我是一名刚开始学习编程的学生 在这里,我用C++编写了一个简单的“两个数的和”程序。 //preprocessor directive #include <stdio.h> //local declarations int main (void) { //declare variables int n1, n2, sum; //input prompts printf("This program finds the sum of two numbers. Enter your

我是一名刚开始学习编程的学生

在这里,我用C++编写了一个简单的“两个数的和”程序。
//preprocessor directive
#include <stdio.h>

//local declarations

int main (void)
{
//declare variables
int n1, n2, sum;

//input prompts
printf("This program finds the sum of two numbers. Enter your first number.\n");
scanf("%d" , &n1);

printf("Enter another number.\n");
scanf("%d" , &n2);

//process
sum=n1+n2;

//output
printf("The sum is %d." , sum);

return 0;

}
//预处理器指令
#包括
//本地声明
内部主(空)
{
//声明变量
int n1,n2,和;
//输入提示
printf(“此程序查找两个数字的总和。输入第一个数字。\n”);
scanf(“%d”&n1);
printf(“输入另一个数字。\n”);
扫描频率(“%d”和“n2”);
//过程
总和=n1+n2;
//输出
printf(“总和为%d.”,总和);
返回0;
}
据我所知,我的语法是准确的,但是,当我尝试构建程序时,我得到以下错误代码:

“Apple Mach-O链接器(Id)错误。链接器命令失败,退出代码为1(使用-v查看调用)”

我无法通过阅读其他Q和A来解决这个问题


有什么解决方案吗?非常感谢

如果源代码中有其他错误,通常会显示此错误。如果您直接复制粘贴代码,则在main中的大括号前会出现一个
x

您的错误不完整。您需要使用
-v
查看调用(如建议的),或者您需要查看日志以了解更多详细信息,因为错误“Linker command failed with exit code 1”后面通常跟着更详细的错误


因此,要查找更多详细信息,请在Xcode中单击Buildtime下的错误,然后选择在日志中显示。这会给你额外的提示。如果没有任何具体的错误,就很难知道问题出在哪里。

这不可能是唯一的错误,必须有更多的错误。好的。谢谢打开大括号之前的“x”只是一个复制错误,而不是我试图编译的代码中的错误。然后一定有其他错误-问题导航器中显示了什么?问题导航器显示“一个问题。”-“Apple Mach-O链接器(Id)错误-链接器命令失败,退出代码为1(使用-v查看调用)”