Hi All, I started on boost today and wrote my first hello world application.
#include
#include <iostream>
using namespace std;
void hello_world()
{
cout << "Hello world, I'm a thread!" << endl;
}
int main(int argc, char* argv[])
{
boost::thread my_thread(&hello_world);
my_thread.join();
return 0;
}
I compiled it using the command. g++ helloworld.cpp
-lboost_thread-gcc41-mt-1_34_1
However, when I try to run it, I keep getting a segmentation fault. I tried
to debug with gdb and this is what I get.
(gdb) run
Starting program: boost_test/a.out
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 46912498370912 (LWP 21199)]
[New Thread 1084229952 (LWP 21202)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1084229952 (LWP 21202)]
0x00002aaaaaab4932 in boost::thread_group::add_thread () from
/usr/local/lib/libboost_thread-gcc41-mt-1_34_1.so.1.34.1
(gdb)
Please let me know as to what I am doing wrong. Any help is appreciated.
Thanks
Nishant