Build log4cpp with VC++ 2008

本文介绍如何将log4cpp的VC++6.0项目文件转换为VC++2008,并解决编译过程中遇到的问题,包括修复损坏的项目文件和修改自定义构建命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

log4cpp only provides VC++ 6.0 project files, so I have to convert those project files to VC++ 2008 and also make some changes in order to build them successfully. Here is the steps.

unzip to D:/opensource/log4cpp-1.0
Open D:/opensource/log4cpp-1.0/msvc6/msvc6.dsw with VC++ 2008
Convert this workspace to new version
Ignore corrupted project files

---------------------------
Microsoft Visual Studio
---------------------------
The project file 'D:/opensource/log4cpp-1.0/msvc6/log4cppDLL_stlport_boost/log4cppDLL_stlport_boost.dsp' has been corrupted and cannot be opened.
---------------------------
OK   
---------------------------

Open project settings of log4cpp project, change Custom Build command line of NTEventLogCategories.mc
The following is for VC++ 6.0
"$(DevEnvDir)../../VC98/Bin/mc.exe" -h $(OutDir) -r $(OutDir) $(ProjectDir)../$(InputName).mc
"$(DevEnvDir)Bin/RC.exe" -r -fo $(OutDir)/$(InputName).res $(OutDir)/$(InputName).rc
"$(DevEnvDir)../../VC98/Bin/link.exe" /MACHINE:IX86 -dll -noentry -out:$(OutDir)/NTEventLogAppender.dll $(OutDir)/$(InputName).res

Change to VC++ 2008
"$(WindowsSdkDir)Bin/mc.exe" -h $(OutDir) -r $(OutDir) $(ProjectDir)../$(InputName).mc
"$(WindowsSdkDir)Bin/RC.exe" -r -fo $(OutDir)/$(InputName).res $(OutDir)/$(InputName).rc
"$(DevEnvDir)../../VC/Bin/link.exe" /MACHINE:IX86 -dll -noentry -out:$(OutDir)/NTEventLogAppender.dll $(OutDir)/$(InputName).res

Add D:/opensource/log4cpp-1.0/src/Localtime.cpp to log4cpp project
D:/opensource/log4cpp-1.0/src/FactoryParams.cpp


Then change log4cppDLL project and build.
1>Linking...
1>   Creating library ./Debug/log4cppD.lib and object ./Debug/log4cppD.exp
1>RemoteSyslogAppender.obj : error LNK2001: unresolved external symbol "public: class std::_Tree<class std::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::const_iterator __thiscall log4cpp::FactoryParams::find(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?find@FactoryParams@log4cpp@@QBE?AVconst_iterator@?$_Tree@V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@$0A@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z)
1>RollingFileAppender.obj : error LNK2001: unresolved external symbol "public: class std::_Tree<class std::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::const_iterator __thiscall log4cpp::FactoryParams::find(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?find@FactoryParams@log4cpp@@QBE?AVconst_iterator@?$_Tree@V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@$0A@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z)
1>Win32DebugAppender.obj : error LNK2019: unresolved external symbol "public: class std::_Tree<class std::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::const_iterator __thiscall log4cpp::FactoryParams::find(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?find@FactoryParams@log4cpp@@QBE?AVconst_iterator@?$_Tree@V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@$0A@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z) referenced in function "protected: struct std::_Tree_nod<class std::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::_Node * __thiscall std::_Tree<class std::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::_Buynode(void)" (?_Buynode@?$_Tree@V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@$0A@@std@@@std@@IAEPAU_Node@?$_Tree_nod@V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@$0A@@std@@@2@XZ)
1>AbortAppender.obj : error LNK2001: unresolved external symbol "public: class std::_Tree<class std::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::const_iterator __thiscall log4cpp::FactoryParams::find(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?find@FactoryParams@log4cpp@@QBE?AVconst_iterator@?$_Tree@V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@$0A@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z)
1>FileAppender.obj : error LNK2001: unresolved external symbol "public: class std::_Tree<class std::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::const_iterator __thiscall log4cpp::FactoryParams::find(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?find@FactoryParams@log4cpp@@QBE?AVconst_iterator@?$_Tree@V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@$0A@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z)
1>NTEventLogAppender.obj : error LNK2001: unresolved external symbol "public: class std::_Tree<class std::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::const_iterator __thiscall log4cpp::FactoryParams::find(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?find@FactoryParams@log4cpp@@QBE?AVconst_iterator@?$_Tree@V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@$0A@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z)
1>PatternLayout.obj : error LNK2001: unresolved external symbol "public: class std::_Tree<class std::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::const_iterator __thiscall log4cpp::FactoryParams::find(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?find@FactoryParams@log4cpp@@QBE?AVconst_iterator@?$_Tree@V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@$0A@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z)
1>PatternLayout.obj : error LNK2019: unresolved external symbol "void __cdecl log4cpp::localtime(__int64 const *,struct tm *)" (?localtime@log4cpp@@YAXPB_JPAUtm@@@Z) referenced in function "public: virtual void __thiscall log4cpp::TimeStampComponent::append(class std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> > &,struct log4cpp::LoggingEvent const &)" (?append@TimeStampComponent@log4cpp@@UAEXAAV?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABULoggingEvent@2@@Z)
1>Debug/log4cppD.dll : fatal error LNK1120: 2 unresolved externals
1>Creating browse information file...
1>Microsoft Browse Information Maintenance Utility Version 9.00.21022
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Build log was saved at "file://d:/opensource/log4cpp-1.0/msvc6/log4cppDLL/Debug/BuildLog.htm"
1>log4cppDLL - 9 error(s), 23 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Add D:/opensource/log4cpp-1.0/src/Localtime.cpp to log4cppDLL project
D:/opensource/log4cpp-1.0/src/FactoryParams.cpp
Then the solution can be built successfully.
PS D:\Desktop\EAP本地\EAPAdmin\ADM_Client> npm install --global windows-build-tools npm WARN deprecated windows-build-tools@5.2.2: Node.js now includes build tools for Windows. You probably no longer need this tool. See https://github.com/felixrieseberg/windows-build-tools for details. npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. > windows-build-tools@5.2.2 postinstall E:\nodejs\node_global\node_modules\windows-build-tools > node ./dist/index.js ... and 1 more Downloaded vs_BuildTools.exe. Saved to C:\Users\shiningtang\.windows-build-tools\vs_BuildTools.exe. Starting installation... Please restart this script from an administrative PowerShell! The build tools cannot be installed without administrative rights. To fix, right-click on PowerShell and run "as Administrator". npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! windows-build-tools@5.2.2 postinstall: `node ./dist/index.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the windows-build-tools@5.2.2 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! E:\nodejs\node_cache\_logs\2025-07-10T01_51_11_574Z-debug.log
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值