#include <boost/thread/thread.hpp>
#include <iostream>
void hello()
{
std::cout <<
"Hello world, I'm a thread!"
<< std::endl;
}
int main(int argc, char* argv[])
{
boost::thread thrd(&hello);
thrd.join();
return 0;
}
Tôi chạy thử để biên dịch chương trình này, và nhận được các lỗi này:Boost chủ đề lỗi: undefined tham khảo
/usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to
`boost::thread_resource_error::thread_resource_error()'
/usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to
`boost::thread_resource_error::~thread_resource_error()'
/usr/include/boost/thread/pthread/mutex.hpp:40: undefined reference to
`typeinfo for boost::thread_resource_error'
./src/thread.o: In function `condition_variable':
/usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33:
undefined reference to `boost::thread_resource_error::thread_resource_error()'
/usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33:
undefined reference to `boost::thread_resource_error::~thread_resource_error()'
/usr/include/boost/thread/pthread/condition_variable_fwd.hpp:33: \
undefined reference to `typeinfo for boost::thread_resource_error'
./src/thread.o: In function `thread_data_base':
/usr/include/boost/thread/pthread/thread_data.hpp:54:
undefined reference to `vtable for boost::detail::thread_data_base'
./src/thread.o: In function `thread<void (*)()>':
/usr/include/boost/thread/detail/thread.hpp:188:
undefined reference to `boost::thread::start_thread()'
./src/thread.o: In function `~thread_data':
/usr/include/boost/thread/detail/thread.hpp:40:
undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/usr/include/boost/thread/detail/thread.hpp:40: undefined reference to
`boost::detail::thread_data_base::~thread_data_base()'
Bất kỳ một thể cho tôi biết lý do tại sao tôi đang nhận được lỗi này?
Âm thanh như tăng không được cài đặt đúng trên hệ thống của bạn – riwalk
nhưng tôi '#include #include #include using namespace std; sử dụng tăng không gian tên; int main() { \t chuỗi str1; \t cin >> str1; \t // chuỗi str1 ("hello world!"); \t to_upper (str1); \t cout << str1; trả lại 0; } 'chạy hoàn hảo –
lal
tôi tìm thấy nó tôi cần phải cài đặt gói libboost-thread trong ubuntu – lal