使用log4cplus时遇到的链接错误:无法解析的外部符号 "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,

#include "stdafx.h"
#include <log4cplus/logger.h>
#include <log4cplus/loggingmacros.h>
#include <log4cplus/configurator.h>
#include <log4cplus/fileappender.h>
#include <log4cplus/win32debugappender.h>
#include <log4cplus/layout.h>
#include <memory>
#include <log4cplus/consoleappender.h>
#include <log4cplus/tchar.h>

using namespace log4cplus;
using namespace log4cplus::helpers;

int _tmain(int argc, _TCHAR* argv[])
{
    log4cplus::initialize();
    Logger logger = Logger::getInstance(_T("main.log"));
    //std::wstring log_path = _T("d:\\test.log");
    SharedObjectPtr<Appender> _append (new ConsoleAppender());

    //step 1

    return 0;
}

error LNK2019: 无法解析的外部符号 "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" ([email protected]@[email protected]@[email protected][email protected][email protected][email protected]@@[email protected][email protected]@@[email protected]@@Z),该符号在函数 _wmain 中被引用
1>D:\GetFileIcon\Rand\Debug\log4cpptest.exe : fatal error LNK1120: 1 个无法解析的外部命令

由于我的导入库lib,以及动态库dll都是正确加载的,所以不是库没正确加载的问题。

分析:这是由于当前工程项目的“字符集”设置与log4plus所用的“字符集”不一致所导致的,log4cplus是使用多字节字符集,而当前工程是使用 Unicode 字符集

解决方案:打开项目属性页-常规-字符集,改成“多字节字符集”。

时间: 2024-07-29 08:14:09

使用log4cplus时遇到的链接错误:无法解析的外部符号 "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,的相关文章

C++程序链接失败,无法解析的外部命令,无法解析的外部符号 &quot;private: static class * Object::current&quot;

C++程序编译结束后,出现链接失败提示: 严重性    代码    说明    项目    文件    行    类别    禁止显示状态错误    LNK2001    无法解析的外部符号 "private: static class Object* Object::current" ([email protected]@@[email protected])    Object    F:\C++\Object.obj    1 严重性    代码    说明    项目    文

vs2010+qt4编译出现error LNK2001: 无法解析的外部符号 &quot;public: virtual struct QMetaObject等错误

1.当vs2010编译qt时会出现以下错误: 1>------ 已启动全部重新生成: 项目: MyDialog, 配置: Debug Win32 ------ 1>生成启动时间为 2015/9/9 14:57:04. 1>InitializeBuildStatus: 1>  正在创建"Debug\MyDialog.unsuccessfulbuild",因为已指定"AlwaysCreate". 1>CustomBuild: 1> 

一个小错误:error LNK2019: 无法解析的外部符号 &quot;public: __thiscall Turtle::~Turtle(void)&quot; (??1Turtle@@QAE@XZ),该符号在函数 _main 中被引用

昨天在撸代码的时候遇到了一个十分蛋疼的错误 : 错误: 1>3.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Turtle::~Turtle(void)" (??1Turtle@@QAE@XZ),该符号在函数 _main 中被引用1>3.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Turtle::Turtle(void)" (??0Turtl

boost 引用错误 无法解析的外部符号

严重性 代码 说明 项目 文件 行 禁止显示状态 错误 LNK2001 无法解析的外部符号 "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" ([email protected]@[email protected]@[email protected]@XZ) libthrift E:\thriftserver\thriftserver\TWins

使用NDK r10构建Cocosd-x v3.2时编译和链接错误的解决办法

如果你使用NDK r10构建Cocos2d-x v3.2,将会遇到所有测试用例编译错误以及Lua测试用例链接错误. 1. 编译错误 错误信息是: 1 2 3 4 5 6 7 8 /Users/minggo/SourceCode/cocos2d-x/build/../cocos/./3d/CCBundleReader.cpp:94:23: error:    return type of out-of-line definition of 'cocos2d::BundleReader::tell'

VC中链接错误,提示string重定义

VC链接错误,说是string已经有了实现了,只要 rebuild 一下好了. Linking...LINK : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specificationmsvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<

VS2013 中使用 CxImage 库时用Unicode编码时出现链接错误

CxImage 本身是支持Unicode 编码的,编译CxImage库的时候选择编译Unicode就可以了,得到的lib文件和dll文件很容易看出有个u的就是Unicode编码的 当然在使用的时候要对应项目该使用哪种库,为了方便,在使用动态库时,我选择全部导入 Debug Unicode_Debug  Release Unicode_Release四种lib #pragma comment(lib,"cximage.lib") #pragma comment(lib,"cxi

Ogre1.6.5 编译链接错误之FreeImage

这两天想重新学习下ogre,但是在vs2010上编译1.6.5的版本上遇到链接失败的问题,耗了不少时间这里记一下. 主要是一些重定义报错. >msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,stru

程序运行时遇到的链接问题

程序遇到链接问题很头疼,无法具体定位出错位置.以下是我最近几天遇到的编译错误,以及最后找出的原因分析. 1.LINK2019:无法解析的外部符号 "public: __thiscall BTnode<int>::~BTnode<int>(void)" ([email protected]@@[email protected]),该符号在函数 "public: void * __thiscall BTnode<int>::`scalar de