VC中的log4cplus++
如何将 log4cplus 框架添加到 VC++ 下的现有项目中? 当我尝试这样做时,我收到链接器错误。我不知道如何解决它。 谢谢赫兹尔
How I can add log4cplus Framework to an existing project under VC++ ?
When i try to do it I receive linker errors. I don't how to fix it.
Thanks herzl
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在项目配置中,您需要将库添加到链接器设置中。不过,趁我在这里,让我简要介绍一下 google-glog 库 ( Google 用于自己的日志记录)。您可以在 Google 日志记录 (GLog) 文档 页面。与 Log4Cxx 不同,Log4Cxx 要求您在各处创建各种记录器,GLog 使用起来更简单一些。示例:
上面没有必要实例化“LOG”、“ERROR”或“DFATAL”。他们就在那里。它还包括一些不同的断言宏,如 CHECK、CHECK_NOTNULL 等,它们将检查特定条件是否为真,然后 LOG(FATAL) 并显示有用的错误消息(如果是这种情况)。
In your project configuration, you need to add the library to your linker settings. While I'm here, though, let me briefly evangelize the google-glog library (which Google uses for its own logging). You can find documentation for it on the Google Logging (GLog) Documentation page. Unlike Log4Cxx, which requires you to create various loggers all over the place, GLog is a little bit simpler to use. Example:
It's not necessary to instantiate "LOG", "ERROR", or "DFATAL" in the above. They are just there. It also includes some various assertion macros like CHECK, CHECK_NOTNULL, etc. which will check that a particular condition is true, and then LOG(FATAL) with a useful error message if it is the case.
我昨天开始评估 log4cplus。我在VC2010下下载并构建了这个库,没有任何问题。但是,当您必须链接自己的代码时,就会变得有点棘手,因为 lib 和 dll 文件分散在各处。我编辑了属性页来更改输出目录,以便我可以在一个目录中找到所有调试库和 dll,并在另一个目录中释放库和 dll。
另外,对于 log4cplus_dll 库,库的名称与 dll 的名称不同。我在项目属性中修复了这个问题。现在我可以正确链接并运行它。
I started evaluating log4cplus yesterday. I downloaded and built the library under VC2010 without any trouble. But when you have to link with your own code, it becomes a little tricky since the lib and dll files are scattered all over. I edited the property pages to alter the output directory so that I can find all the debug libs and dlls in one directory and release libs and dlls in another.
Also, for the log4cplus_dll library, name of the lib is different from the dll. I fixed that in the project property. Now I am able to link properly and run it.