有人成功地使用MinGW/MSYS编译freetype吗?

8

我尝试使用MinGW/MSYS编译freetype,但未成功。

我的操作如下:

cmd.exe切换到MSYS

C:\temp\freetype-2.3.5-1\src\freetype\2.3.5\freetype-2.3.5>bash

然后调用configure脚本

bash-3.1$ ./configure

FreeType build system -- automatic system detection

The following settings are used:

  platform                    unix
  compiler                    cc
  configuration directory     ./builds/unix
  configuration rules         ./builds/unix/unix.mk

If this does not correspond to your system or settings please remove the file
`config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type `make' again to build the library,
or `make refdoc' to build the API reference (the latter needs python).

cd builds/unix; ./configure
checking build system type... i686-pc-mingw32

[------ Deleted some 121 lines because they seem irrelevant for the problem ------]

config.status: creating ftconfig.h
make: Nothing to be done for `unix'.

在配置好freetype之后,我想使用make编译源代码:

bash-3.1$ make
/bin/sh: cygpath: command not found
config.mk:36: /builds/freetype.mk: No such file or directory
config.mk:57: /builds/unix/install.mk: No such file or directory
builds/toplevel.mk:158: /builds/modules.mk: No such file or directory
make: *** No rule to make target `/builds/modules.mk'.  Stop.

问题似乎在于 cygpath,这很奇怪,因为我没有安装cygwin。
由于编译说明需要使用gnu make,我进行了验证:
bash-3.1$ make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i686-pc-msys

我做错了什么?

编辑:目录中还有Makefile.mingw。尝试使用make -f Makefile.mingw启动编译过程也无法完成,返回消息¨make: *** No rule to make target 'MFSED', needed by 'all'. Stop.

更新:好的,我进行了一些调查,似乎问题是因为我没有安装CygWin。我这样认为是因为cygpath是CygWin实用程序(请参见此处),可以将Unix路径转换为Windows路径,反之亦然。

现在,¨find . -type f -exec grep -l cygpath {} \;找到了几个使用cygpath的位置:

  • ./builds/unix/aclocal.m4
  • ./builds/unix/configure
  • ./builds/unix/unix-def.in
  • ./builds/unix/unix-def.mk
  • ./patches/freetype-2.3.4.diff
  • ./patches/freetype-2.3.5/builds/unix/unix-def.mk
  • ./patches/freetype-2.3.5.diff

我认为我需要在其中一个或多个位置更改一些内容以修复构建。对吗?我仍然希望有更多了解整个./configure-build过程的人能够给我一些提示。

更新II:根据rubenvb的答案,我想我可以尝试./configure --build=i686-pc-mingw32,然后删除读取的行

TOP_DIR := $(shell cd $(TOP_DIR); cygpath -m `pwd`)

builds/unix/unix-def.mk 文件中,然后更改读取行。
RCTOOL_COMPILE = RCTOOL

to

RCTOOL_COMPILE = $(RCTOOL)

./builds/freetype.mk中,同时将http://gnuwin32.sourceforge.net/rctool.sh.txt复制到c:\mingw\bin(由于缺少rctool.sh导致出现奇怪的错误),然后使用make开始编译过程。现在,源文件的编译似乎(至少部分地)最终完成了,尽管我收到了许多警告信息,例如:
./src/base/ftcalc.c:75:3: warning: 'FT_RoundFix' redeclared without dllimport attribute: previous dllimport ignored

但是链接器无法链接*.o文件,因为存在许多未定义的引用,例如:
C:\temp\freetype-2.3.5-1\src\freetype\2.3.5\freetype-2.3.5/src/base/ftinit.c:89: undefined reference to `_imp__FT_Add_Module'

我猜编译警告与链接错误有关联。那么,现在怎么办?
1个回答

4
一般来说,在Windows上编译Unix/Linux软件有两种方法:
  1. 使用MSYS或Cygwin中现有的配置脚本。
  2. 从cmd.exe(Windows shell)中使用提供的mingw makefile。
你尝试了第一种方法(但我认为不够努力),并且错误地执行了第二种方法:
  1. 尝试将--host=i686-pc-mingw32传递给configure。脚本告诉你它检测到了一个Unix构建,这是极其错误的,正如你所看到的,不起作用。
  2. 你也可以直接从cmd.exe中使用mingw32-make来使用你找到的makefile.mingw。它应该可以正常工作。
尝试在主源目录中查找README或INSTALL文件。它应该会告诉你该怎么做,并可能具有一个针对Windows的特定部分。

感谢您宝贵的帮助。不幸的是,两个选项都没有改变任何东西,仍然产生与缺少 cygpath 相关的相同错误。我找到了一个 README(实际上称为 INSTALL.UNIXUPGRADE.UNIX,都明确说明是用于 MinGW/MSYS),并告诉我基本上已经做了我已经做过的事情。我不会争论我没有尽力而为(虽然我已经花了4-5个小时),但整个 ./configure 的目的不是让我们不必担心不同的平台吗? - René Nyffenegger
1
cygpath在msys环境中不应该被需要。您确定在Windows控制台(cmd.exe)中使用mingw32-make的mingw makefile无法工作吗? - rubenvb
当我打开一个cmd.exe并cd到C:\ temp \ freetype-2.3.5-1 \ src \ freetype \ 2.3.5 \ freetype-2.3.5,然后运行mingw32-make.exe -f Makefile.mingw,它会打印很多行,最终打印mingw32-make:***没有规则可以制作目标MFSED',需要all'。停止。 - René Nyffenegger
@René:那么他们的makefile肯定有问题。但是你的目录结构非常深(虽然可能与你的问题无关...) - rubenvb
谢谢你的帮助。我的解压源代码似乎出了些问题。我已经下载了另一个源代码压缩文件,目前正在构建库。看起来这次应该会成功。 - René Nyffenegger
随着时间的推移和问题的变化:我偶然发现了这个答案,因为 msys2-freetype2 的依赖链在 ole32 处停止,而 ole32 不是 msys2 的一部分。现在编译 freetype 更加容易了。下载源代码,在 mingw32/mingw64 shell 中打开,运行 ./configuremake -j SOME_NUMBER,完成。 - scones

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接