Boost logo

Boost Users :

From: Hans Mull (hans72mull_at_[hidden])
Date: 2008-03-07 02:49:01


Nishant Mittal schrieb:
> Hi All, I started on boost today and wrote my first hello world application.
>
>
>
> #include <boost/thread/thread.hpp>
>
> #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
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
At my computer it works (prints "Hello World! I''m a thread!") Ic
recommend you check your compiler settings and reinstall boost (you may
also compile it from source. I did so and it works properly.)#

Best regards, Hans


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net