gpt4 book ai didi

c++ - Xcode C++ 错误 "linker command failed with exit code 1"

转载 作者:太空狗 更新时间:2023-10-29 23:04:51 26 4
gpt4 key购买 nike

我是一名编程初学者。

在这里,我使用 C++ 在 Xcode 中编写了一个简单的“两数之和”程序。

//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;

}

据我所知,我的语法是准确的,但是,当我尝试构建程序时,我得到了这个错误代码:

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

我无法通过阅读其他问答来解决这个问题。

任何建议的解决方案?将不胜感激!!

最佳答案

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

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

关于c++ - Xcode C++ 错误 "linker command failed with exit code 1",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21337028/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com