- 论坛徽章:
- 0
|
在 linux下编译tt.C,
tt.C的内容如下:
#include <iostream>;
using namespace std;
int main(){
cout << "line:"<<__LINE__<< "\n";
cout << "file:"<<__FILE__<< "\n";
cout << "date:"<<__DATE__<< "\n";
#ifndef __cplusplus
cout << "time:"<<__TIME__<< "\n";
#endif
return 0;
}
编译的 命令是cc text.C
结果如下:
/tmp/ccreYPMX.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'
/tmp/ccreYPMX.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'
/tmp/ccreYPMX.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'
/tmp/ccreYPMX.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'
/tmp/ccreYPMX.o(.text+0x12e): In function `main':
: undefined reference to `std::cout'
/tmp/ccreYPMX.o(.text+0x133): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char>; >;& std: perator<< <std::char_traits<char>; >;(std::basic_ostream<char, std::char_traits<char>; >;&, char const*)'
/tmp/ccreYPMX.o(.text+0x13c): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char>; >;: perator<<(int)'
/tmp/ccreYPMX.o(.text+0x145): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char>; >;& std: perator<< <std::char_traits<char>; >;(std::basic_ostream<char, std::char_traits<char>; >;&, char const*)'
/tmp/ccreYPMX.o(.text+0x165): In function `main':
: undefined reference to `std::cout'
/tmp/ccreYPMX.o(.text+0x16a): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char>; >;& std: perator<< <std::char_traits<char>; >;(std::basic_ostream<char, std::char_traits<char>; >;&, char const*)'
/tmp/ccreYPMX.o(.text+0x173): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char>; >;& std: perator<< <std::char_traits<char>; >;(std::basic_ostream<char, std::char_traits<char>; >;&, char const*)'
/tmp/ccreYPMX.o(.text+0x17c): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char>; >;& std: perator<< <std::char_traits<char>; >;(std::basic_ostream<char, std::char_traits<char>; >;&, char const*)'
/tmp/ccreYPMX.o(.text+0x19c): In function `main':
: undefined reference to `std::cout'
/tmp/ccreYPMX.o(.text+0x1a1): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char>; >;& std: perator<< <std::char_traits<char>; >;(std::basic_ostream<char, std::char_traits<char>; >;&, char const*)'
/tmp/ccreYPMX.o(.text+0x1aa): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char>; >;& std::operator<< <std::char_traits<char>; >;(std::basic_ostream<char, std::char_traits<char>; >;&, char const*)'
/tmp/ccreYPMX.o(.text+0x1b3): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char>; >;& std::operator<< <std::char_traits<char>; >;(std::basic_ostream<char, std::char_traits<char>; >;&, char const*)'
/tmp/ccreYPMX.o(.text+0x1e0): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
/tmp/ccreYPMX.o(.text+0x20f): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccreYPMX.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
说我什么这么多的函数没用,不加using,又说我的cout未定义。
郁闷 |
|