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
Nice instructions. The project's Readme and/or "Windows" wiki page could definitely use the updated instructions you have in this gist.
Also, you should use
--needed
withpacman
so that pacman won't re-install packages if you already have them (I don't know why that's pacman's default behavior. It doesn't make sense to me).@lel4866
That's not true. You can use any subsystem to install packages with
pacman
and those packages can then be used in any of the three subsystems.That's because mingw32 subsystem is for compiling 32-bit Windows programs, mingw64 subsystem is for compiling 64-bit programs, and msys subsystem is for compiling programs for use in MSYS2.
I just tried
ag testpattern *.c
in Linux and that doesn't do recursive search either.ag testpattern **/*.c
would work if you are using zsh or if you setshopt -s globstar
in bash. In any case, I think it's the shell that expands the wildcards into filenames and passes them toag
as argument instead ofag
itself expanding the wildcards. On Windows, the shell probably just pass**/*.c
literally toag
which is why you'll get errors likeAnyway, to do what you intend (search a pattern in .c files recursively), use this instead