c++ - 使用 log4cplus 运行代码时出现 bad_alloc 错误

标签 c++ windows runtime-error log4cplus

我一直在尝试在我的 PC 上运行这个 log4cplus 示例:

http://log4cplus.sourceforge.net/loglevel.html

我使用 VS2010 创建了我的 LogLevel 项目,我使用的是 log4cplus v1.1.0。

我的程序编译正常,但是当我执行这一行时

Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("main"));

我收到以下错误:

Unhandled exception at 0x75d5d3cf in LogLevel.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0030ed2c..

在“..\Microsoft Visual Studio 10.0\VC\crt\src\new.cpp”文件中(第 63 行)

我怎样才能解决这个问题?

我知道有 another SO thread谈论同样的问题,但不幸的是它没有得到解决。

最佳答案

如果您在调试中构建应用程序,请确保链接到 lib4CplusD.lib 和 lib4CplusD.dll。同样,发布应用程序应该链接 aginst lib4cplus.lib 和 lib4cplus.dll 我遇到了同样的运行时错误,当我将调试应用程序链接到调试库时,问题就解决了。

Logger::getInstance causing bad_alloc exception in log4cplus

关于c++ - 使用 log4cplus 运行代码时出现 bad_alloc 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13271707/

相关文章:

vba - 使用 VBA 从安全网站导入 Excel 中的数据时出现运行时错误 438

c++ - Qt 事件或 repaint() 函数不工作

c++ - 在 IOKit 中获取 Constant 或 Enum 的字符串表示形式,可能吗?

c++ - 使用 FFMPEG 将 RGB 图像序列保存到 .mp4 时遇到问题

php - 我可以使用 phpmyadmin 的 import.php 文件吗

windows - mingw-w64 线程 : posix vs win32

c++ - XCode 4.4.1 - C++ - Apple Mach-O 链接器 (ID) 错误 - 找不到架构 i386 的符号

windows - Windbg 将指针视为有符号整数

python - pytorch中矩阵和向量之间的加/减

php - 在 PHP 中使用 MySQLi 准备语句,得到 "No data supplied for parameters in prepared statement "