- 论坛徽章:
- 0
|
#include <iostream>;
using namespace std;
int main()
{
return 0;
}
就这么简单,文件名是test1.cpp,用make test1可以生成可执行程序.但是先gcc -c test1.cpp,然后再gcc test1.o -o test1,却总是出现如下错误:
test1.o(.text+0xd): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >; const& ':
: undefined reference to `std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >;::size() const'
test1.o(.text+0x60): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >; const& ':
: undefined reference to `std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >;: perator[](unsigned int) const'
test1.o(.text+0x9d): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >; const& ':
: undefined reference to `std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >;: perator[](unsigned int) const'
test1.o(.text+0xc : In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >; const& ':
: undefined reference to `std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >;: perator[](unsigned int) const'
test1.o(.text+0x13e): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
test1.o(.text+0x16d): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
test1.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
这是什么原因呢? |
|