1
我是C++的新手,試圖製作一個簡單的程序。編譯錯誤:鏈接器命令失敗,退出代碼1
但我得到這個錯誤:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[Finished in 0.4s with exit code 1]
從這個代碼:
#include <iostream>
using namespace std;
// Lets add some global variables
int FirstNumber = 0;
int SecondNumber = 0;
int MultiNum = 0;
void MultiNumbers()
{
cout << "Enter the first number: ";
cin >> FirstNumber;
cout << "Enter the second number: ";
cin >> SecondNumber;
// Multiply two numbers...
MultiNum = FirstNumber * SecondNumber;
// Display result
cout << "Displaying result from MultiNumbers(): ";
cout << FirstNumber << " x " << SecondNumber;
cout << " = " << MultiNum << endl;
}
int Main()
{
cout << "This program will help you to multiply two numbers" << endl;
// Now call the function that does all the work
MultiNumbers();
cout << "Displaying from main(): ";
// This line will not compile and work because of the global variables
cout << FirstNumber << " x " << SecondNumber;
cout << " = " << MultiNum << endl;
return 0;
}
我已經試過檢查我的崇高的編譯器,在終端使用g ++ -o測試TEST.CPP
編譯但似乎沒有任何幫助。
我的理解是,我定義MultiNumbers()上面,然後我打電話給它在main()...但我似乎已經錯過了一些東西......
建議?
或者你可以改變的切入點,將用於:http://stackoverflow.com/questions/7494244/how-to-change-the-entry- point-in-gcc – bialpio 2015-01-09 21:51:00
謝謝!那是我再也不會犯的錯誤了...... – Chef1075 2015-01-09 22:28:31