configure error: Could not link against boost_system
On a Debian based 64-bit machine, the following command fixed this error for me:
./configure --with-boost-libdir=/usr/lib/x86_64-linux-gnu
configure: error: Can not link to libboost_atomic
You're missing the package for developing with the boost atomic library. This is a common problem when compiling stuff on Linux, and your fix is to always Google the library (boost atomic) and your linux flavor, to see what to get. For Debian based systems (e.g. Ubuntu),
sudo apt-get install libboost-atomic-dev
should fix this. You may get other such errors - rinse and repeat. If all else fails you can download the source, and compile and install that:
http://www.boost.org/doc/libs/1_53_0/doc/html/atomic.html
You have make instructions there.
Unable to link against boost libraries
After days of debugging, this is the solution I found. It is possible that even a subset of the following instructions is equally enough to go about the problem.
Quick instructions without much detail
Perform the following instructions:
- Install
g++-6
(any version newer than5.2
which supportsc++14
will
most likely work as well, though I have not tested them). - Install boost
1.58
or newer (support for coroutine2). As of the date of
this post, the latest version available in Ubuntu PPA is1.54
. Therefore, you need to manually install boost. If you do not know how, follow this link. - Run your program using
-std=c++14
flag. Also, if you are working with coroutines like me, make sure to link againstlibboost_context
. I have noticed that for coroutines 2,libboost_system
is not needed, perhaps because it is automally pulled in bylibboost_context
, though I'm not sure about the reason. - Make sure that you link against your newly installed boost libraries, and not the old one. See this SO question to see what might go wrong. In my case, I had to delete all the previously installed boost from my machines.
To put these points together, here's the command I used to compile and link my code (let's say I install boost in /usr/local/
):
g++-6 -std=c++14 example.cpp -I/usr/local/include -L/usr/local/lib -lboost_coroutine -lboost_context -lboost_system
More details
Apparently, boost.coroutine
library in boost 1.54
is implemented with the deprecated C-like fcontext-API from boost.context [source]. I have noticed that my machine had problem compiling those parts. Unfortunately, Ubuntu PPA does not offer any newer version than 1.54
at this moment. Boost.coroutine2
is the recommended library to use, which can be found in version 1.59
or newer. Therefore, you need to manually download a suitable version of boost from its website and install it.
After doing so, my code successfully compilied, but not linked:
... undefined reference to `ontop_fcontext' `boost::context::basic_fixedsize_stack<boost::context::stack_traits>::deallocate(boost::context::stack_context&)':
example.cpp:(...): undefined reference to `boost::context::stack_traits::minimum_size()'
example.cpp:(...): undefined reference to `boost::context::stack_traits::is_unbounded()'
example.cpp:(...): undefined reference to `boost::context::stack_traits::maximum_size()'
Surprisingly, adding -lboost_context
flag to the compile command did not remove this link error, suggesting that libboost_context
is not properly linked against.
I then came across a question in boost forum wherein the original poster had somewhat similar problem to what I had. In short, there are a number of C macros that prevent execution_context to be properly included, and thus the problem with libboost_context
. The code to know if your compiler has some of these macros enabled is as follows (I'm not sure if all of these macros are relevant):
#include <boost/config.hpp>
#if defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) || \
defined(BOOST_NO_CXX11_CONSTEXPR) || \
defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || \
defined(BOOST_NO_CXX11_FINAL) || \
defined(BOOST_NO_CXX11_HDR_TUPLE) || \
defined(BOOST_NO_CXX11_NOEXCEPT) || \
defined(BOOST_NO_CXX11_NULLPTR) || \
defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) || \
defined(BOOST_NO_CXX11_UNIFIED_INITIALISATION_SYNTAX) || \
defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || \
defined(BOOST_NO_HDR_ATOMIC) || \
defined(BOOST_NO_HDR_TUPLE)
#error "execution_context is prevented to be included in this compiler";
#endif
The solution is easy: installing g++-6
(or I guess 5.2
or newer), and compiling the code with std=-c++14
.
Cannot link against boost filesystem in qt
Don't put the prefix or extension of the library name in the -l
parameter.
Use something like:
-lboost_filesystem-mgw46-d-1_47
configure rcsserver and have trouble with boost
If you use same team name you should change it's name :)
Related Topics
How to Track Child Process Using Strace
Remote Linux Server to Remote Linux Server Dir Copy. How
Why Disabling Interrupts Disables Kernel Preemption and How Spin Lock Disables Preemption
What Is a Reasonable Amount of Inotify Watches with Linux
Differencebetween Ld_Library_Path and -L at Link Time
Expression After Last Specific Character
What Is the Use of _Iomem in Linux While Writing Device Drivers
Can't Change Tomcat 7 Heap Size
How to Read Websocket Response in Linux Shell
Is There Any Modern Review of Solutions to the 10000 Client/Sec Problem
How to Find Ports Opened by Process Id in Linux
Limit on File Name Length in Bash
Linux Tool to Send Raw Data to a Tcp Server
What Is The Equivalent of "Aptitude" in MAC Osx
What Would It Take to Make Windows a Posix Compliant Operating System Out of The Box
How to Switch Linux Kernel Console After Boot Process
How to Write a Linux Bash Script That Tells Me Which Computers Are on in My Lan