VC2005下编译log4cpp的修正方法

现象:

   在vc2005下面编译下载过来的log4cpp源代码,由于log4cpp1.0仅提供了vc6的工程文件,因此,使用vs2005打开后,需要进行转换。但是转换后,不能正确编译,提示Custom Build Step时出现了错误,报错为:

1>正在执行自定义生成步骤
1>系统找不到指定的路径。
1>系统找不到指定的路径。
1>系统找不到指定的路径。
1>Project : error PRJ0019: 工具从"正在执行自定义生成步骤"
1>正在创建浏览信息文件...
1>Microsoft ?????????? Version 8.00.50727
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>BSCMAKE: error BK1506 : : No such file or directory
1>生成日志保存在“file://d:\log4cpp-1.0\msvc6\log4cpp\Debug\BuildLog.htm”
1>log4cpp - 2 个错误,0 个警告
========== 全部重新生成: 0 已成功, 1 已失败, 0 已跳过 ==========

分析:

   因为log4cpp在生成NTEventLogAppender.dll时,需要连接NTEventLogCategories.mc文件。所以,项目设置了自定义的生成步骤去生成NTEventLogAppender.dll。但从vc6的工程文件转换时,这些步骤却没有正确的转换过来。从而出现上述问题。

解决方法:

重新填写Custom Build Step项。

其中,CommandLine填写以下内容:

if not exist $(OutDir) md $(OutDir)
"mc.exe" -h $(OutDir) -r $(OutDir) $(SolutionDir)\NTEventLogCategories.mc
"RC.exe" -r -fo $(OutDir)\$(InputName).res $(ProjectDir)\$(InputName).rc
"link.exe" /MACHINE:IX86 -dll -noentry -out:$(OutDir)\NTEventLogAppender.dll $(OutDir)\$(InputName).res

Outputs填写:

$(OutDir)\NTEventLogAppender.dll

适用范围:

log4cppDLL项目的Debug和Release配置。

分割线----------------------------------------------------------------------------------------------------------------------------------

然后编译,8个连接报错,符号找不到

需要将源代码目录下的Localtime.cpp和FactoryParams.cpp两个文件添加到项目中,然后再次编译。即可成功。

原文地址:https://www.cnblogs.com/hcfalan/p/1916840.html