目前,我正试图在Windows下编译redland (图书管理员http://librdf.org/)。根据他们的网站,它应该在Windows下构建。由于我不想花时间修复.sln,所以我考虑在cygwin中编译library to (和必要的项目),然后在visual studio中使用这个库。
因此,我的问题是:在windows应用程序中是否可以使用cygwin编译的库?如果是的话,怎么做?
因为我是一个windows开发人员,所以我不知道从创建的.a文件到.dlls是否有什么区别。我已经阅读了这个主题,并且有必要将cygwin1.dll包含在项目中,但这不会是一个问题。
或者有谁更清楚我如何将redland编译成windows dlls呢?我曾想过使用mingw,但直到现在我才设法编译它。
任何帮助都将不胜感激。
谢谢
更新:
感谢Yaakov (和他非常酷的cygwin端口)的帮助,我同时成功地编译了猛禽(这是图书管理员的先决条件)。我所要做的就是包括另一个配置参数:--with-xml2-config=/usr/x86_64-w64-mingw32/sys-root/mingw/bin/xml2-config
现在,我正在尝试编译rasqal,这是另一个请求,也依赖于raptor2。为了使其工作,我必须导出PKG_CONFIG_PATH="/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/“的pkg-config,以找到正确的猛禽安装。
因此,对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我没办法想清楚我不太喜欢交叉编译。有人能把我引向正确的方向吗?
发布于 2013-05-29 00:01:30
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,然后运行make install。对于x64,用x86_64代替上面所有的i686。
请记住,librdf有很多(子)依赖项,但我现在不记得有多少是可选的。其中一些(但不是全部)可以从Cygwin港存储库中获得;这些至少可以帮助您开始工作。
发布于 2018-01-24 17:40:16
我建议您使用Visual构建raptor2。我在Visual 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-windowsBuild raptor2
下载猛禽:http://librdf.org/raptor/ (http://download.librdf.org/source/raptor2-2.0.15.tar.gz)
更改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/LIBXML2_INCLUDE_DIR/x64-windows/包含set LIBXML2_LIBRARIES to: LIBXML2_LIBRARIES
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_INSTALL_PREFIX设置为令人遗憾的路径,例如C:\thirdparty\vs2017\x64\raptor2
在Visual中执行INSTALL目标。
如果不喜欢手动执行此步骤,则只需下载预构建版本这里即可。
https://stackoverflow.com/questions/16799164
复制相似问题