升压日志链接错误 [英] link error with boost log

查看:28
本文介绍了升压日志链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试编译一个boost log(1.55)的例子,但是会弹出这样的链接错误

Try to compile an example of boost log(1.55), but it pop out the link error like this

main.obj : error LNK2019: unresolved external symbol "void __cdecl boost::log::v2s_mt_nt5::aux::code_convert(unsigned short const *,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::locale const &)" (?code_convert@aux@v2s_mt_nt5@log@boost@@YAXPBGIAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABVlocale@6@@Z) referenced in function "private: void __thiscall boost::log::v2s_mt_nt5::basic_formatting_ostream<char,struct std::char_traits<char>,class std::allocator<char> >::aligned_write<unsigned short>(unsigned short const *,int)" (??$aligned_write@G@?$basic_formatting_ostream@DU?$char_traits@D@std@@V?$allocator@D@2@@v2s_mt_nt5@log@boost@@AAEXPBGH@Z)

简化后的代码

#include <fstream>

#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared_object.hpp>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/sinks/text_ostream_backend.hpp>
#include <boost/log/sources/logger.hpp>
#include <boost/log/sources/record_ostream.hpp>

namespace logging = boost::log;
namespace src = boost::log::sources;
namespace sinks = boost::log::sinks;

void init()
{
    // Construct the sink
    typedef sinks::synchronous_sink< sinks::text_ostream_backend > text_sink;
    boost::shared_ptr< text_sink > sink = boost::make_shared< text_sink >();
}

int main()
{        

    return 0;
}

这是我的qmake文件

This is my qmake file

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

BOOST_LIB_PATH += G:/Tools/3rdLibs/boost/boost_1_55_0/lib32-msvc-9.0

INCLUDEPATH += G:/Tools/3rdLibs/boost/boost_1_55_0

QMAKE_CFLAGS_RELEASE += /MT
QMAKE_CXXFLAGS_RELEASE += /MT

LIBS += $${BOOST_LIB_PATH}/libboost_date_time-vc90-mt-s-1_55.lib
LIBS += $${BOOST_LIB_PATH}/libboost_chrono-vc90-mt-s-1_55.lib
LIBS += $${BOOST_LIB_PATH}/libboost_system-vc90-mt-s-1_55.lib
LIBS += $${BOOST_LIB_PATH}/libboost_filesystem-vc90-mt-s-1_55.lib
LIBS += $${BOOST_LIB_PATH}/libboost_thread-vc90-mt-s-1_55.lib

LIBS += $${BOOST_LIB_PATH}/libboost_log_setup-vc90-mt-s-1_55.lib
LIBS += $${BOOST_LIB_PATH}/libboost_log-vc90-mt-s-1_55.lib

SOURCES += main.cpp

vc2008编译,win7 32位

It is compiled by vc2008, win7 32 bits

我们的应用使用的是MT,我不能使用动态链接

our applications are using MT, I can't use dynamic link

推荐答案

问题解决了,需要定义

QMAKE_CFLAGS = -Zc:wchar_t
QMAKE_CXXFLAGS = -Zc:wchar_t

在您的代码中.

但我不知道这会不会造成任何麻烦

But I don't know this would cause any trouble or not

这篇关于升压日志链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆