我想編譯一個C++程序,它在Xcode中工作正常,但在終端中給出錯誤。Mac OS X給出的架構x86_64找不到ld:symbol(s)
的main.cpp
int main(int argc, const char * argv[])
{
Example* example =new Example();
example->show();
}
example.h文件
class Example {
public:
void show();
};
example.cpp
void Example::show() {
std::cout<<"Hello World"<<std::endl;
}
的錯誤,我得到
"Example::show()", referenced from:
_main in cckpIa3V.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
我使用G ++
g++ -o test main.cpp
「但在終端出現錯誤」究竟是什麼意思?你是否試圖在命令行上編譯?如果是這樣,請顯示您的命令行! – trojanfoe 2013-03-05 15:07:34
g ++ -o test main.cpp – Kathick 2013-03-05 15:08:55