Visual studio 使用gcc在Cygwin中编译库(redland),并在visualstudio(c+;+;)中使用输出

Visual studio 使用gcc在Cygwin中编译库(redland),并在visualstudio(c+;+;)中使用输出,visual-studio,visual-c++,cygwin,redland,raptor2,Visual Studio,Visual C++,Cygwin,Redland,Raptor2,我目前正试图在Windows下编译redland(librdf)。根据他们的网站,它应该在Windows下构建。由于我不想花时间修复.sln,我考虑在cygwin中编译librdf(以及必要的项目),然后在visual studio中使用该库 所以我的问题是: 是否可以在windows应用程序中使用cygwin中的Library编译?如果是这样,怎么办 由于我是一名windows开发人员,我不知道创建的.a文件与.dll文件是否有任何区别。我已经阅读了这个主题,有必要在项目中包含cygwin1.

我目前正试图在Windows下编译redland(librdf)。根据他们的网站,它应该在Windows下构建。由于我不想花时间修复.sln,我考虑在cygwin中编译librdf(以及必要的项目),然后在visual studio中使用该库

所以我的问题是: 是否可以在windows应用程序中使用cygwin中的Library编译?如果是这样,怎么办

由于我是一名windows开发人员,我不知道创建的.a文件与.dll文件是否有任何区别。我已经阅读了这个主题,有必要在项目中包含cygwin1.dll,但这不会是一个问题

或者有没有人对如何将redland编译为windows DLL有更好的想法? 我曾想过使用mingw,但直到现在我还没能编译它

任何帮助都将不胜感激

谢谢

更新:

多亏了雅科夫(以及他相当酷的cygwin端口)的帮助,我同时成功地编译了raptor(这是librdf的先决条件)。 我所要做的就是为configure包含另一个参数:--with-xml2-config=/usr/x86_64-w64-mingw32/sys root/mingw/bin/xml2-config

现在我正在尝试编译rasqal,它是另一个requesite,也依赖于raptor2。 为了让它正常工作,我必须导出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
我无法理解,我不太喜欢交叉编译。
有人能给我指出正确的方向吗?

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

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

./configure --prefix=/usr/i686-w64-mingw32/sys-root/mingw --host=i686-w64-mingw32
然后运行
make
,然后运行
makeinstall
。对于Windows x64,将上面的所有
i686
替换为
x86\u 64


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

我建议您使用Visual Studio构建raptor2。 我通过以下方式成功地为Visual Studio 2017 x64实现了这一点:

安装libxml2和libxslt

打开PowerShell:

git clone https://github.com/Microsoft/vcpkg
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg install libxml2:x64-windows
.\vcpkg install libxslt:x64-windows
建造猛禽2

下载猛禽:()

更改raptor2-2.015/CMakeLists.txt,第258行:

ADD_DEFINITIONS(-DHAVE_CONFIG_H)
->
ADD_DEFINITIONS(-DHAVE_CONFIG_H -DYY_NO_UNISTD_H)
更改raptor2-2.015/src/CMakeLists.txt,第118行:

ADD_LIBRARY(raptor2
    raptor_avltree.c
    ...
->
ADD_LIBRARY(raptor2
    raptor_escaped.c
    sort_r.c
    raptor_ntriples.c
    raptor_avltree.c
    ...
打开cmake: 将LIBXML2_INCLUDE_DIR设置为:path/to/vcpkg/installed/x64 windows/INCLUDE 将LIBXML2_库设置为:path/to/vcpkg/installed/x64 windows/lib/LIBXML2.lib

set LIBXSLT_INCLUDE_DIR to: path/to/vcpkg/installed/x64-windows/include
set LIBXSLT_LIBRARIES to: path/to/vcpkg/installed/x64-windows/lib/libxlst.lib
set LIBXSLT_EXSLT_LIBRARY to: path/to/vcpkg/installed/x64-windows/lib/libexlst.lib
部署:

CMAKE\u INSTALL\u前缀设置为您的部门路径,例如
C:\thirdparty\vs2017\x64\raptor2

在Visual Studio中执行
安装
目标


如果您不想手动执行此步骤,您可以下载预编译版本。

您进行得很正确;您刚刚遇到了一个可移植性问题。现在有两组与GCC兼容的头文件和Windows导入库:mingw.org和mingw-w64。后者更新、更完整,并且支持x64,但这些都是di差异可能与最初设计用于前者的包中的变通方法相冲突,这似乎是这里的问题所在(我从来没有说过这会很容易)我会先删除
win32\u rasqal\u config.h
文件中冲突的typedef,然后尝试继续构建。
win32\u rasqal\u config.h
在cygwin下构建时不应使用。而是使用生成的
rasqal\u config.h
自动工具。