Skip to content

Instantly share code, notes, and snippets.

@yongzhy
Last active December 22, 2016 09:26
Show Gist options
  • Save yongzhy/5450698 to your computer and use it in GitHub Desktop.
Save yongzhy/5450698 to your computer and use it in GitHub Desktop.
Build the silver searcher on Windows using MingW

Build the silver searcher on Windows using MingW

Install Dependency Packages

$mingw-get install pthread
$mingw-get install autotools

Compile and Install Zlib

download zlib-1.2.7

$tar vxzf zlib-1.2.7.tar.gz
$cd zlib-1.2.7
$vim win32/Makefile.gcc 

add following three lines

BINARY_PATH=/mingw/bin
INCLUDE_PATH=/mingw/include
LIBRARY_PATH=/mingw/lib

Then

$make -f win32/Makefile.gcc
$make install

Build PCRE

download pcre-8.32

$unzip pcre-8.32.zip
$cd pcre-8.32.zip
$./configure CC=mingw32-gcc CXX=mingw32-g++ --prefix=/mingw --enable-jit --disable-shared
$make

Build the silver searcher

$git clone https://github.com/ggreer/the_silver_searcher.git
$cd the_silver_searcher
$vim configure

Comment out line PKG_CHEC_MODULES(PCRE, libpcre)

$aclocal && autoconf && autoheader && automake --add-missing
$./configure CC=mingw32-gcc CXX=mingw32-g++ PCRE_CFLAGS='-I/z/tmp/pcre/pcre-8.32' PCRE_LIBS='-L/z/tmp/pcre/pcre-8.32/.libs -static -lpcre' LIBS='-lshlwapi'
$ make CFLAGS='-g -O2 -I/z/tmp/pcre/pcre-8.32 -Wall -Wextra -DPCRE_STATIC'

if the last linking process has error, directly issue command below to link

$mingw32-gcc  -g -O2 -I/z/tmp/pcre/pcre-8.32 -Wall -Wextra -DPCRE_STATIC   -o ag.exe  src/ignore.o src/log.o src/options.o src/print.o src/scandir.o src/search.o src/util.o src/decompress.o src/main.o  -lz -lpthread -lshlwapi

Now you have ag.exe, copy ag.exe and pthreadGC2.dll to same place, add this folder to your PATH, now you can use ag to search.

Use ag in VIM

Install ack.vim Put line below in to your .vimrc

let g:ackprg = 'ag --nogroup --nocolor --column'

Problem

When I use the ag build from the process above, I always got this error message, don't know how to eliminate it. Why ag will issue git command?

'git' is not recognized as an internal or external command, operable program or batch file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment