I am starting a new c++ project and I want to use Boost.Build / bjam.
I'm getting "multiple definition" errors because, I think maybe, the jam file is not written correctly or I am not including the headers correctly or, perhaps, the library is not written well, which I have not investigated.
main.cpp uses libA. rest.cpp uses libA.
libA is a header library. Therefore I need to include headers for libA in both main.cpp and rest.cpp of the compiler complains about namespaces etc...
I'm using gcc on debian.
Here are my jam files:
Jamroot.jam
import os ;
import modules ;
path-constant boost-root : "/home/dude/include/boost_1_48_0" ;
path-constant cgi-root : "/home/dude/include/cgi-0.7.1/libs/cgi/build" ;
path-constant BOOST_BUILD_PATH : "$(boost-root)/tools/build/v2" ;
# path-constant include-dir : /usr/local/include ;
use-project /boost/ : $(boost-root) ;
use-project /boost/cgi/ : $(cgi-root) ;
lib libsoci_core : : <file>/usr/local/lib/libsoci_core.so ;
lib libsoci_odbc : : <file>/usr/local/lib/libsoci_odbc.so ;
lib libboost_log : : <file>/usr/local/lib/libboost_log.so ;
Jamfile.jam
project hello_fcgi
: requirements
<library>/boost/cgi/
<library>/boost/system/
<library>/boost/thread/
<include>/usr/local/include/soci/
<include>/usr/local/include/soci/odbc/
;
# exe rest : rest.cpp hello /boost/regex/ libboost_log libsoci_core libsoci_odbc ;
exe hello : main.cpp rest.cpp cms.cpp /boost/regex/ libboost_log libsoci_core libsoci_odbc ;
# Our install rule (builds binaries and copies them to <location>)
install install
:
hello
:
<location>/var/www/localhost/cgi-bin/
;
# Only install example if you use `bjam install' or equivalent
explicit install ;
The errors I get are repetitions of:
Performing configuration checks
- has_icu builds : yes
...patience...
...patience...
...found 3228 targets...
...updating 1 target...
gcc.link bin/gcc-4.4.5/debug/hello
bin/gcc-4.4.5/debug/rest.o: In function `basic_client':
/usr/include/c++/4.4/exception:62: multiple definition of `boost::cgi::common::basic_client<boost::cgi::common::tags::fcgi>::basic_client()'
bin/gcc-4.4.5/debug/main.o:/home/dude/include/cgi-0.7.1/boost/cgi/fcgi/client.hpp:44: first defined here
This defect report looks relevant: it seems this "header only" library has slipped up on a few things which aren't really just header only.