最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to build the C++ GLM library with cmake in Windows? - Stack Overflow

programmeradmin1浏览0评论

I am having issues building the GLM library. I am using Windows and VS Code. I have the following installed:

  • Mingw64 that includes gcc and g++ compilers
  • cmake

For GLM, as instructed in their readme:

  • I downloaded the latest release and extracted it to c:\glm

  • I navigated to the folder in the command prompt and ran the command

    C:\cmake\bin\cmake -DGLM_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -B build .
    
  • I got the following error:

    CMake Error in CMakeLists.txt:
      Running
    
       'nmake' '-?'
    
      failed with:
    
       no such file or directory
    
    
    CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
    CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
    

I tried with cmake-gui as well but I got the same error when I clicked configure.

I also have the cmake extension for VS Code so I tried configuring and building in VS Code, right clicking on the CmakeLists.txt and selecting "Clean Reconfigure All Projects". That resolved the compiler related errors:

[cmake] -- Check for working C compiler: C:/mingw64/bin/gcc.exe - skipped
[cmake] -- Check for working CXX compiler: C:/mingw64/bin/g++.exe - skipped

And I also didn't get the no such file or directory error. However, when I tried to continue with the rest of the instructions, at the C:\cmake\bin\cmake --build build -- install command, I got the mingw32-make: *** No rule to make target 'install'. Stop. error.

I see that there are two cmakes (cmake.exe and mingw32-make) and I was thinking that may be causing issues but I haven't found how I can fix that issue.

I am having issues building the GLM library. I am using Windows and VS Code. I have the following installed:

  • Mingw64 that includes gcc and g++ compilers
  • cmake

For GLM, as instructed in their readme:

  • I downloaded the latest release and extracted it to c:\glm

  • I navigated to the folder in the command prompt and ran the command

    C:\cmake\bin\cmake -DGLM_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -B build .
    
  • I got the following error:

    CMake Error in CMakeLists.txt:
      Running
    
       'nmake' '-?'
    
      failed with:
    
       no such file or directory
    
    
    CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
    CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
    

I tried with cmake-gui as well but I got the same error when I clicked configure.

I also have the cmake extension for VS Code so I tried configuring and building in VS Code, right clicking on the CmakeLists.txt and selecting "Clean Reconfigure All Projects". That resolved the compiler related errors:

[cmake] -- Check for working C compiler: C:/mingw64/bin/gcc.exe - skipped
[cmake] -- Check for working CXX compiler: C:/mingw64/bin/g++.exe - skipped

And I also didn't get the no such file or directory error. However, when I tried to continue with the rest of the instructions, at the C:\cmake\bin\cmake --build build -- install command, I got the mingw32-make: *** No rule to make target 'install'. Stop. error.

I see that there are two cmakes (cmake.exe and mingw32-make) and I was thinking that may be causing issues but I haven't found how I can fix that issue.

Share Improve this question edited Jan 18 at 17:15 genpfault 52.1k12 gold badges91 silver badges148 bronze badges asked Jan 18 at 17:13 Murat AykanatMurat Aykanat 1,7084 gold badges31 silver badges39 bronze badges 6
  • GLM is header-only, I think? Then you don't need to build it. – HolyBlackCat Commented Jan 18 at 17:31
  • 1 GLM project generates install target only when GLM_BUILD_INSTALL option is set. Check that you haven't disable that option. – Tsyvarev Commented Jan 18 at 17:35
  • 1 As for the first error about nmake, it is described in that question. As you could find, that error is absolutely unrelated to your install error, and by including both of them into the question post you only make your question confusing. – Tsyvarev Commented Jan 18 at 17:38
  • 1 To build with MinGW you needed to specify a different generator. It should not use nmake for MinGW. – drescherjm Commented Jan 18 at 17:51
  • You may want to use msys2 instead of your version of mingw64. VSCode recommends this. Anyways my second reason for recommending that is msys2 has glm in its repository so you wouldn't have to compile it yourself: https://packages.msys2.org/base/mingw-w64-glm you would instead use pacman to install the correct version for what msys2 environment you select. VSCode recommends ucrt64 in their official MinGW instructions: https://code.visualstudio.com/docs/cpp/config-mingw – drescherjm Commented Jan 18 at 17:55
 |  Show 1 more comment

1 Answer 1

Reset to default 0

I want to provide what I did to solve this per the comments of @Tsyvarev and @drescherjm

I downloaded the actual source from the GLM releases page

After unzipping the source, at the root of the source, I ran the commands:

C:\cmake\bin\cmake -DGLM_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -B build . -G "MinGW Makefiles"
C:\cmake\bin\cmake --build build -- all
C:\cmake\bin\cmake --build build -- install

Adding "MinGW Makefiles" resolved the "compiler variable not set" errors I was getting and since the source contained the GLM_BUILD_INSTALL, the install executed without errors.

发布评论

评论列表(0)

  1. 暂无评论