如何使用vs2005编译log4cpp-0.3.5rc3?

如何使用vs2005编译log4cpp-0.3.5rc3?

问题:由于log4cpp-0.3.5rc3仅提供了vc6的工程文件,因此,使用vs2005打开后,需要进行转换。但是转换后,不能正确编译,提示Custom Build Step时出现了错误。

分析:因为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

适用范围:log4cpp项目、log4cppDLL项目的Debug和Release配置。同时,该方法适用于vs2003(vc7.1)。

-------------------------------------------------------------------------------------------------------------------------------------------

在VS2003下面编译log4cpp-0.3.5rc2时遇到下面的问题:
该版本的log4cpp提供了bcb5,vc6开发环境的工程文件,可以直接打开进行编译,在.net2003下面打开并转换工程文件后,有几个工程报告转换失败,它们是用来进行测试的,可以不管它们。直接编译log4cpp是通不过的,报错:error prj0019:工具从“正在执行自定义生成步骤”。把NTEventLogCategories.mc文件删除掉就可以了开始编译了,编译过程中找不到文件<log4cpp/Manipulator.hh>,发现在CategoryStream.hh文件中包含有该文件,将该文件包含语句include屏蔽掉,编译成功。