我想在C++中做一些非常简单的事情,但是我找不到任何有关如何解决这个问题的信息。即使我刚才说的书“只编译和运行程序”。体系结构x86_64的未定义符号:我应该使用哪种体系结构?
TEST.CPP
#include <iostream>
using namespace std;
int main()
{
cout << "Never fear, C++ is here!";
return 0;
}
编译器说:
Undefined symbols for architecture x86_64:
"std::cout", referenced from:
_main in ccVfJHGs.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
_main in ccVfJHGs.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccVfJHGs.o
"std::ios_base::Init::~Init()", referenced from:
___tcf_0 in ccVfJHGs.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
我试着像-arch i386
和-m32
标志编译但它总是说,这是错误的架构。我应该使用哪一个?
我在Mac上这样做,但不使用XCode,只是gcc。
您使用哪个gcc? MacPorts的?的XCode?看起来你的道路是混乱的。 – FFox