Windows 下静态链接、正常工作的 readline 库?

发布于 2024-10-12 12:05:04 字数 435 浏览 4 评论 0原文

我们正在开发一个 C++ 软件包,它依赖于 GNU readline 库,并且通常使用 gcc 进行构建(至少需要版本 4)。现在我们想将其移植到 Windows,获得一个静态链接版本,我们可以重新分发该版本,而无需用户编译。

我尝试了几种方法:

  • 使用 Cygwin 构建(不使用提供的 readline 与 -mno-cygwin 或 MinGW 编译器相结合),
  • 使用 MinGW 和 GnuWin32 的 readline 构建(未解决对 stat64 的依赖关系,其中我无法解决),
  • 使用 MinGW 构建并从源代码构建 readline 和所需的 pdcurses(最有前途的方法,获得静态二进制文件!但获得的交互式 shell 行为不正确,例如退格键未可视化)。

我们有什么想法可以让其中一种方法发挥作用吗?

We're developing a C++ software package which depends on the GNU readline library and we usually build using gcc (requiring at least version 4). Now we would like to port this to Windows, obtaining a statically linked version which we can redistribute without requiring compilation by users.

I've tried several approaches:

  • Building using Cygwin (no go with the provided readline combined with -mno-cygwin or a MinGW compiler),
  • Building using MinGW and readline from GnuWin32 (unresolved dependencies to stat64, which I could not resolve),
  • Building using MinGW and building readline and required pdcurses from source (most promising approach, got to a static binary! But the obtained interactive shell behaved incorrectly, e.g. backspace was not visualized).

Any ideas how we might get one of the approaches to work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你的呼吸 2024-10-19 12:05:04

经过类似的挫折后,我刚刚使用 MinGW-w64。以下是我的做法:

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 >。

After similar frustrations, I have just now compiled both a 32bit and 64bit version of libreadline 6.2 using MinGW-w64. Here's my how I did it:

Layout of my dev directory:

c:\dev\msys
c:\dev\mingw32
c:\dev\local32
c:\dev\mingw64
c:\dev\local64

Set some environment variables for the 32 bit build:

export CPPFLAGS=-I/c/dev/local32/include
export LDFLAGS=-L/c/dev/local32/lib

termcap 1.3.1.
Run the configure script:

./configure --host=i686-w64_mingw32 --prefix=/c/dev/local32

Edit termcap.c and fix up a few lines at the top. Mine looks like this:

/* 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

and 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 */

Modify the 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

After that call make install and it should compile without warnings or errors.

readline 6.2
Set the same CPPFLAGS and LDFLAGS variables as with termcap before calling:

./configure --prefix=/c/dev/local32 --host=i686-w64-mingw32 --enable-static --enable-shared

Edit the Makefile:

Line 40: AR = i686-w64-mingw32-ar

make install should now compile and install readline!
If you want a 64bit library, replace i686-w64-mingw32 with x86_64-w64-mingw32 and local32 with local64.

别靠近我心 2024-10-19 12:05:04

查看 MinGWEditLine 库

本机 Windows 控制台的 EditLine API 实现。这个 BSD 许可的库提供了类似于 GNU Readline 中的命令行编辑和历史功能。

主要的 readline 功能是针对本机 Windows 控制台实现的。 BSD 许可证。

Check out MinGWEditLine library

An EditLine API implementation for the native Windows Console. This BSD-licensed library provides command line editing and history functions similar to those found in GNU Readline.

Main readline functions are implemented for the native Windows console. BSD license.

清晰传感 2024-10-19 12:05:04

gnuwin32 有一个 readline 端口: http://gnuwin32.sourceforge.net/packages/readline.htm< /a>

对于非 GPL 项目,libedit 具有更可接受的许可 [使用 BSD 许可]

gnuwin32 has a port of readline: http://gnuwin32.sourceforge.net/packages/readline.htm

for non-GPL projects, libedit has a more acceptable licensing [uses BSD licensing]

烟雨凡馨 2024-10-19 12:05:04

现在有一个 cygwin 的 readline 发行版,它对我有用。包名称为libreadline-devel

There is now a cygwin distribution of readline, which worked for me. The package name is libreadline-devel

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文