[英]Xcode C++ Error “linker command failed with exit code 1”
我是一名編程學生。
在這里,我使用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查看調用)”
我一直無法通過閱讀其他Q和A來解決這個問題。
任何建議的解決方 這將不勝感激!!
您的錯誤不完整。 您需要使用-v
來查看調用(如建議的那樣),或者需要檢查日志以獲取更多詳細信息,因為錯誤“ 鏈接器命令失敗,退出代碼為1 ”后面通常會出現更詳細的錯誤。
因此,要查找更多詳細信息,請在Xcode中單擊Buildtime下的錯誤,然后選擇Reveal in log 。 這應該給你額外的提示。 沒有任何特定錯誤,很難知道問題是什么。
如果源代碼中有其他錯誤,通常會顯示此錯誤。 如果您直接復制粘貼代碼,則在main中的左括號前面有一個x
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.