简体   繁体   English

如何从本地Windows .dll和/或.lib文件创建与Cygwin兼容的库文件

[英]How to create Cygwin compatible library files from native Windows .dll and/or .lib files

I have downloaded both a .dll and a .lib file compatible for 32-bit Windows from libspotify . 我已经从libspotify下载了与32位Windows兼容的.dll和.lib文件。 The project I am working on requires me to use other libraries that does not work on Windows, but compile and work using Cygwin. 我正在处理的项目要求我使用其他在Windows上不起作用,但可以使用Cygwin进行编译和工作的库。 I therefore need a way to get the .dll and/or .lib file "converted" into a compatible Cygwin format. 因此,我需要一种将.dll和/或.lib文件“转换”为兼容的Cygwin格式的方法。 Is that possible? 那可能吗?

The .dll file does not contain symbols, so the suggested method described in the bottom of the Cygwin doc did not work. .dll文件不包含符号,因此Cygwin文档底部描述的建议方法无效。

The other libraries that I have, generated the following files: 我拥有的其他库生成了以下文件:

/usr/local/lib/{libname.la, libname.dll.a and sometimes libname.a}
/usr/local/bin/cyglibname.dll

Where libname is the name of the library correctly compiled and installed. 其中libname是正确编译和安装的库的名称。 How do I get these files from the native 32-bit Windows .dll and .lib files? 如何从本地32位Windows .dll和.lib文件获取这些文件?

Update: 更新:

I tried to include the full path to the .dll file instead of using -l and -L as I am used to linking libraries, and I got the following message: 我尝试包含.dll文件的完整路径,而不是像我以前用来链接库那样使用-l和-L,我得到以下消息:

/usr/bin/ld: i386 architecture of input file `/usr/local/test/libspotify.dll' is 
incompatible with i386:x86-64 output

It seems like the problem is the 32-bit vs 64-bit. 看来问题出在32位与64位。 Anyone know how to fix that? 有人知道该如何解决吗?

Another update: 另一个更新:

It worked by adding -m32 to CFLAGS and LDFLAGS. 它通过将-m32添加到CFLAGS和LDFLAGS来工作。 I now got a different error that I believe is irrelevant for the original question. 我现在遇到了另一个错误,我认为它与原始问题无关。

It seems like the problem is the 32-bit vs 64-bit. 看来问题出在32位与64位。 Anyone know how to fix that? 有人知道该如何解决吗?

Yes; 是; use 32 bit Cygwin for a project that depends on third party DLL's only available in 32 bit form. 对于依赖第三方DLL(仅以32位格式提供)的项目,请使用32位Cygwin。 Do not use 64 bit Cygwin. 不要使用64位Cygwin。

Cygwin and Cygwin-64 can be installed side by side, by the way. 顺便说一下,Cygwin和Cygwin-64可以并排安装。 (And it's possible to share the same home folder between them, so you don't have to duplicate your .bashrc and whatnot.) (并且有可能在它们之间共享相同的主文件夹,因此您不必复制.bashrc和其他东西。)

This is not a Cygwin problem. 这不是Cygwin问题。 If you build a 64 bit executable with, say, Microsoft Visual Studio, it also will not load the 32 bit libspotify DLL. 如果使用Microsoft Visual Studio构建64位可执行文件,它也将不会加载32位libspotify DLL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM