在 vs 2010 c++ 中构建 log4cxx
这让我发疯,我正在尝试构建 log4cxx 库以便在我一直在使用的 C++ 项目中使用。我在运行 VS2010 Express C++ 版本的 win7 主机上。我已按照 log4cxx 说明 ( ) 进行操作,包括下载 apr 和 apr-util 并主题化 .hw 文件,但不幸的是,当我尝试加载 log4cxx.dsw 解决方案并将其转换为当前的 VS 时,我收到一个错误,试图构建 apr.apr/dsw 和一堆其他相关的 .dsw 文件。有什么建议吗?
具体来说,我看到的是:
The Project file 'C:\...projects\apr-util\xml\expat\lib\xml.dsp' cannot be loaded. Do you want to remove the unloadable project from the solution?
我在一堆其他 .dsp 文件中看到了这一点。
然后在VC的输出框中:
C:\Users\x\Documents\Visual Studio 2010\Projects\apr\apr.dsp : error : Project upgrade failed.
C:\Users\x\Documents\Visual Studio 2010\Projects\apr-util\xml\expat\lib\xml.dsp : error : Project upgrade failed.
C:\Users\x\Documents\Visual Studio 2010\Projects\apr-util\aprutil.dsp : error : Project upgrade failed.
C:\Users\x\Documents\Visual Studio 2010\Projects\apache-log4cxx-0.10.0\projects\log4cxx.dsp : error : Project upgrade failed.
谢谢
文件位于正确的路径中。
This is driving me crazy, I'm trying to building the log4cxx library in order to use in a c++ project I've been using. I'm on a win7 host running VS2010 express c++ edition. I've followed the directions per the log4cxx directions ( ) including downloading apr
and apr-util and motifying the .hw files, but I unfortunately, when ever I try to load the log4cxx.dsw solution and convert it to the current VS, I receive an error trying to build apr.apr/dsw and a bunch of other dependent .dsw files. Any suggestions?
Specifically, what I am seeing is:
The Project file 'C:\...projects\apr-util\xml\expat\lib\xml.dsp' cannot be loaded. Do you want to remove the unloadable project from the solution?
I see this for a bunch of other .dsp files.
then in the output box in VC:
C:\Users\x\Documents\Visual Studio 2010\Projects\apr\apr.dsp : error : Project upgrade failed.
C:\Users\x\Documents\Visual Studio 2010\Projects\apr-util\xml\expat\lib\xml.dsp : error : Project upgrade failed.
C:\Users\x\Documents\Visual Studio 2010\Projects\apr-util\aprutil.dsp : error : Project upgrade failed.
C:\Users\x\Documents\Visual Studio 2010\Projects\apache-log4cxx-0.10.0\projects\log4cxx.dsp : error : Project upgrade failed.
Thanks
The files are in the correct path.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您必须按照以下步骤让 log4cxx(版本 0.10.0)与 VS2010 一起使用:
apu.hw
#define APU_HAVE_APR_ICONV
,将其设置为 0 并保存文件apr_ldap.hw
并找到条目#define APR_HAS_LDAP
,将其设置为 0 并保存该文件也是如此。好的,如果你现在点击构建,那么你将看到大约 2000 个错误,这就是有趣且“困难”的部分开始的地方:
一些示例:
示例:
如果编译器抱怨 insert_iterator 不在命名空间 std 中,请将
#include
添加到源文件的 include 部分。最后但并非最不重要的一点是,右键单击 log4cxx 项目并选择“添加引用”并选择其他 3 个项目作为引用
希望这对您和其他一些人有帮助:) ...如果您需要整个解决方案或其他文件,请告诉我!
我在 this Lex LI 的博客文章。
编辑:
您可以从我的保管箱下载我的 VS2010 解决方案和源代码:
https://www.dropbox.com/s/rn5d0044jzgzwyf/log4cxx_vs2010.7z
You have to follow these steps to get log4cxx (Version 0.10.0) working with VS2010:
apu.hw
in a texteditor of your choice#define APU_HAVE_APR_ICONV
, set it to 0 and save the fileapr_ldap.hw
from the same directory and find the entry#define APR_HAS_LDAP
, set it to 0 and save the file, too.Ok if you hit build now then you will see around 2000 errors and that is where the interesting and "hard" part starts:
Some examples:
Example:
If the compiler complains about insert_iterator not being in the namespace std, add
#include <iterator>
to the include section of the source file.Last but not least, right-click on log4cxx project and select Add References and select the other 3 projects as reference
Hope this helps you and some others :) ... if you need the whole solution or other files, let me know!
I figured out these steps with the enormous help of this blog entry by Lex LI.
EDIT:
You can download my VS2010 solution and source code from my dropbox:
https://www.dropbox.com/s/rn5d0044jzgzwyf/log4cxx_vs2010.7z
人们已经成功地通过 2 个步骤转换了 log4cxx:
值得庆幸的是,有人已经将 log4cxx 0.10 作为 Visual Studio 2008 项目提供,网址为 http://www.dreamcubes.com/webdrive/log4cxx_win32/log4cxx -0.10.0-vc2008-June2008.rar。我已经使用 VS 2010 Express 成功构建了该项目。
People have successfully converted log4cxx in 2 steps:
Thankfully, someone has made log4cxx 0.10 available as a Visual Studio 2008 project at http://www.dreamcubes.com/webdrive/log4cxx_win32/log4cxx-0.10.0-vc2008-June2008.rar. I've built the project successfully with VS 2010 Express.
第 1 章官方步骤
我们将按照此处的步骤操作,http ://logging.apache.org/log4cxx/building/vstudio.html。然而,我们必须做出改变以适应windows/VS201*。
从这里下载更高版本的 log4cxx,即 apache log4cxx 0.10,http://logging.apache .org/log4cxx/download.html
从下载依赖项https://archive.apache.org/dist/apr/
官方构建指南是非常容易遵循:
以上2个cmd需要sed.exe,在执行它们之前安装它(gow/git)。
或者您可以手动更改 apu.hw 和 apr_ldap.hw:
打开 apr_ldap.hw 并找到条目 #define APR_HAS_LDAP,将其设置为 0 并保存文件。
打开apu.hw并找到条目#define APU_HAVE_APR_ICONV,将其设置为0并保存文件
第2章构建Log4cxx
现在我们必须将*.dsw转换为*.cxproj。为了使其顺利进行,只需启动 Visual Studio 201* 并打开 log4cxx.dsw。 VS 会询问您是否要转换所有内容。只需单击“是”即可。
将 log4cxx 设置为启动项目。
属性->共同属性->框架和参考文献。
像这样,
旧的:
新的:
你会遇到另一个关于insert_iterator的错误,只需添加#include<迭代器>到相对文件
完成!享受你的 log4cxx!
Chapter 1 Official Steps
We are going to follow the steps here, http://logging.apache.org/log4cxx/building/vstudio.html. However, we must make changes to adapt to windows/VS201*.
download later version of log4cxx which is apache log4cxx 0.10 from here, http://logging.apache.org/log4cxx/download.html
download dependencies from https://archive.apache.org/dist/apr/
The official building guideline is quite easy to follow:
above 2 cmd requires sed.exe, install it (gow/git) before execute them.
or you can change apu.hw and apr_ldap.hw manually:
Open apr_ldap.hw and find the entry #define APR_HAS_LDAP, set it to 0 and save the file, too.
Open apu.hw and find the entry #define APU_HAVE_APR_ICONV, set it to 0 and save the file
Chapter 2 Building Log4cxx
Now we have to convert *.dsw to *.cxproj. To make it smooth, just launch Visual Studio 201* and open log4cxx.dsw. VS will ask if you like to convert everything. Simply click Yes.
Set log4cxx as startup project.
properties -> common properties -> framework and references .
like this,
old:
new:
and u will meet another err about insert_iterator, simply add #include< iterator> to relative file
Done! enjoy your log4cxx!
要使用 Visual Studio 2015 在 Windows 7 64 位上构建 log4cxx,除了 Scott 的回答之外,我还必须执行一些步骤,并进行一些说明。
将 apr_VERSION 和 apr-util_VERSION 文件夹重命名为 apr 和 apr-util,生成一个包含三个文件夹的目录:apache-log4cxx-0.10.0、apr 和 apr-util
现在,其中三个项目显示为“(Visual Studio 2010) ”在他们旁边。由于 stdio 的更改,这导致了稍后的链接错误:
4>apr-1.lib(start.obj):错误 LNK2001:无法解析的外部符号 __imp__wenviron
4>apr-1.lib(start.obj) : 错误 LNK2001: 无法解析的外部符号 __imp__environ
4>apr-1.lib(filedup.obj) : 错误 LNK2019: 函数 apr_file_dup2 中引用了无法解析的外部符号 __imp___iob_func
通过转到每个项目的“属性”并将所有配置的“平台工具集”更改为 Visual Studio 2015 来更改此设置。
"#if Defined(_MSC_VER) && !define(LOG4CXX_STATIC) && Defined(LOG4CXX)"
的行更改为"#if Defined(_MSC_VER) &第 1700 章定义(LOG4CXX)”
。"#elif Defined(_MSC_VER) && !define(LOG4CXX_STATIC)"
的行更改为"#elif Defined(_MSC_VER) && _MSC_VER < 1700 & ;& !定义(LOG4CXX_STATIC)"
。stringhelper.cpp
中的insert_iterator
相关。将#include
添加到该文件。然后出现链接错误:
apr-1.lib(rand.obj):错误 LNK2019:无法解析的外部符号 __imp__UuidCreate
要解决此问题,请转到 log4cxx 属性 >链接器>输入并添加
rpcrt4.lib
现在应该构建解决方案,并且该库将链接到您的 64 位应用程序。如果您只编辑一个,请重复调试/发布配置。
To build log4cxx on Windows 7 64-bit with Visual Studio 2015, I had to do a few steps in addition to Scott's answer, and have some clarifications.
Rename the apr_VERSION and apr-util_VERSION folder to apr and apr-util resulting in a directory with three folder: apache-log4cxx-0.10.0, apr and apr-util
Now I had three of the projects showing up with "(Visual Studio 2010)" next to them. This caused a link error later due to changes in stdio:
4>apr-1.lib(start.obj) : error LNK2001: unresolved external symbol __imp__wenviron
4>apr-1.lib(start.obj) : error LNK2001: unresolved external symbol __imp__environ
4>apr-1.lib(filedup.obj) : error LNK2019: unresolved external symbol __imp___iob_func referenced in function apr_file_dup2
Change this by going to the Properties for each project and changing the "Platform Toolset" for all configurations to Visual Studio 2015.
"#if defined(_MSC_VER) && !defined(LOG4CXX_STATIC) && defined(LOG4CXX)"
to"#if defined(_MSC_VER) && _MSC_VER < 1700 && !defined(LOG4CXX_STATIC) && defined(LOG4CXX)"
."#elif defined(_MSC_VER) && !defined(LOG4CXX_STATIC)"
to"#elif defined(_MSC_VER) && _MSC_VER < 1700 && !defined(LOG4CXX_STATIC)"
.insert_iterator
instringhelper.cpp
. Add#include <iterator>
to that file.Then there is a link error:
apr-1.lib(rand.obj) : error LNK2019: unresolved external symbol __imp__UuidCreate
To fix this, go to log4cxx Properties > Linker > Input and add
rpcrt4.lib
Now the solution should build and and the library will link to your 64-bit application. Repeat for Debug/Release configurations if you were only editing one.