Boost logo

Boost Users :

Subject: Re: [Boost-users] Problem with linking files using boost::log with CMake Buildfile
From: David Georg Reichelt (davidgeorg_reichelt_at_[hidden])
Date: 2013-12-07 07:15:47

Am 06.12.2013 16:59, schrieb Steven Watanabe:
>> <snip>
>> 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)
> Did you mean Boost 1.55.0?
Yes, you're right, that was an error when changing the version.
>> <snip>
>> This code works right, but when I call make, I get the following errors:
>> <snip>
>> C:/cppLib/boost_1_55_0/boost/log/detail/snprintf.hpp:45:9: Fehler:
>> ╗::swprintf½ wurde nicht deklariert
>> <snip>
> The problem is swprintf. I'm guessing
> that MinGW doesn't support it. You'll
> probably need -DBOOST_LOG_WITHOUT_WCHAR_T.
I tried to change ADD_DEFINITIONS to ADD_DEFINITIONS("-std=c++0x
-DBOOST_LOG_WITHOUT_WCHAR_T"). This changes the errors to:

undefined reference to `boost::log::v2s_mt_nt5::core::get()'
undefined reference to `boost::log::v2s_mt_nt5::core::set_filter(boost::log
::v2s_mt_nt5::filter const&)'
undefined reference to `boost::log::v2s_mt_nt5::trivial::logger::get()'
undefined reference to `boost::log::v2s_mt_nt5::trivial::logger::get()'
undefined reference to `std::ios_base::Init::~Init()'
undefined reference to `std::ios_base::Init::Init()'
CMakeFiles\Hasselbrack.dir/objects.a(main.cpp.obj): bad reloc address
0x138 in s
ection `.rdata'
final link failed: Invalid operation
collect2.exe: Fehler: ld gab 1 als Ende-Status zurück
make[2]: *** [Hasselbrack.exe] Fehler 1

again. But the library is again found correctly in
C:/cppLib/boost_1_55_0/stage/lib/libboost_log-mgw47-mt-1_55.dll (And is
still correkt in the CMakeCache.txt in
right, or should I add it somewhere else? At least, it changed the error...
>> If I don't use
>> ADD_DEFINITIONS("-std=c++0x"), I got the following errors:
> That's odd. Is Boost.Log somehow being compiled
> with -std=c++0x? It shouldn't be unless you
> specified it.
Not as I know. Trying to recompile boost leads to the following output: Has it maybe something to do with
the errors? The errors do not realy seem to be related to the log-library.
>> CMakeFiles\Hasselbrack.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x12c):
>> undefined reference to `boost::log::v2s_mt_nt5::core::get()'
>> <snip>
>> 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?
> In Christ,
> Steven Watanabe
Thanks for the advice!
Best Regards,

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at