首页 > 解决方案 > 在 Windows 10 上使用 OMNETPP shell 将 libxml 与 MinGW 链接

问题描述

使用 omnetpp shell 时,如何在 MinGW 上链接 libxml?

我在 Windows 10 机器上使用 omnetpp。
当我尝试从这里安装第 3 方包时发生了
我的
问题错误(I/mingw64/include/libxml2对于undefined reference to 'xmlFunctionName'许多函数名称)

我试图隔离问题并从 libxml2 编译代码示例
遵循编译指南:
使用gcc `xml2-config --cflags --libs` -o tree2 tree2.c
I got a fatal error: 'libxml/parser.h' file not found
When I replace xml2-config --cflags --libswith -I/mingw64/include/libxml2
I got the same error as beforeundefined reference to 'xmlFunctionName'

我能做些什么来解决这个问题?

标签: windowsmingwposixomnet++libxml2

解决方案


针对这个特定问题:libxml2 实际上已经存在,因为 OMNET 5.x 也使用它。目录中提供了所有依赖项和工具tools/win64/mingw64。问题是(出于未知原因)文件include/libxml2/libxml夹的包含文件。配置脚本正确检测到这一点,并使其在Makefile.incasXML_CFLAGS= = -I/mingw64/include/libxml2

这必须添加到要使用 XML 解析器的每个文件的编译器标志中。(库文件在/mingw64/lib文件夹中)因此可以检测到这些文件,无需额外配置即可使用。

通常,第三方库应该在/mingw64/include/mingw64/lib文件夹中可用。您可以在那里手动复制它们或尝试使用 mingw 包管理器安装它(但是这很可能会破坏您的 omnet 安装,因为 mingw64 不是特别一致并且它是一个滚动版本 - 即强烈不推荐这样做)。


推荐阅读