静态链接,在Windows下正确工作的读取线库?
-
12-10-2019 - |
题
我们正在开发一个取决于GNU Readline库的C ++软件包,通常使用GCC构建(至少需要版本4)。现在,我们想将其移植到Windows,获取静态链接的版本,我们可以重新分发,而无需用户汇编。
我尝试了几种方法:
- 使用cygwin建造(不使用提供的读取线与
-mno-cygwin
或mingw编译器), - 使用gnuwin32的mingw和readline建造(我无法解决的STAT64依赖关系),
- 使用mingw和构建读取线建造,并从源中获得所需的pdcurses(最有前途的方法,可以使用静态二进制!但是获得的交互式外壳的行为不正确,例如,backspace并未可视化)。
有什么想法,我们如何获得一种工作方法?
解决方案
经过类似的挫败感,我现在刚刚编制了一个32位和64位版本的Libreadline 6.2 mingw-w64. 。这是我的工作方式:
我的布局 开发 目录:
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
在那次电话之后 进行安装 它应该在没有警告或错误的情况下进行编译。
读取线6.2
在调用之前,将相同的cppflags和ldflag变量与TermCap设置:
./configure --prefix=/c/dev/local32 --host=i686-w64-mingw32 --enable-static --enable-shared
编辑makefile:
Line 40: AR = i686-w64-mingw32-ar
进行安装 现在应该编译并安装读取线!
如果您想要一个64位库,请更换 I686-W64-MINGW32 使用 * x86_64-w64-mingw32 *和 local32 和 local64.
其他提示
本机Windows控制台的Editline API实现。该BSD许可的库提供了命令行编辑和历史记录功能,类似于GNU Readline中的功能。
对本机Windows控制台实现主读取功能。 BSD许可证。
GNUWIN32有一个读取线: http://gnuwin32.sourceforge.net/packages/readline.htm
对于非GPL项目,Libedit具有更可接受的许可[使用BSD许可
不隶属于 StackOverflow