Undefined Reference (newbie)

I think my problem is a simple linking problem. I have looked through the
archives and tried a few things to no avail.
I am trying to compile the simple thread example from the boost site (see
end of message).
I am using 64 bit Redhat linux on a dual core opteron box.
g++ -v
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
I believe the boost libraries come pre-installed on linux, but just in case
I followed all the directions online and installed the libraries (I just
used whatever defaults the installed runs).
I compile the program below with:
g++ test.cpp (I renamed the sample program test)
and get these errors:
/tmp/cctHP3Df.o(.text+0x169): In function `main':
: undefined reference to `boost::thread::thread(boost::function0

On Mon, Jan 01, 2007 at 06:57:23PM -0600, mailbox44@swissmail.org wrote:
I think my problem is a simple linking problem. I have looked through the archives and tried a few things to no avail.
Try linking with -lboost_threads AND -lpthread I can force the same errors you get, and then fix it by doing this:
g++ test.cpp -I/usr/local/include -L/usr/local/lib -lboost_thread -lpthread
Of course, the -I and -L are specific to my boost location. I bet this will do in your situation:
g++ test.cpp -lboost_thread -lpthread
I had no problem on my Linxu box, but FreeBSD was complaining about the same issues and that fixed it for me with the code you sent. Good luck, Pete
participants (2)
-
mailbox44@swissmail.org
-
pete@mu.org