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

Ren*_*ger 9 cygwin mingw freetype gnu-make cygpath

我试图用MinGW/MSYS编译freetype是不成功的

这是我做的:

cmd.exe我切换到MSYS:

C:\temp\freetype-2.3.5-1\src\freetype\2.3.5\freetype-2.3.5>bash
Run Code Online (Sandbox Code Playgroud)

然后调用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'.
Run Code Online (Sandbox Code Playgroud)

配置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.
Run Code Online (Sandbox Code Playgroud)

问题似乎是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
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

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

更新好了,我已经做了一些侦探调查此事,似乎这个问题是precisly因为我还没有安装了Cygwin.我有这个假设因为cygpath是一个CygWin实用程序(见这里),它将unix-paths转换为windows-paths,反之亦然.

现在,¨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过程的知识可以给我一个关于这个问题的提示.

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

TOP_DIR := $(shell cd $(TOP_DIR); cygpath -m `pwd`)
Run Code Online (Sandbox Code Playgroud)

builds/unix/unix-def.mk然后更改行读取

RCTOOL_COMPILE = RCTOOL
Run Code Online (Sandbox Code Playgroud)

RCTOOL_COMPILE = $(RCTOOL)
Run Code Online (Sandbox Code Playgroud)

./builds/freetype.mk也复制http://gnuwin32.sourceforge.net/rctool.sh.txtc:\mingw\bin(因为有因缺少的奇怪的错误rctool.sh),并随后开始编译过程make.

现在,源文件的编译似乎(至少部分)最终完成,虽然我收到了 很多警告

./src/base/ftcalc.c:75:3: warning: 'FT_RoundFix' redeclared without dllimport attribute: previous dllimport ignored
Run Code Online (Sandbox Code Playgroud)

但链接器无法链接*.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'
Run Code Online (Sandbox Code Playgroud)

我猜编译警告与链接器错误无关.

所以现在怎么办?

rub*_*nvb 4

一般来说,在Windows上编译unix/linux软件可以有两种方式:

  1. 使用 MSYS 或 Cygwin 中的现有配置脚本。

  2. 使用 cmd.exe(Windows shell)提供的 mingw makefile。

你尝试了第一个(但我认为还不够努力),但第二个做错了:

  1. 尝试传递--host=i686-pc-mingw32配置。该脚本告诉您它检测到一个 unix 版本,这是严重错误的,正如您所看到的,它不起作用。

  2. 您还可以mingw32-make直接从 cmd.exe 来使用您找到的 makefile.mingw。它应该工作正常。

尝试在主源目录中找到 README 或 INSTALL 文件。它应该告诉您要做什么,并且可能有一个特定于 Windows 的部分。