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
Since it's been awhile, I just thought I'd like to comment on my experience.
First of all, after carefully following your exact instructions, it worked perfectly on my Windows 7 system at work. But not on the first try and here's why:
When you install MSYS2, it installs 3 subsystems: msys2, mingw32, and mingw64. You do the installs with msys2. But if you read carefully,the instructions above for Build the Silver Searcher say: Open "MSYS2 MinGW 32-bit" or "MSYS2 MinGW 64-bit" from the start menu. YOU MUST MAKE SURE AND OPEN MSYS2 MinGW 32-bit or MSYS2 MinGW 64-bit, NOT MSYS2 MSYS. If you don't, it won't find gcc, and things go downhill from there. If you do, everything works fine.
Now, on Windows 7, when you enter msys2 on the Start menu prompt, it conveniently gives you all 3 and you can select the proper one. But on Windows 10, it only shows you one choice. You have to select the proper one some other way (like opening Windows Explorer, and going to the msys2 installation directory).
One other issue, but not with this sites build instructions. The Windows version of ag doesn't seem to recurse into subdirectories. At least I couldn't figure out what to type to make it happen:
ag testpattern *.c works if you're in the proper directory
ag testpattern *.c doesn't find anything if you're in the parent directory. same with **/*.c
Anyways, really great job! thanks!