【问题标题】:c++ xerces reference without define but is definedc ++ xerces参考没有定义但已定义
【发布时间】:2015-12-24 04:51:56
【问题描述】:

我按照build xerces in linux 的说明进行操作 。/配置 制作 进行安装

但我正在尝试从Programming Guide 运行第一个示例

#include <xercesc/util/PlatformUtils.hpp>
// Other include files, declarations, and non-Xerces-C++ initializations.

using namespace xercesc;

int main(int argc, char* argv[])
{
  try {
    XMLPlatformUtils::Initialize();
  }
  catch (const XMLException& toCatch) {
    // Do your failure processing here
    return 1;
  }

  // Do your actual work with Xerces-C++ here.

  XMLPlatformUtils::Terminate();

  // Other terminations and cleanup.
  return 0;
}

但我遇到了一些错误:

 === Build: Debug in vasprun_xml (compiler: GNU GCC Compiler) ===

    vasprun_xml/main.cpp|22|reference to  `xercesc_3_1::XMLUni::fgXercescDefaultLocale' not define

    vasprun_xml/main.cpp 22reference to `xercesc_3_1::XMLPlatformUtils::Initialize(char const*, char const*, xercesc_3_1::PanicHandler*, xercesc_3_1::MemoryManager*)' not define

我该如何解决这个问题?

【问题讨论】:

  • 听起来你没有链接到 xerces 库。显示您的编译/链接命令。
  • 我将构建输出放在这个 pastebin pastebin.com/Bdcn9E1R 中。如果有用,我正在使用 code::blocks
  • 哦!您有问题的原因是 Code::Blocks 不能自动检测系统动态库。我们需要转到项目->构建选项->链接器设置,然后添加您的库的名称(在我们的例子中为 xerces-c-3.1)而不带 lib 前缀。好的,而不是构建和运行没有错误。就像做 g++ -o main main.cpp /path-to-your-lib/src/.libs/libxerces-c-3.1.so
  • 如果您找到了自己问题的答案,请将其作为答案发布在这里,然后接受它,这样问题就会关闭。

标签: c++ gcc g++ xerces


【解决方案1】:

匿名邮件是有原因的。

问题是 Code::Blocks 不能自动检测系统动态库。

我们需要去

项目->构建选项->链接器设置

然后添加不带 lib 前缀的库名称(在我们的例子中为 xerces-c-3.1)。好的,而不是构建和运行没有错误。

喜欢做

g++ -o main main.cpp /path-to-your-lib/src/.libs/libxerces-c-3.1.so

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-11
    • 1970-01-01
    • 1970-01-01
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    相关资源
    最近更新 更多