【问题标题】:Getting cmake to work under Cygwin on Windows 7让 cmake 在 Windows 7 上的 Cygwin 下工作
【发布时间】:2018-09-10 13:35:18
【问题描述】:

我在我的 Windows 7 机器上安装了最新的 Cygwin:版本 2.893(64 位)。我确保我包含了 cmake,也就是说,在进行第一次安装后,我可以通过再次运行 Cygwin 网络版本安装程序来添加几个包。然后我尝试使用 cmake 并确保我从 bin 目录中调用它:

user008@L0147816 /bin
$ ./cmake
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
//share/cmake-3.6.2
Usage

cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

我不知道构建目录可能在哪里。我对 Cygwin 比较陌生。我希望有人找到了在 Cygwin 下安装 cmake 并正常工作的解决方案。

【问题讨论】:

    标签: windows cmake cygwin


    【解决方案1】:

    这看起来是 cmake 101。

    假设您只想从某个地方构建软件下载 例如gl2ps:

    # choosing a test area
    $ cd /tmp
    # downloading source
    $ wget http://geuz.org/gl2ps/src/gl2ps-1.4.0.tgz
    # expanding source code
    $ tar -xf gl2ps-1.4.0.tgz
    $ ls gl2ps-1.4.0-source/
    CMakeLists.txt  COPYING.LGPL  gl2ps.h    gl2ps.tex    gl2psTestSimple.c
    COPYING.GL2PS   gl2ps.c       gl2ps.pdf  gl2psTest.c  README.txt
    # preparing a build area
    $ mkdir build
    $ cd build
    # invoking cmake and pointing to the source directory 
    $ cmake ../gl2ps-1.4.0-source/
    -- The C compiler identification is GNU 7.3.0
    [cut ...]
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /tmp/build
    
    # running the build 
    $ make
    Scanning dependencies of target shared
    [ 11%] Building C object CMakeFiles/shared.dir/gl2ps.o
    ...
    [ 88%] Building C object CMakeFiles/gl2psTestSimple.dir/gl2psTestSimple.o
    [100%] Linking C executable gl2psTestSimple.exe
    [100%] Built target gl2psTestSimple
    

    要学习如何使用 cmake 构建,请转到 https://cmake.org/cmake-tutorial/

    【讨论】:

    • 好的,我用这个例子试过了:github.com/krux02/minimal_cmake_example 但我得到了同样的错误。此外,在 //share/cmake-3.6.2 中找不到这些模块。然后再一行:“CMake 错误:执行 cmake::LoadCache() 时出错。中止”。 Cygwin != Linux 发行版。再检查一下是不是101 ...
    • 好的,我的 Windows 机器上有几个 cmake 版本,我担心调用不同的版本 - 而不是使用 cygwin 安装的版本。这就是我这样做的原因:bin 目录中的“./cmake”。但是,现在我意识到,当我打开 cygwin 提示符时,无论如何都会调用正确的 cmake 可执行文件。无需在命令 cmake 前添加点和斜线!因此,我尝试使用新的“构建”目录中的 cmake 来构建最小的 cmake 示例 - 以 matzeri 显示的方式。这样我就走得更远了。我现在偶然发现了一个不同的问题:“无法找到请求的 Boost 库”...
    • 你安装了boost开发包吗?
    • 是的,我下载了 boost 包和 gtest(或 Google 测试)。我将它们放在 /usr/local/ 中的 2 个单独文件夹中,并在文件 CMakeCache.txt 中填写了路径。我现在能够编译该示例,但只有 2 个警告。
    【解决方案2】:

    这是我刚刚找到的解决方案。

    让我们命名 3 个目录:

    • {cygwin64-path}/bin/: cmake.exe 在这里。
    • {cygwin64-path}/usr/share/:cmake模块目录(如cmake-3.20.0)在这里。
    • {cygwin64-path}/share/: cmake.exe 试图在这里找到 cmake-module-directory,但它不存在。

    因为cygwin在{cygwin64-path}/usr/share/中安装cmake-module-directory,但是cmake.exe会在{cygwin64-path}/share/中寻找目录。

    所以解决方案很简单。下面的每一个都有效。

    方法一:创建目录{cygwin64-path}/share/,并将{cygwin64-path}/usr/share/中的所有相关目录和文件复制到新目录中。

    方法 2:创建 符号链接 {cygwin64-path}/share/{cygwin64-path}/usr/share/

    • 在 Windows 10 管理员 cmd.exe 中:mklink /J share usr\share 并且一切正常。
    • 或使用 WSL 或 Cygwin64 终端:ln -s usr/share share

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-01
      • 2011-11-27
      • 1970-01-01
      • 2013-07-28
      • 1970-01-01
      • 2011-03-29
      • 1970-01-01
      相关资源
      最近更新 更多