- 操作系统版本Windows 11 X64专业版
- Visual Studio 2019 Professional
- Cygwin64安装gcc-core、g++、gdb、make、libtool包
- 以下所有命令均在“Cygwin64 Terminal”命令行中执行
1 Windows C library headers and libraries.
WindowsCrtIncludeDir='C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt'
WindowsCrtLibDir='C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\'
INCLUDE="${WindowsCrtIncludeDir};$INCLUDE"
LIB="${WindowsCrtLibDir}x64;$LIB"
2 Windows API headers and libraries.
WindowsSdkIncludeDir='C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\'
WindowsSdkLibDir='C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\'
INCLUDE="${WindowsSdkIncludeDir}um;${WindowsSdkIncludeDir}shared;$INCLUDE"
LIB="${WindowsSdkLibDir}x64;$LIB"
3 Visual C++ tools, headers and libraries.
VSINSTALLDIR='C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional'
VCINSTALLDIR="${VSINSTALLDIR}"'\VC\Tools\MSVC\14.29.30133'
PATH=`cygpath -u "${VCINSTALLDIR}"`/bin/Hostx64/x64:"$PATH"
INCLUDE="${VCINSTALLDIR}"'\include;'"${INCLUDE}"
LIB="${VCINSTALLDIR}"'\lib\X64;'"${LIB}"
export INCLUDE LIB
4 configure, and build commands.
PATH=/usr/local/msvc64/bin:$PATH
export PATH
echo ${PATH}
#win32_target仅反选一下最接近的版本
win32_target=_WIN32_WINNT_WINXP # for MSVC 9.0
win32_target=_WIN32_WINNT_VISTA # possibly for MSVC >= 10.0
win32_target=_WIN32_WINNT_WIN7 # possibly for MSVC >= 10.0
win32_target=_WIN32_WINNT_WIN8 # possibly for MSVC >= 10.0
5 scripts ‘ar-lib’ and ‘compile’.
#cygwin cmd run
cd $HOME
mkdir msvc
下载ar-lib后保存至cygwin安装目录$HOME/msvc/ar-lib
下载compile后保存至cygwin安装目录$HOME/msvc/compile
#cygwin cmd run
cd $HOME/msvc
chmod a+x ar-lib compile
6 libiconv
cd D:/build/pg
tar -xf libiconv-1.16.tar.gz
cd libiconv-1.16
./configure --host=x86_64-w64-mingw32 --prefix=/usr/local/msvc64 \
--enable-static=no \
CC="$HOME/msvc/compile cl -nologo" \
CFLAGS="-MD" \
CXX="$HOME/msvc/compile cl -nologo" \
CXXFLAGS="-MD" \
CPPFLAGS="-D_WIN32_WINNT=$win32_target -I/usr/local/msvc64/include" \
LDFLAGS="-L/usr/local/msvc64/lib" \
LD="link" \
NM="dumpbin -symbols" \
STRIP=":" \
AR="$HOME/msvc/ar-lib lib" \
RANLIB=":"
修改libiconv-1.16\libcharset\lib\relocatable-stub.c,注释
/*
extern LIBCHARSET_DLL_EXPORTED void
libcharset_set_relocation_prefix (const char *orig_prefix, const char *curr_prefix);
*/
因为libcharset_set_relocation_prefix方法已经在libcharset.h中声明过了。
make
make check
make install
7 gettext
cd D:/build/pg
tar -xf gettext-0.21.tar.gz
cd gettext-0.21
./configure --host=x86_64-w64-mingw32 --prefix=/usr/local/msvc64 \
--with-libiconv-prefix=/usr/local/msvc64 \
--enable-static=no \
CC="$HOME/msvc/compile cl -nologo" \
CFLAGS="-MD" \
CXX="$HOME/msvc/compile cl -nologo" \
CXXFLAGS="-MD" \
CPPFLAGS="-D_WIN32_WINNT=$win32_target -I/usr/local/msvc64/include" \
LDFLAGS="-L/usr/local/msvc64/lib" \
LD="link" \
NM="dumpbin -symbols" \
STRIP=":" \
AR="$HOME/msvc/ar-lib lib" \
RANLIB=":"
make
make check
make install
cd ..
rm -rf gettext-0.21
8 最后
安装完成后从cygwin安装目录中的usr/local/msvc64复制到你的VC库即可。