Я пытаюсь скомпилировать свой простой буст-код:
#include <iostream>
#include <boost/thread.hpp>
void workerFunc(const char* msg, float delay_ms)
{
boost::posix_time::milliseconds workTime(delay_ms);
std::cout << "Worker: running, message = " << msg << std::endl;
// Pretend to do something useful...
boost::this_thread::sleep(workTime);
std::cout << "Worker: finished" << std::endl;
}
int main(int argc, char* argv[])
{
std::cout << "main: startup" << std::endl;
boost::thread workerThread(workerFunc, "Hello, Boost!", 2.5e3);
std::cout << "main: waiting for thread" << std::endl;
workerThread.join();
std::cout << "main: done" << std::endl;
return 0;
}
с использованием g ++ с этой командой
g++ main.cpp -o main
но я получаю ошибку вроде этого:
main.cpp: In function `void workerFunc(const char*, float)':
main.cpp:7: error: `boost::posix_time' has not been declared
main.cpp:7: error: `milliseconds' was not declared in this scope
main.cpp:7: error: expected `;' before "workTime"
main.cpp:12: error: `boost::this_thread' has not been declared
main.cpp:12: error: `workTime' was not declared in this scope
main.cpp: In function `int main(int, char**)':
main.cpp:21: error: no matching function for call to `boost::thread::thread(void (&)(const char*, float), const char[14], double)'
/usr/include/boost/thread/thread.hpp:35: note: candidates are: boost::thread::thread(const boost::thread&)
/usr/include/boost/thread/thread.hpp:38: note: boost::thread::thread(const boost::function0<void, std::allocator<boost::function_base> >&)
/usr/include/boost/thread/thread.hpp:37: note: boost::thread::thread()
Что не так и как мне его скомпилировать ...?