I'm currently trying to compile redland (librdf http://librdf.org/) under Windows. According to their website it should build under Windows. As i don't want to spend my time fixing the .sln I thought about compiling librdf (and the necessary projects) in cygwin and then use the library in visual studio.
So my question is: Is it possible to use librarys compile in cygwin in windows application? And if so how?
As I am a windows developer I don't know if there is any difference from the created .a files to .dlls. I already read up to the topic and it will be necessary to include the cygwin1.dll in the project but this won't be a problem.
Or does anyone have any better idea how I can get redland compiled as windows dlls? I thought about using mingw but until now I didn't manage to compile it.
Any help will be appreciated.
Thanks
Update:
Thanks to the help of Yaakov (And his pretty cool cygwin ports) I meanwhile managed to compile raptor (which is a prerequisite for librdf). All I had to do was include another argument for configure: --with-xml2-config=/usr/x86_64-w64-mingw32/sys-root/mingw/bin/xml2-config
Now I'm trying to compile rasqal which is another requesite and is also depending on raptor2. For it to work I had to export PKG_CONFIG_PATH="/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/" for pkg-config to find the correct raptor installation.
So configure for rasqal worked but when I try to make it I get the following error:
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
Which I can't get my head around I'm not really into cross compiling. Can someone point me into the right direction?
The MSVC and Cygwin runtimes are incompatible, so you cannot use a Cygwin-compiled binary within VS. However, you can use Cygwin to cross-compile a library for Windows, which for C libraries, should be compatible with VS. (C++ is very compiler-specific, particularly with symbol mangling, but IIRC these libraries are all in C.)
To get started, you need to install the
mingw64-i686-gcc-core
,mingw64-i686-headers
, andmingw64-i686-runtime
packages, plus all dependencies, via Cygwin'ssetup.exe
installer. Then, beginning with the "bottom" of the dependency chain, build each library with e.g.:Then run
make
followed bymake install
. For Windows x64, substitute all thei686
s above withx86_64
.Keep in mind that
librdf
has a lot of (sub)dependencies, but I don't remember now how many are optional. Some, but not all, of these are available from the Cygwin Ports repository; those should at least help you get started.I recommend you to build raptor2 using Visual Studio. I did this successfully for Visual Studio 2017 x64 this way:
Install libxml2 and libxslt
Open PowerShell:
Build raptor2
Download raptor: http://librdf.org/raptor/ (http://download.librdf.org/source/raptor2-2.0.15.tar.gz)
Change raptor2-2.015/CMakeLists.txt, line 258:
change raptor2-2.015/src/CMakeLists.txt, line 118:
open cmake: set LIBXML2_INCLUDE_DIR to: path/to/vcpkg/installed/x64-windows/include set LIBXML2_LIBRARIES to: path/to/vcpkg/installed/x64-windows/lib/libxml2.lib
Deployment:
Set
CMAKE_INSTALL_PREFIX
to your deplyoment path e.g.C:\thirdparty\vs2017\x64\raptor2
Execute the
INSTALL
target in Visual Studio.If you do not like to execute this steps manually you can just download a prebuild version here.