MinGW32:使用-static标志链接ImageMagick [英] MinGW32: Linking against ImageMagick with -static flag
问题描述
我目前正在尝试构建一个支持ImageMagick的Windows版emacs。
I am currently trying to build a Windows-version of emacs that supports ImageMagick.
为此,我已经使用MinGW32 / MSys编译了ImageMagick以获得兼容的库文件。基本上链接也有效,但我必须明确添加 -llibMagickCore-6.Q16
和 -llibMagickWand-6.Q16
通过 configure.bat
的 - lib
选项链接命令。
For that purpose I have already compiled ImageMagick with MinGW32/MSys in order to get compatible library files. Basically linking also works, though I have to add explicitly -llibMagickCore-6.Q16
and -llibMagickWand-6.Q16
to the linking command through configure.bat
's --lib
option.
但是,即使缺少依赖项,也应该加载windows的emacs二进制分发版。我在添加链接器选项( configure.bat --ldflags
) -static
时获得此行为。
However, the binary distribution of emacs for windows is supposed to load, even when the dependencies are absent. This behaviour I obtain when I add the linker option (configure.bat --ldflags
) -static
.
然而,当我尝试使用ImageMagick-Support进行编译时,静态链接失败,说它无法找到ImageMagick包含。
However, when I try to compile with ImageMagick-Support, static linking fails saying it cannot find the ImageMagick includes.
库文件位于 D:/ BUILD / libraries / lib
。作为一个最小的例子:
The library files are located in D:/BUILD/libraries/lib
. As a minimal example:
D:\>ld -LD:/BUILD/libraries/lib -llibMagickWand-6.Q16
D:\>ld -static -LD:/BUILD/libraries/lib -llibMagickWand-6.Q16
ld: cannot find -llibMagickWand-6.Q16
但是该目录包含静态库。
The directory does however contain the static library.
D:\BUILD\libraries\lib>dir *Magick*
[...]
2013-07-02 15:16 2,585,830 libMagick++-6.Q16.a
2013-07-02 15:16 1,745,404 libMagick++-6.Q16.dll.a
2013-07-02 15:16 1,178 libMagick++-6.Q16.la
2013-07-02 15:16 5,153,712 libMagickCore-6.Q16.a
2013-07-02 15:16 977,292 libMagickCore-6.Q16.dll.a
2013-07-02 15:16 1,096 libMagickCore-6.Q16.la
2013-07-02 15:16 1,609,692 libMagickWand-6.Q16.a
2013-07-02 15:16 472,364 libMagickWand-6.Q16.dll.a
2013-07-02 15:16 1,142 libMagickWand-6.Q16.la
任何想法,这里可能出现什么问题?根据我的理解, .a
文件是MinGW的静态库,因此缺少 .lib
文件( Visual Studio)应该不是问题。
Any idea, what could be going wrong here? From what I understand, the .a
files are the static libraries for MinGW, so the absence of .lib
files (Visual Studio) shouldn't be a problem.
我使用了ImageMagick的Unix源代码,因为Windows源代码需要Visual Studio来构建。
I have used the Unix source distribution of ImageMagick, because the Windows sources require Visual Studio for building.
推荐答案
我发现错误在 ld -verbose = 0 ...
。
出于某种原因,当使用 -static
标志时,lookupbehaviour会发生变化。没有 -static
标志:
For some reason, when using the -static
flag the lookupbehaviour changes. Without the -static
flag:
...
attempt to open D:/BUILD/libraries/lib/liblibMagickWand-6.Q16.dll.a failed
attempt to open D:/BUILD/libraries/lib/libMagickWand-6.Q16.dll.a succeeded
-static
flag:
...
attempt to open D:/BUILD/libraries/lib\liblibMagickWand-6.Q16.a failed
attempt to open c:\mingw\bin\../../MinGW/usr/local/lib\liblibMagickWand-6.Q16.a failed
attempt to open c:\mingw\bin\../../MinGW/lib\liblibMagickWand-6.Q16.a failed
attempt to open c:\mingw\bin\../../MinGW/usr/lib\liblibMagickWand-6.Q16.a failed
attempt to open D:/BUILD/libraries/lib\libMagickWand-6.Q16.lib failed
attempt to open c:\mingw\bin\../../MinGW/usr/local/lib\libMagickWand-6.Q16.lib failed
attempt to open c:\mingw\bin\../../MinGW/lib\libMagickWand-6.Q16.lib failed
attempt to open c:\mingw\bin\../../MinGW/usr/lib\libMagickWand-6.Q16.lib failed
ld: cannot find -llibMagickWand-6.Q16
写 -lMagickWand-6 .Q16
而不是 -llibMagickWand-6.Q16
工作。
这篇关于MinGW32:使用-static标志链接ImageMagick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!