在经历了类似的挫折之后,我刚刚使用MinGW-w64 编译了 32 位和 64 位版本的 libreadline 6.2。这是我的做法:
我的 dev 目录的布局:
c:\dev\msys
c:\dev\mingw32
c:\dev\local32
c:\dev\mingw64
c:\dev\local64
为 32 位构建设置一些环境变量:
export CPPFLAGS=-I/c/dev/local32/include
export LDFLAGS=-L/c/dev/local32/lib
termcap 1.3.1.
运行配置脚本:
./configure --host=i686-w64_mingw32 --prefix=/c/dev/local32
编辑 termcap.c 并在顶部修复几行。我的看起来像这样:
/* Emacs config.h may rename various library functions such as malloc. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef emacs
#include <lisp.h> /* xmalloc is here */
/* Get the O_* definitions for open et al. */
#include <sys/file.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
//#ifdef HAVE_UNISTD_H
#include <unistd.h>
//#endif
#else /* not emacs */
//#ifdef STDC_HEADERS
#include <stdlib.h>
#include <string.h>
#define bcopy(b1,b2,len) (memmove((b2), (b1), (len)), (void) 0)
//#else
//char *getenv ();
//char *malloc ();
//char *realloc ();
//#endif
和 tparam.c
/* Emacs config.h may rename various library functions such as malloc. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef emacs
#include "lisp.h" /* for xmalloc */
#else
//#ifdef STDC_HEADERS
#include <stdlib.h>
#include <string.h>
//#else
//char *malloc ();
//char *realloc ();
//#endif
/* Do this after the include, in case string.h prototypes bcopy. */
//#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy)
#define bcopy(s, d, n) memcpy ((d), (s), (n))
//#endif
#endif /* not emacs */
修改 Makefile:
Line 23: CC = i686-w64-mingw32-gcc
Line 24: AR = i686-w64-mingw32-ar
Line 36: prefix = /c/dev/local32
Line 49: #oldincludedir = /usr/local
在调用 make install 之后,它应该可以在没有警告或错误的情况下编译。
readline 6.2
在调用之前设置与 termcap 相同的 CPPFLAGS 和 LDFLAGS 变量:
./configure --prefix=/c/dev/local32 --host=i686-w64-mingw32 --enable-static --enable-shared
编辑 Makefile:
Line 40: AR = i686-w64-mingw32-ar
make install 现在应该编译并安装 readline!
如果您需要 64 位库,请将 i686-w64-mingw32 替换为 x86_64-w64-mingw32 并将 local32 替换为 local64.