Boost Users :
Subject: Re: [Boost-users] boost mutex linking problem (undefined reference to mutex) on gcc and boost 1.34
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2008-11-02 06:44:13
On Sat, Nov 1, 2008 at 11:53 AM, professor rumsdiegeige <
> I'm trying to compile a simple program with a boost::mutex in it. It
> compiles fine, but the linking process shipwrecks:
> "undefined reference to `boost::mutex::~mutex()' "
> I'm using ubuntu 8.04 and boost 1.34. When I try to compile the same
> program on MSVS 2005, it compiles, links and works fine
> Do I need to link explicitly to certain library? On the web I found sth.
> about needing to link against posix4 - but that didn't help.
> Any help appreciated!
you need to link against the boost-threads library. Under MSVC boost uses
auto-linking feature and specifies the libs to be linked via a pragma
directive in a header file of the lib. AFAIK GCC does not support this, so
you need to do it explicitly yourself using the -l linker option.
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