gpt4 book ai didi

visual-studio - 使用 gcc 在 Cygwin 中编译库 (redland) 并使用 Visual Studio (c++) 中的输出

转载 作者:行者123 更新时间:2023-12-04 17:50:49 30 4
gpt4 key购买 nike

我目前正在尝试在 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,这是另一个需要的,也依赖于 raptor2。
为了让它工作,我必须为 pkg-config 导出 PKG_CONFIG_PATH="/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/"以找到正确的猛禽安装。

所以为 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

我无法理解我并不是真的喜欢交叉编译。
有人可以指出我正确的方向吗?

最佳答案

MSVC 和 Cygwin 运行时不兼容,因此您不能在 VS 中使用 Cygwin 编译的二进制文件。但是,您可以使用 Cygwin 交叉编译 Windows 库,对于 C 库,应该与 VS 兼容。 (C++ 是非常特定于编译器的,尤其是符号修改,但 IIRC 这些库都是用 C 编写的。)

首先,您需要安装 mingw64-i686-gcc-core , mingw64-i686-headers , 和 mingw64-i686-runtime包以及所有依赖项,通过 Cygwin 的 setup.exe安装程序。然后,从依赖链的“底部”开始,构建每个库,例如:

./configure --prefix=/usr/i686-w64-mingw32/sys-root/mingw --host=i686-w64-mingw32

然后运行 ​​ make其次是 make install .对于 Windows x64,替换所有 i686以上与 x86_64 .

请记住, librdf有很多(子)依赖项,但我现在不记得有多少是可选的。其中一些(但不是全部)可从 Cygwin Ports 获得。存储库;这些至少应该可以帮助您入门。

关于visual-studio - 使用 gcc 在 Cygwin 中编译库 (redland) 并使用 Visual Studio (c++) 中的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16799164/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com