Install the following packages using pacman -S package-name
:
- base-devel
- mingw-w64-{i686,x86_64}-toolchain
(mingw-w64-{i686,x86_64}-gcc, mingw-w64-{i686,x86_64}-pkg-config) - mingw-w64-{i686,x86_64}-pcre
- mingw-w64-{i686,x86_64}-xz
- git
Open "MSYS2 MinGW 32-bit" or "MSYS2 MinGW 64-bit" from the start menu.
$ git clone https://github.com/ggreer/the_silver_searcher.git
$ cd the_silver_searcher/
$ ./build.sh PCRE_CFLAGS=-DPCRE_STATIC LDFLAGS=-static
$ strip ag.exe
(This is an old way. Using MSYS2 is easier.)
Install the following packages using Cygwin's setup-x86.exe:
- mingw-gcc-g++
- mingw-zlib-devel
- pkg-config
- autoconf
- automake
- gettext
- gettext-devel
- liblzma-devel
- git
- wget
Build PCRE for static link. I don't want to install it to the system.
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.bz2
$ tar xvf pcre-8.34.tar.bz2
$ cd pcre-8.34/
$ ./configure CC=i686-pc-mingw32-gcc CXX=i686-pc-mingw32-g++ --enable-jit --enable-unicode-properties --disable-shared
$ make
$ cd ..
Build XZ Utils (liblzma) for static link. I don't want to install it to the system.
$ wget http://tukaani.org/xz/xz-5.0.5.tar.xz
$ tar xvf xz-5.0.5.tar.xz
$ cd xz-5.0.5
$ ./configure CC=i686-pc-mingw32-gcc
$ make
$ cd ..
PCRE, zlib and liblzma are statically linked with this configuration but pthread is dynamically linked.
$ git clone https://github.com/ggreer/the_silver_searcher.git
$ cd the_silver_searcher/
$ aclocal && autoconf && autoheader && automake --add-missing
$ ./configure CC=i686-pc-mingw32-gcc PCRE_CFLAGS='-DPCRE_STATIC -I../pcre-8.34 -I../xz-5.0.5/src/liblzma/api' PCRE_LIBS='-static -L../pcre-8.34/.libs -lpcre' LZMA_LIBS='-L../xz-5.0.5/src/liblzma/.libs -llzma' LIBS='-lshlwapi'
$ make
$ strip ag
Pthread's DLL will be found at:
C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\bin\pthreadGC2.dll
Build PCRE and install it to $HOME/opt/pcre
.
Ubuntu has PCRE but sometimes it is old. I want to use the latest PCRE to enable JIT.
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.bz2
$ tar xvf pcre-8.34.tar.bz2
$ cd pcre-8.34/
$ ./configure --prefix=$HOME/opt/pcre --enable-jit --enable-unicode-properties
$ make
$ make install
PCRE is statically linked with this configuration.
$ aclocal && autoconf && autoheader && automake --add-missing
$ ./configure PCRE_CFLAGS="-I $HOME/opt/pcre/include" PCRE_LIBS="-L $HOME/opt/pcre/lib -Wl,-Bstatic -lpcre -Wl,-Bdynamic"
$ make
It means "pthread is not statically linked". So when you run ag.exe, pthreadGC2.dll is needed.
Yes. After I wrote this, ag supports lzma. But I haven't compiled the latest ag yet.