/tmp/cc6u7EbK.o (.text+0x44): ...undefined reference to foo::bar

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.

* the reference file is a file within /tmp/ with a random name (e.g. /tmp/cc6n7Ebk.o).
* undefined reference to a class or function.


$ g++ boost_example.cpp -o run
/tmp/cc6u7EbK.o: In function `__static_initialization_and_destruction_0(int, int)':
boost_example.cpp:(.text+0x38): undefined reference to `boost::system::get_system_category()'
boost_example.cpp:(.text+0x44): undefined reference to `boost::system::get_generic_category()'
boost_example.cpp:(.text+0x50): undefined reference to `boost::system::get_generic_category()'
boost_example.cpp:(.text+0x5c): undefined reference to `boost::system::get_generic_category()'
boost_example.cpp:(.text+0x68): undefined reference to `boost::system::get_system_category()'
collect2: ld returned 1 exit status

The problem is caused by forgetting to link to the proper library at compile time.
The above example should have link to the library boost_filesystem-mt thus:
g++ boost_example.cpp -o run -lboost_filesystem-mt