在 Windows 上使用“make”和“g++”或如何让 karambola 在 Windows 上工作

问题描述

我的目标:在我的 Windows 10 机器上安装 karambola

要安装 karambola,我需要 make 命令,但在任何程序中都找不到。唯一有效的是使用 GnuWin32(当我在 karambola 目录中时):

& 'C:\Program Files (x86)\GnuWin32\bin\make.exe'

但它只是说:

 -Wall -O2 -DNDEBUG  -DVERSION_NUMBER=2.0 -o karambola.o -c karambola.cpp
 process_begin: CreateProcess(NULL,g++ -Wall -O2 -DNDEBUG -DVERSION_NUMBER=2.0 -o karambola.o -c karambola.cpp,...) Failed.
 make (e=2): Das System kann die angegebene Datei nicht finden.
 make: *** [karambola.o] Fehler 2

(“Das System kann die angegebene Datei nicht finden”的意思是“系统找不到给定的文件” 而“Fehler 2”的意思是“错误2”)

同样使用 Linux 控制台总是会导致找不到“g++”命令,我认为它会包含在我使用的程序中。

它说我需要 gsl 但这不适用于 Windows,所以我尝试了 Microsoft Visual Studios,然后是 Gnuwin32(连同 make.exe),然后是 Cygwin,然后是 msys 和 MinGW(基本上我能找到的所有解决方案)。我什至不知道每个包需要哪些包,也不知道它们的具体用途。我使用 Windows Powershell 来执行命令,因为看起来所有其他控制台都没有按照安装手册的预期工作。

我尝试了几天,但它不起作用。请帮忙:(

解决方法

无论您尝试使用什么发行版(Cygwin、Mingw、Linux Debian、Fedora ..),默认情况下都不会安装某些程序。 由于不是任何人都是 C++ 程序员,因此您需要安装/添加包含您的任务所需的工具、编译器、头文件、库的专用包。

例如 Cygwin 有将近 10000 个包:
https://cygwin.com/packages/package_list.html

所以你需要 makeg++ 和至少 gsl development package
使用 cygcheck -p 查找包含程序的包:

$ cygcheck -p usr/bin/make.exe
Found 6 matches for usr/bin/make.exe
..
make-debuginfo-4.3-1 - make-debuginfo: Debug info for make
..
make-4.3-1 - make: The GNU version of the 'make' utility

所以你需要安装包make。您可以跳过 debuginfo

$ cygcheck -p usr/bin/g++.exe
Found 5 matches for usr/bin/g++.exe
gcc-g++-10.2.0-1 - gcc-g++: GNU Compiler Collection (C++)
...
gcc-g++-9.3.0-2 - gcc-g++: GNU Compiler Collection (C++)

并且您需要安装包 gcc-g++
对于 gsl,我们查看导入库。可能是libgsl.dll.a 但我们以更通用的方式询问 Cygwin 网络服务器

$ cygcheck -p usr/lib/libgsl
Found 3 matches for usr/lib/libgsl
libgsl-devel-1.16-2 - libgsl-devel: the GNU Scientific Library (installed binaries and support files
)
libgsl-devel-2.3-1 - libgsl-devel: the GNU Scientific Library
libgsl-devel-2.3-2 - libgsl-devel: the GNU Scientific Library

安装libgsl-devel

不要忘记安装 cygwin-devel

查看安装附加包的文档
https://cygwin.com/install.html

,

我想通了:) 解决方案是使用 Windows 中已经实现的 Linux 功能。

  1. 在 Windows 设置中启用 Linux 并安装一个 ubunto 控制台,我可以从那里继续。 This helped me with that.

(我在以下步骤中遇到了一些问题,但有两件事对我有帮助:以 root 用户身份和 this fix 工作。)

  1. 然后我不得不安装 g++,它可以通过一个命令来完成(如果你尝试使用它,它会告诉你是哪一个)。

以下仅按照安装说明进行:

  1. 通过“configure && make && make install”安装gsl
  2. 通过“make”和“make test”安装karambola(第二个是必需的吗?可能不是)
  3. 通过“karambola myfile.poly --nolabels”或“karambola myfile.poly --labels”使用 karambola(在 root 用户模式下)。