使用gcc在Cygwin中编译库(redland),并在Visual Studio(c ++)中使用输出 [英] Compiling a library (redland) in Cygwin using gcc and using the output in Visual Studio (c++)

查看:211
本文介绍了使用gcc在Cygwin中编译库(redland),并在Visual Studio(c ++)中使用输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试在Windows下编译redland(librdf http://librdf.org/).根据他们的网站,它应该在Windows下构建.由于我不想花时间修复.sln,因此我想到了在cygwin中编译librdf(和必要的项目),然后在visual studio中使用该库.

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.

所以我的问题是: 是否可以在Windows应用程序中的cygwin中使用库进行编译?如果可以,怎么办?

So my question is: Is it possible to use librarys compile in cygwin in windows application? And if so how?

由于我是Windows开发人员,所以我不知道从创建的.a文件到.dlls是否有任何区别.我已经阅读了该主题,并且有必要在项目中包含cygwin1.dll,但这不是问题.

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.

还是有人能更好地了解如何将redland编译为Windows dll? 我曾考虑过使用mingw,但直到现在我还没有对其进行编译.

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.

任何帮助将不胜感激.

谢谢

更新:

借助于Yaakov(以及他非常酷的cygwin端口)的帮助,我同时设法编译了猛禽(这是librdf的前提). 我要做的就是包含另一个配置参数:--with-xml2-config =/usr/x86_64-w64-mingw32/sys-root/mingw/bin/xml2-config

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

现在,我正在尝试编译rasqal,这是另一个必要条件,并且还取决于raptor2. 为此,我必须导出PKG_CONFIG_PATH ="/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/"到pkg-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.

因此为rasqal配置工作正常,但是当我尝试将其配置时,出现以下错误:

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?

推荐答案

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

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.)

要开始使用,您需要通过Cygwin的setup.exe安装程序安装mingw64-i686-gcc-coremingw64-i686-headersmingw64-i686-runtime软件包以及所有依赖项.然后,从依赖关系链的底部"开始,使用例如:

To get started, you need to install the mingw64-i686-gcc-core, mingw64-i686-headers, and mingw64-i686-runtime packages, plus all dependencies, via Cygwin's setup.exe installer. Then, beginning with the "bottom" of the dependency chain, build each library with e.g.:

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

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

Then run make followed by make install. For Windows x64, substitute all the i686s above with x86_64.

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

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.

这篇关于使用gcc在Cygwin中编译库(redland),并在Visual Studio(c ++)中使用输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆