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

Ste*_*eve 5 cygwin redland visual-studio visual-c++ raptor2

我目前正在尝试在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的先决条件).我所要做的就是为configure配置另一个参数: - 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 /"以找到正确的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
Run Code Online (Sandbox Code Playgroud)

我无法理解这一点我并不是真的在进行交叉编译.有人能指出我正确的方向吗?

Yaa*_*kov 7

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

要开始,你需要安装mingw64-i686-gcc-core,mingw64-i686-headersmingw64-i686-runtime包,以及所有的依赖关系,通过Cygwin的setup.exe安装程序.然后,从依赖关系链的"底部"开始,使用例如:构建每个库:

./configure --prefix=/usr/i686-w64-mingw32/sys-root/mingw --host=i686-w64-mingw32
Run Code Online (Sandbox Code Playgroud)

然后运行make然后make install.对于Windows x64,用i686上面的所有s替换x86_64.

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