|
Boost Users : |
From: Justin Findlay (findlay_at_[hidden])
Date: 2004-10-22 18:45:49
On Fri, Oct 22, 2004 at 01:44:44PM -0700, Sara Collins wrote:
> This might be very easy for a lot of you but I've been
> banging my head on the wall.
>
> I just installed the boost library and tried to run a
> simple test file using boost.thread.mutex
>
> #include <boost/thread/mutex.hpp>
>
> int main()
> {
> boost::mutex m;
> }
>
> I got this compilation error message:
> undefined reference to
> `boost::mutex::mutex[in-charge]()'
>
> I guess I have to link in the libboost_thread.dll file
Yes, you do, otherwise the linker can't find the definition of your class that
has already been compiled and lives elsewhere. It's fairly simple on a Unix-like
system. If you're on that system that uses the .dll naming convention, then I
can't help you much.
Now to build your program, you need to know the where your library is, and
what it is named. On my machine it is in ~/local/lib and is called
libboost_thread-gcc-mt.so, so for me to compile your program I would do:
$ g++ -L~/local/lib -lboost_thread-gcc-mt program.cpp -o program
Notice that when using the `-l' flag, you drop the `lib' prefix and `.so'
suffix.
> somehow but I don't seem to find a solution how.
> Perharps I've been searching the wrong places.
This HOWTO has been useful to me.
http://www.tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
> Please help the newbie. Thanks a lot in advance.
No problem.
Justin
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