Opened 5 years ago
Closed 4 years ago
#13476 closed Bugs (fixed)
Linker error when using Spirit Classic
Reported by: | Owned by: | Joel de Guzman | |
---|---|---|---|
Milestone: | To Be Determined | Component: | spirit |
Version: | Boost 1.60.0 | Severity: | Regression |
Keywords: | spirit classic header only | Cc: |
Description
After upgrading to Boost 1.60, my project using Spirit Classic no longer builds, failing with a linker error complaining about undefined references to boost::system::generic_category() and boost::system::system_category().
The minimal test case is:
#include <boost/spirit/include/classic.hpp> int main (int argc, char ** argv) { return 0; }
which gives results in the following compiler output:
$ g++ -Wall test.cxx /tmp/ccpjbwj6.o: In function `__static_initialization_and_destruction_0(int, int)': test.cxx:(.text+0x23f): undefined reference to `boost::system::generic_category()' test.cxx:(.text+0x249): undefined reference to `boost::system::generic_category()' test.cxx:(.text+0x253): undefined reference to `boost::system::system_category()' collect2: error: ld returned 1 exit status
Attachments (1)
Change History (8)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
I don't think this is a Spirit bug. Is boost::system advertised to be header only?
comment:3 by , 5 years ago
Boost.System isn't, but Spirit is, right? At least it is not listed among the libraries that are not header only here.
comment:4 by , 5 years ago
The first thing I should say: Boost 1.60 is pretty old (released 2+ years ago).
Spirit does not use Boost.System directly, but I suspect it is used by Boost.Thread that may be included even if BOOST_SPIRIT_THREADSAFE
is not defined. Please try to apply manually https://github.com/boostorg/spirit/pull/323.patch or better grab the latest Spirit from the git develop branch.
The simplest solution for you is to add -lboost_system
to you compile command.
by , 5 years ago
Attachment: | thread_unsafe.patch added |
---|
comment:5 by , 5 years ago
The boost/spirit/home/classic/core/non_terminal/impl/static.hpp
might still be a problem even on the latest Spirit. Try to also apply the attached patch `thread_unsafe.patch`.
comment:6 by , 5 years ago
Oh, I missed that boost/spirit/home/classic/core/non_terminal/impl/static.hpp
will be included only if BOOST_SPIRIT_THREADSAFE
is defined. So the problem should have been fixed in PR 323.
comment:7 by , 4 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
A workaround is to define BOOST_SYSTEM_NO_DEPRECATED before including any Spirit headers.