如何使用MinGW / MSYS在Windows上编译htmlcxx?

问题描述

我正在尝试使用MinGW / MSYS编译htmlcxx lib,但遇到了麻烦。首先,我收到此错误

make : The term 'make' is not recognized as the name of a cmdlet,function,script file,or
operable program.

在通过编辑PATH解决了这一问题之后,我开始遇到有关“ ./configure”命令的相同错误

./configure : The term './configure' is not recognized as the name of a cmdlet,or operable program.

此问题的根源是什么?

解决方法

首先,我真的建议您使用MSYS2(https://www.msys2.org/),因为它比MSYS更新得多且速度更快,而MinGW-w64因为比MinGW更新而又最新,并且支持32位和64位Windows。

您的错误表明您正在从PowerShell运行这些命令,而不是从MSYS(bash)shell运行这些命令。从MSYS Shell运行相同的命令。

实际上,您可以省略autoreconf -i,因为已经有一个configure脚本。

自己尝试一下之后,我发现MSYS2 / MinGW-w64构建需要一些技巧来进行构建(静态库和共享库):

INSTALLPREFIX=/usr/local
./configure --prefix=$INSTALLPREFIX &&
sed -i.bak -e "s/\(allow_undefined=\)yes/\1no/" libtool &&
make install-strip am_libcss_parser_pp_la_OBJECTS="parser_pp.lo parser.lo css_syntax.lo css_lex.lo" LIBS="-Wl,--as-needed -liconv" &&
echo Success

我已将这些MinGW-w64构建问题报告给htmlcxx here

,

因此,这是我为使其正常工作所做的指示:

  • 首先安装MinGW
  • 然后转到C:\MinGW\bin并将mingw-make.exe重命名为make.exe(也许这不是必需的步骤,但这就是我所做的)
  • 然后将C:\MinGW\binC:\MinGW\msys\1.0\bin添加到您的PATH(环境变量)中
  • 然后打开文件夹,在其中解压缩htmlcxx并编辑Configure.ac文件-之后
AC_CHECK_LIB(iconv,iconv_open)

添加

AC_CHECK_LIB(iconv,libiconv_open)
  • 然后打开PowerShell,键入sh命令进入shell
  • 并且只有在那里,您应该使用htmlcxx cd到您的文件夹并使用以下命令:
autoreconf -i 
./configure 
make 
make install