This folder contains external libraries necessary for building The Silver Searcher for Windows using Microsoft Visual C++.
Usage:
Open a cmd.exe command window; Go to the_silver_searcher root directory; Then run:
win32\configure.bat
win32\make.bat
This builds the necessary libraries in win32, then ag.exe.
The 32 and 64 bits versions of ag.exe will be stored in bin\WIN32\ and bin\WIN64\ respectively.
The ag.exe programs built with these libraries have the following features:
- Support Windows XP and higher versions of Windows. (Windows Server 2003 minimum for the 64-bits version.)
- Support path names up to 64KB. (Using WIN32 APIs not limited to 260 bytes, even in XP.)
- Support Unicode path names.
- Support text files encoded both in UTF-8 and in the current Windows System Code Page.
(The latter depends on the Windows localization. Ex: CP 1252 for US and West-European versions of Windows.) - Support Unicode search strings and regular expressions.
(Some limitations for regexps searches in files encoded in Windows system CP, especially for MBCS CPs.) - Output non-ASCII characters correctly in any console code page.
(Provided that the console font has bitmaps for them. See the table below.)
(But if the output is piped to a file or another program, it'll be converted to the current console code page, and unsupported characters will be lost. This is a limitation of the Windows console, not of ag.exe.)
Console font | Character families it can display |
---|---|
Arial sans MS | Latin; Greek; Cyrillic |
Liberation Mono | Latin; Greek; Cyrillic; Hebrew |
Microsoft YaHei | Latin; Greek; Cyrillic; CJK Ideograms; Hiragana; Katakana; Hangul |
Yu Gothic | Latin; Greek; Cyrillic; Dingbats; CJK Ideograms; Hiragana; Katakana |
If needed, the "Visual Studio Community" edition is a free version of Visual C++ for Windows, available at: https://www.visualstudio.com/vs/cplusplus/
When installing it, select the workload "Desktop Development with C++", and the options "C++/CLI support" and "Standard Library modules".
The ag build has been tested successfully with Visual Studio versions 2013, 2015, and 2017.
Older versions of Visual Studio will NOT to work, due to lack of C99 support.
Note that all libraries build successfully with Visual Studio 2005. So converting ag/src/*.c to be C89-compliant
would allow adding support for older versions of Windows, and even for MS-DOS!
configure.bat searches the installed versions of Visual C++, Windows SDKs, and the necessary libraries.
It generates config.HOSTNAME.bat files, with definitions of the paths to the tools and libraries to use.
This script is automatically run once, the first time you build ag. (Running it manually allows to verify
that all tools and libraries are correctly located, before going on with the build.)
You need to run configure.bat again only if you install new versions of any of the build tools or libraries,
or move them to different places.
make.bat is a front-end to nmake.exe.
It uses the config.HOSTNAME.bat generated by configure.bat to locate all the necessary tools.
Then it uses the target-version-specific make files in win32\include to build each library and program version.
A log file with all compiler messages is created every time, and displayed automatically in case of a compilation error.
Both scripts are actually located in the win32\include sub-directory.
The short eponymous scripts in win32 are just proxies included for your convenience.
You may want to add the absolute path to win32\include in your PATH. This allows using make.bat in any directory,
for rebuilding one component without rebuilding the rest.
For example, once the libraries have been built, you may want to run make.bat in the src directory,
to save time when just rebuilding modified versions of ag.exe.
Home page: https://github.com/JFLarvoire/SysToolsLib/tree/master/C/MsvcLibX.
The MsvcLibX library extends Microsoft Visual C++ Standard C Libraries, adding many missing standard Unix definitions and functions.
It also includes support for UTF-8 command-lines, file names, input and output.
This ensures that Unix programs designed for use in an UTF-8 environment behave correctly in Windows' UTF16 environment, in any console code page.
MsvcLibX is one component of the System Tools Library, as are the configure.bat and make.bat scripts described above.
None
None
Home page: http://www.pcre.org/
Using pcre 8.44, which is the latest in the PCRE 1 series as of June 2020.
Do not use pcre2, which has different APIs.
Name | Description |
---|---|
config.h.MsvcLibX | Hand-crafted config.h for pcre, based on config.h.generic, describing MsvcLibX capabilities. |
configure.pcre.bat | Tells configure.bat to use the MsvcLibX library. |
Files.mak | Define input and output files. |
pcre.mak | Pcre-specific make rules. |
None
When upgrading pcre, check changes in config.h.generic, and port them into config.h.MsvcLibX.
This typically includes the 3 version strings.
Home page: http://sourceforge.net/projects/pthreads4w/
Using a patched version of pthread 3.0, which is the latest available as of June 2020. Note that the 2.10 beta used by KJK worked with only minimal patches for MsvcLibX compatibility, but the 2.10 RC, 2.10 release, and 3.0 release do not: They hang at run time. The root cause is a memory allocation issue in purely static builds of pthreads.lib
Name | Description |
---|---|
configure.pthread.bat | Tells configure.bat to ignore Nmakefile, and NOT to use the MsvcLibX library. |
Files.mak | Define input and output files. |
pthread.mak | Pthread-specific make rules. |
Name | Description |
---|---|
_ptw32.h | Line 123: Surrounded #define HAVE_STRUCT_TIMESPEC by #ifndef HAVE_STRUCT_TIMESPEC and #endif |
Line 151: Changed #elif !defined(__MINGW32__) to #elif !defined(__MINGW32__) && !defined(HAS_MSVCLIBX) |
|
config.h | Line 146: Changed #if defined(_MSC_VER) && _MSC_VER >= 1900 to `#if defined(_MSC_VER) && (_MSC_VER >= 1900 |
dll.c (v2.10 only) | Line 127: Moved four #pragma comment (linker, ...) lines to implement.h |
implement.h | Line 137: Added a #if defined(PTW32_CONFIG_MINGW) ... #endif block with the four #pragma comment (linker, ...) lines from dll.c. This ensures that purely static builds link with dll.obj. |
ptw32_processInitialize.c | Lines 42 & 143: Added a fix for the bug that caused pthreads.lib 2.10 and 3.0 to hang in static builds. |
Gotcha: pthread has its own Nmakefile file, which we do not want to use.
Hence the special IGNORE_NMAKEFILE definition in configure.pthread.bat.
Home page: http://www.zlib.net/
Using zlib 1.2.11, which is the latest version as of June 2020.
Name | Description |
---|---|
configure.zlib.bat | Tells configure.bat to use the MsvcLibX library. |
Files.mak | Define input and output files. |
zlib.mak | Zlib-specific make rules. |
Name | Description |
---|---|
gzguts.h | Line 47: Changed #ifdef WINAPI_FAMILY to #if defined(WINAPI_FAMILY) && !defined(HAS_MSVCLIBX) |
zutil.h | Line 170: Changed to: #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX && !defined HAS_MSVCLIBX |
Setting the DEBUG environment variable before running make.bat allows to build the debug versions of the libraries and ag.exe programs.
set "DEBUG=1"
win32\make.bat
The debug versions of the program are output in bin\WIN32\Debug\ and bin\WIN64\Debug\ respectively.
Recommended: The debug versions of the pcre and zlib libraries output huge amounts of data, which is rarely interesting for ag.exe debugging.
After building the debug libraries for the first time, overwrite the debug versions of the pcre and zlib libraries with the non-debug ones.
Then relink ag.exe using these libraries:
:# Overwrite the debug libraries
copy /y win32\pcre\bin\WIN32\pcre.lib win32\pcre\bin\WIN32\Debug\pcre.lib
copy /y win32\pcre\bin\WIN64\pcre.lib win32\pcre\bin\WIN64\Debug\pcre.lib
copy /y win32\zlib\bin\WIN32\zlib.lib win32\zlib\bin\WIN32\Debug\zlib.lib
copy /y win32\zlib\bin\WIN64\zlib.lib win32\zlib\bin\WIN64\Debug\zlib.lib
:# Delete the old debug versions of ag.exe
del bin\WIN32\Debug\ag.exe
del bin\WIN64\Debug\ag.exe
:# Descend into the src directory, to avoid relinking the debug libraries we just copied
cd src
:# Rebuild only ag.exe
..\win32\make.bat