<pre lang="c++"><pre lang="c++">
I wrote Smaple Boost logger code,when i compiled this code,only .DLL file Created,but .Lib is not generated,can anyone help me,how to generate .Lib for this code to work Multi dependency projects.
Project 1 contain Two file Logger.h and Logger.cpp
---------------------------------------------
Sample Code
-----------------
Logger.h
------
<pre>#pragma once
#include<crtdefs.h>
#include<boost/log/expressions.hpp>
#include<boost/log/expressions/formatters/named_scope.hpp>
#include<boost/log/sources/global_logger_storage.hpp>
#include<boost/log/support/date_time.hpp>
#include<boost/log/trivial.hpp>
#include<boost/log/utility/setup.hpp>
#include<string.h>
#include"Binary_Export.h"
#include <boost/log/sinks/debug_output_backend.hpp>
#define FILE (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define INFO BOOST_LOG_SEV ( my_logger::get(), boost::log::trivial::info) << "|" << FILE<< "| " <<" "<<"|"<< __LINE__ << "| "<<__FUNCSIG__
#define WARN BOOST_LOG_SEV( my_logger::get(), boost::log::trivial::warning) << "|" << FILE<< "| " <<" "<<"|"<< __LINE__ << "| "<<__FUNCSIG__
#define ERROR BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::error) << "|" << FILE<< "| " <<" "<<"|"<< __LINE__ << "| "<<__FUNCSIG__
#define SYS_LOGFILE "C:\\Users\\janardhanreddyn\\Documents\\LogFile\\DLL.log"
typedef boost::log::sources::severity_logger_mt<boost::log::trivial::severity_level> logger_t;
BOOST_LOG_GLOBAL_LOGGER( my_logger, logger_t);
Logger.Cpp
----------
#include"Simple_Logger.h"
namespace logging = boost::log;
namespace sinks = boost::log::sinks;
namespace src = boost::log::sources;
namespace expr = boost::log::expressions;
namespace attrs = boost::log::attributes;
namespace keywords = boost::log::keywords;
BOOST_LOG_GLOBAL_LOGGER_INIT(my_logger, logger_t)
{
logger_t lg;
logging::add_common_attributes();
logging::add_file_log(
keywords::file_name = SYS_LOGFILE,
keywords::rotation_size = 1024 * 1024 * 20,
keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point (0, 0, 0),
keywords::auto_flush = true,
keywords::format = (
expr::stream<<expr::format_date_time <boost::posix_time::ptime> ("TimeStamp", "%d-%m-%y %H:%M:%S")
<< " [" << expr::attr <boost::log::trivial::severity_level> ("Severity") << "]: "
<< expr::smessage
)
);
logging::add_console_log(
std::cout,
keywords::format = (
expr::stream <<"|"<< expr::format_date_time <boost::posix_time::ptime> ("TimeStamp", "%d-%m-%y %H:%M:%S")<<"|"
<< " [" << expr::attr <boost::log::trivial::severity_level> ("Severity") << "]: "
<< expr::smessage
)
);
logging::core::get()->set_filter
(
logging::trivial::severity >= logging::trivial::info
);
return lg;
}
What I have tried:
When I use above code in ProjectB, It was generated .Dll file,if i want to use above code in projectB,I need .Lib file.
ProjectB file Winfactory.h and Win_defination.cpp
---------------------------------------------------
Winfactory.h
---------------
#include"Factory.h"
#include"tfexports1.h"
class TF_API1 DWinfactory:public AFactory
{
public:
DWinfactory();
void Func();
};
Win_defination.cpp
#include"Winfactory.h"
DWinfactory::DWinfactory()
{
}
void DWinfactory:: Func()
{
INFO<<Derived Func"; //Info used from Project1
}