在vs 2010 C ++中构建log4cxx [英] building log4cxx in vs 2010 c++
问题描述
这让我发疯,我试图构建log4cxx库以便在我一直在使用的c ++项目中使用.我在运行VS2010 Express C ++版本的Win7主机上.我已按照每个log4cxx指示()的指示进行操作,包括下载apr 和apr-util并修饰.hw文件,但不幸的是,当我尝试加载log4cxx.dsw解决方案并将其转换为当前VS时,尝试构建apr.apr/dsw和一堆错误时会收到错误消息其他相关的.dsw文件.有什么建议吗?
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?
我看到了一堆其他的.dsp文件.
I see this for a bunch of other .dsp files.
然后在VC的输出框中:
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.
谢谢
文件位于正确的路径.
推荐答案
您必须按照以下步骤操作,以使log4cxx(版本0.10.0)与VS2010一起使用:
You have to follow these steps to get log4cxx (Version 0.10.0) working with VS2010:
- 从此处 下载最新的log4cxx软件包.
- 从此处 下载apr和apr-util ZIP软件包
- 将log4cxx,apr和apr-util提取到同一目录
- 将apr_VERSION和apr-util_VERSION文件夹重命名为apr和apr-util,从而得到一个包含三个文件夹的目录:apache-log4cxx-0.10.0,apr和apr-util
- 切换到log4cxx目录并执行configure.bat
- 更改为apr-util/include目录,并在您选择的文本编辑器中打开
apu.hw
- 找到条目
#define APU_HAVE_APR_ICONV
,将其设置为0并保存文件 - 从同一目录中打开
apr_ldap.hw
并找到条目#define APR_HAS_LDAP
,将其设置为0并保存文件. - 切换到log4cxx/projects目录,并使用VS2010打开log4cxx.dsw.为每个项目(apr,apr-util,log4cxx,xml)回答是/确定来回答VS2010的转换提示
- Download the latest log4cxx package from here
- Download apr and apr-util ZIP packages from here
- Extract log4cxx, apr und apr-util to the same directory
- 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
- Change into the log4cxx directory and execute configure.bat
- Change to apr-util/include direcotry and open
apu.hw
in a texteditor of your choice - Find the entry
#define APU_HAVE_APR_ICONV
, set it to 0 and save the file - Open
apr_ldap.hw
from the same directory and find the entry#define APR_HAS_LDAP
, set it to 0 and save the file, too. - Change to log4cxx/projects directory and open log4cxx.dsw with VS2010. Answer the converting prompts of VS2010 with yes/ok for each project (apr, apr-util, log4cxx, xml)
好吧,如果您现在点击构建,那么您将看到大约2000个错误,而有趣的硬"部分正是从这里开始的:
Ok if you hit build now then you will see around 2000 errors and that is where the interesting and "hard" part starts:
- Ctrl + F并找到"LOG4CXX_LIST_DEF"宏的每个条目.您必须将这些条目移出其相关类,并移到同一类之前.有时您也需要移动typedef或在宏之前添加类.
一些示例:
// telnetadapter.h
...
typedef log4cxx::helpers::SocketPtr Connection;
LOG4CXX_LIST_DEF(ConnectionList, Connection);
class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton
...
// appender.h
...
class Appender;
LOG4CXX_PTR_DEF(Appender);
LOG4CXX_LIST_DEF(AppenderList, AppenderPtr);
class Layout;
typedef log4cxx::helpers::ObjectPtrT<Layout> LayoutPtr;
...
class LOG4CXX_EXPORT Appender :
public virtual spi::OptionHandler
{
...
- 如果编译器抱怨KeySet不是LoggingEvent的成员,则只需删除作用域(由于我们在上一步中将类型移到类外部,因此这些类型不再在类内部)
示例:
// old
LoggingEvent::KeySet set;
// new
KeySet set;
-
如果编译器抱怨insert_iterator不在名称空间std中,请在源文件的include部分中添加
#include <iterator>
.最后但并非最不重要的一点是,右键单击log4cxx项目并选择Add References,然后选择其他3个项目作为参考
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!
我在此书的巨大帮助下找到了这些步骤 Lex LI的博客条目.
I figured out these steps with the enormous help of this blog entry by Lex LI.
您可以从我的保管箱下载我的VS2010解决方案和源代码: https://www.dropbox.com/s/rn5d0044jzgzwyf/log4cxx_vs2010.7z
You can download my VS2010 solution and source code from my dropbox: https://www.dropbox.com/s/rn5d0044jzgzwyf/log4cxx_vs2010.7z
这篇关于在vs 2010 C ++中构建log4cxx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!