VC2010编译Log4cpp1.0

参考:http://blog.csdn.net/codejoker/article/details/5188364

1.去下面的地址下载log4cpp1.0源码,http://sourceforge.net/projects/log4cpp/files/

2.解压源码后发现log4cpp只提供了VC6.0的工程文件,在<msvc6>目录下。

3.用VisualStudio2010打开vc6的工程,并进行转换。

4.直接编译log4cppDLL项目,生成失败,提示如下:

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

5. 重新填写Custom Build Step项:

命令行填写如下

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

输出填写如下:

$(OutDir)/NTEventLogAppender.dll

6. 继续编译, 再次报错, 连接失败, 找不到符号

因为工程没有包含源文件: FactoryParams.cpp & Localtime.cpp

7. 手动添加上述两个文件到工程, 重新编译通过, 并生成log4cpp.dll


posted @ 2012-01-30 12:30  董雨  阅读(458)  评论(0编辑  收藏  举报