【发布时间】:2013-05-28 18:42:38
【问题描述】:
我目前正在尝试在 Windows 下编译 redland (librdf http://librdf.org/)。根据他们的网站,它应该在 Windows 下构建。因为我不想花时间修复 .sln,所以我考虑在 cygwin 中编译 librdf(和必要的项目),然后在 Visual Studio 中使用该库。
所以我的问题是: 是否可以在 Windows 应用程序中使用在 cygwin 中编译的库?如果是的话怎么办?
由于我是 Windows 开发人员,我不知道创建的 .a 文件与 .dll 是否有任何区别。我已经阅读了该主题,并且有必要在项目中包含 cygwin1.dll,但这不是问题。
或者有没有人知道如何将 redland 编译为 windows dll? 我想过使用mingw,但直到现在我都没有设法编译它。
我们将不胜感激。
谢谢
更新:
感谢 Yaakov(以及他非常酷的 cygwin 端口)的帮助,同时我设法编译了 raptor(这是 librdf 的先决条件)。 我所要做的就是为配置添加另一个参数:--with-xml2-config=/usr/x86_64-w64-mingw32/sys-root/mingw/bin/xml2-config
现在我正在尝试编译 rasqal,它是另一个 requesite,也依赖于 raptor2。 为了让它工作,我必须为 pkg-config 导出 PKG_CONFIG_PATH="/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/" 以找到正确的 raptor 安装。
所以为 rasqal 配置工作,但是当我尝试进行配置时,我收到以下错误:
Making all in src
make[1]: Entering directory `/home/Stefan/workspace/rasqal/src'
make all-am
make[2]: Entering directory `/home/Stefan/workspace/rasqal/src'
/bin/sh ../libtool --tag=CC --mode=compile x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -DRASQAL_INTERNAL=1 -I/usr/x86_64-w64-mingw32/sys-root/mingw/include/raptor2 -g -O2 -DMTWIST_CONFIG -I../libmtwist -g -O2 -MT rasqal_algebra.lo -MD -MP -MF .deps/rasqal_algebra.Tpo -c -o rasqal_algebra.lo rasqal_algebra.c
libtool: compile: x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -DRASQAL_INTERNAL=1 -I/usr/x86_64-w64-mingw32/sys-root/mingw/include/raptor2 -g -O2 -DMTWIST_CONFIG -I../libmtwist -g -O2 -MT rasqal_algebra.lo -MD -MP -MF .deps/rasqal_algebra.Tpo -c rasqal_algebra.c -DDLL_EXPORT -DPIC -o .libs/rasqal_algebra.o
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/sys/time.h:10:0,
from rasqal.h:116,
from rasqal_algebra.c:39:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/time.h:260:8: error: redefinition of 'struct timezone'
./win32_rasqal_config.h:62:8: note: originally defined here
Makefile:1045: recipe for target `rasqal_algebra.lo' failed
make[2]: *** [rasqal_algebra.lo] Error 1
make[2]: Leaving directory `/home/Stefan/workspace/rasqal/src'
Makefile:720: recipe for target `all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/Stefan/workspace/rasqal/src'
Makefile:484: recipe for target `all-recursive' failed
make: *** [all-recursive] Error 1
我无法理解我并不是真正喜欢交叉编译。 有人能指出我正确的方向吗?
【问题讨论】:
-
您的操作正确;您刚刚遇到了可移植性问题。现在有两组适用于 Windows 的 GCC 兼容头文件和导入库:mingw.org 和 mingw-w64。后者更新、更完整,并且支持 x64,但这些差异可能与最初设计用于前者的软件包中的解决方法冲突,这似乎是这里的问题。 (我从未说过这会简单。)我会先删除
win32_rasqal_config.h文件中的冲突类型定义,然后尝试继续构建。 -
win32_rasqal_config.h在 cygwin 下构建时不应使用。而是使用自动工具生成的rasqal_config.h。
标签: visual-studio visual-c++ cygwin redland raptor2