Reputation: 1032
I followed the boost log tutorial here http://boost-log.sourceforge.net/libs/log/doc/html/index.html
I tries to compile and run this sample
//[ example_tutorial_trivial
#include <boost/log/trivial.hpp>
int main(int, char*[])
{
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An error severity message";
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
return 0;
}
It can not compile . Errors return as http://pastebin.com/DcLdWGke
Then i edit my code as follow :
#define BOOST_LOG_DYN_LINK
//[ example_tutorial_trivial
#include <boost/log/trivial.hpp>
int main(int, char*[])
{
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An error severity message";
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
return 0;
}
Now it complied and worked well .I read about this marcro on the boost site :
If defined in user code, the library will assume the binary is built as a dynamically loaded library ("dll" or "so"). Otherwise it is assumed that the library is built in static mode. This macro must be either defined or not defined for all translation units of user application that uses logging. This macro can help with auto-linking on platforms that support it.
So my question is : why i need #define BOOST_LOG_DYN_LINK to compiled ?
Upvotes: 1
Views: 1193
Reputation: 47824
#define BOOST_LOG_DYN_LINK
will forces all libraries that have separate source of their own, to be linked as dll's instead of static libraries.
Ref: \boost_1_xx_0\boost\config\user.hpp
for details
To configure boost, use the user config header <boost/config/user.hpp>
Upvotes: 0