Boost logo

Boost Users :

Subject: [Boost-users] Problem with linking files using boost::log with CMake Buildfile
From: David Georg Reichelt (davidgeorg_reichelt_at_[hidden])
Date: 2013-12-05 16:13:37


Hi,

I've got problems compiling a program using boost with CMake (using
Windows and MinGW 4.7.2, with -G "MinGW Makefiles"). Boost is compiled
normaly with b2.exe --toolset=gcc --prefix=C:\cppLib\boost_1_55_0 and
the folder seems to contain the right files. The original CMake-File
compiled fine using Ubuntu. I've got a code using only boost::log and a
CMake File containing the following boost-related-code:

ADD_DEFINITIONS("-std=c++0x")
SET(BOOST_ROOT "C:/cppLib/boost_1_55_0/")
link_libraries (${Boost_LIBRARIES})

find_package( Boost 1.54.0 COMPONENTS log)

if(Boost_FOUND)
MESSAGE("Boost found")
include_directories(${Boost_INCLUDE_DIRS})
add_executable(Hasselbrack ${AUTO_SOURCES})
endif()

This code works right, but when I call make, I get the following errors:

In file included from
C:/cppLib/boost_1_55_0/boost/log/expressions/formatters/c_decorator.hpp:21:0,
from C:/cppLib/boost_1_55_0/boost/log/expressions/formatters.hpp:29,
from C:/cppLib/boost_1_55_0/boost/log/expressions.hpp:26,
from C:\Users\DaGeRe\cpp\Minimalprojekt\main.cpp:3:
C:/cppLib/boost_1_55_0/boost/log/detail/snprintf.hpp:45:9: Fehler:
╗::swprintf½ wurde nicht deklariert
C:/cppLib/boost_1_55_0/boost/log/detail/snprintf.hpp:46:9: Fehler:
╗::vswprintf½ wurde nicht deklariert
In file included from
C:/cppLib/boost_1_55_0/boost/log/expressions/formatters.hpp:29:0,
from C:/cppLib/boost_1_55_0/boost/log/expressions.hpp:26,
from C:\Users\DaGeRe\cpp\Minimalprojekt\main.cpp:3:
C:/cppLib/boost_1_55_0/boost/log/expressions/formatters/c_decorator.hpp:
In statischer Elementfunktion â•—static std::size_t
boost::log::v2s_mt_nt5::exp
ressions::aux::c_decorator_traits<wchar_t>::print_escaped(wchar_t
(&)[N], wchar_t)½:
C:/cppLib/boost_1_55_0/boost/log/expressions/formatters/c_decorator.hpp:110:43:
Fehler: ╗swprintf½ ist kein Element von ╗boost::log::v2s_mt_nt5::aux½

I tried to figure it out, the lines in snprintf are the following:

using ::snprintf;
using ::vsnprintf;

but I can't find an error in this. The Include in the beginning of the file:

#ifdef BOOST_LOG_USE_WCHAR_T
#include <wchar.h>
#endif // BOOST_LOG_USE_WCHAR_T

seems to be exectued right (according to
http://pubs.opengroup.org/onlinepubs/7990989775/xsh/wchar.h.html,
snprintf is declared here). If I don't use
ADD_DEFINITIONS("-std=c++0x"), I got the following errors:

CMakeFiles\Hasselbrack.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x12c):
undefined reference to `boost::log::v2s_mt_nt5::core::get()'
CMakeFiles\Hasselbrack.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x143):
undefined reference to `boost::log::v2s_mt_nt5::core::set_filter(boost::log
::v2s_mt_nt5::filter const&)'
CMakeFiles\Hasselbrack.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x1c7):
undefined reference to `boost::log::v2s_mt_nt5::trivial::logger::get()'
CMakeFiles\Hasselbrack.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x20b):
undefined reference to `boost::log::v2s_mt_nt5::trivial::logger::get()'
CMakeFiles\Hasselbrack.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x2e7):
undefined reference to `std::ios_base::Init::~Init()'
CMakeFiles\Hasselbrack.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x308):
undefined reference to `std::ios_base::Init::Init()'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
CMakeFiles\Hasselbrack.dir/objects.a(main.cpp.obj): bad reloc address
0x1b in se
ction
`.text$_ZN5boost6detail15sp_counted_base7releaseEv[__ZN5boost6detail15sp_counted_base7releaseEv]'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
final link failed: Invalid operation

But nevertheless, boost is found and I can't figure out CMake seems to
be unable to link it. The output of $(Boost_LIBRARIES) from CMake also
seems correct:
C:/cppLib/boost_1_55_0/stage/lib/libboost_log-mgw47-mt-1_55.dll . So I
got no clue anymore what I could try.

Has anybody an hint how to solve this?

Best Regards,
DaGeRe


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