我编写了一个简单的 C++ 程序 test.cpp:
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
cout << s << endl;
return 0;
}
为什么运行gcc test.cpp -o mytest
会给我这些错误,以及更多?
Undefined symbols for architecture x86_64:
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()", referenced from:
_main in cc8rGYVq.o
"std::cin", referenced from:
_main in cc8rGYVq.o