编译是没有问题的,可以生成.o文件,但连接就出现错误
# H4 f$ T' r+ G
$ G* h3 \1 D! ]- t1 Tg++ -c thread1.cpp -o thread -I /usr/include/boost-1_33_1
) X u8 d7 R2 B
8 k! S0 ^+ k/ Z, M( W; B" w+ sld thread1.o
: i: H8 j; i1 A8 y/ H `. l o& G
出错提示:
复制内容到剪贴板
代码:
ld: warning: cannot find entry symbol _mainCRTStartup; defaulting to 00401000
thread1.o :thread1.cpp: (.text+0xd) : undefined reference to `std::string::size() const'
thread1.o :thread1.cpp: (.text+0x60) : undefined reference to `std::string::perator[](unsigned int) const'
thread1.o :thread1.cpp: ( .text+0x9f) : undefined reference to `std::string::perator[](unsigned int) const'
thread1.o :thread1.cpp: (.text+0xce): undefined reference to `std::string:perator[](unsigned int) const'
thread1.o :thread1.cpp: (.text+0x111): undefined reference to `std::cout'
thread1.o :thread1.cpp: (.text+0x116): 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*)'
thread1.o :thread1.cpp: (.text+0x11e): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
thread1.o :thread1.cpp.text+0x126): undefined reference to `std:stream: perator<<(std:stream& (*)(std:stream&))'
thread1.o :thread1.cpp: (.text+0x159): undefined reference to `_alloca'
thread1.o :thread1.cpp: (.text+0x160): undefined reference to `__gxx_personality_sj0'
thread1.o :thread1.cpp: (.text+0x185): undefined reference to `_Unwind_SjLj_Register'
thread1.o :thread1.cpp: (.text+0x18a): undefined reference to `__main'
thread1.o :thread1.cpp: (.text+0x1c5): undefined reference to `boost::thread::thread(boost::function0<void, std::allocator<boost::function_base> > const&)'
thread1.o :thread1.cpp: (.text+0x1f7): undefined reference to `_Unwind_SjLj_Resume'
thread1.o :thread1.cpp: (.text+0x21b): undefined reference to `boost::thread::join()'
thread1.o :thread1.cpp: (.text+0x22d): undefined reference to `boost::thread::~thread()'
thread1.o :thread1.cpp: (.text+0x25f): undefined reference to `boost::thread::~thread()'
thread1.o :thread1.cpp: (.text+0x277): undefined reference to `_Unwind_SjLj_Resume'
thread1.o :thread1.cpp: (.text+0x282): undefined reference to `_Unwind_SjLj_Unregister'
thread1.o :thread1.cpp: (.text+0x2af): undefined reference to `std::ios_base::Init::Init()'
thread1.o :thread1.cpp: (.text+0x2ca): undefined reference to `std::ios_base::Init::~Init()'
thread1.o :thread1.cpp.text$_ZN5boost6detail8function15functor_managerIPFvvESaINS_13function_baseEEE6manageENS1_11any_pointerENS1_30functor_manager_operation_typeE[__ZN5boost6detail8function15functor_managerIPFvvESaINS_13function_baseEEE6manageENS1_11any_pointerENS1_30functor_manager_operation_typeE]+0x34): undefined reference to `strcmp'
thread1.o :thread1.cpp: (.rdata$_ZTIPFvvE[__ZTIPFvvE]+0x0): undefined reference to `vtable for __cxxabiv1::__pointer_type_info'
thread1.o:thread1.cpp: (.rdata$_ZTIFvvE[__ZTIFvvE]+0x0): undefined reference to `vtable for __cxxabiv1::__function_type_info'