Statically linked, correctly working readline library under windows?

we are developing a C ++ software package that depends on the GNU readline library, and we usually build using gcc (requiring at least version 4). Now we would like to transfer this to windows, having received a statically linked version, which we can redistribute without requiring compilation by users.

I tried several approaches:

  • using cygwin (do not use the provided readline in conjunction with -mno-cygwin or the mingw compiler),
  • using mingw and readline from GnuWin32 (unresolved stat64 dependencies that I could not solve),
  • building using mingw and building readline and necessary pdcurses from the source code (the most promising approach obtained before static binary code! But the resulting interactive shell behaved incorrectly, for example, the backspace was not visualized).

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

THX! Broes

+8
c ++ cygwin mingw libreadline
source share
3 answers

After such disappointments, I just compiled both a 32-bit and a 64-bit version of libreadline 6.2 using MinGW-w64 . Here is 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 configure script:

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

Modify termcap.c and correct a few lines at the top. My 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 */ 

Change 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 this call, make install and it should compile without warnings or errors.

readline 6.2
Set the same CPPFLAGS and LDFLAGS variables as 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 64-bit library, replace i686-w64-mingw32 with * x86_64-w64-mingw32 * and local32 with local64.

+4
source share

Check out the MinGWEditLine Library

Implementing the EditLine API for the native Windows console. This licensed BSD library provides editing features and command line history similar to those found in the GNU Readline.

The main functions of readline are implemented for the native Windows console. BSD License.

+2
source share

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

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

0
source share

Source: https://habr.com/ru/post/651246/


All Articles