Building with OpenGL on Windows 11

Started by mwj12, Nov 05, 2025, 01:20 AM

Previous topic - Next topic

mwj12

*
Newbie
Posts: 26
Logged
I am trying to build with opengl=ON in Windows 11, but am getting the errors below. I have no problems with opengl=OFF.

C:\GGEMS\ggems>python setup.py build_ext --opengl=ON install --user
running build_ext
cmake C:\GGEMS\ggems -DCMAKE_BUILD_TYPE=Release -DOPENGL_VISUALIZATION=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=C:\GGEMS\ggems\build\lib.win-amd64-cpython-311
-- CUDA Toolkit: TRUE
-- CUDA Toolkit VERSION: 12.8.61
-- CUDA Toolkit INCLUDE DIRS: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8/include
-- CUDA Toolkit LIBRARY DIR: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8/lib/x64
CMake Error at C:/Program Files/CMake/share/cmake-4.2/Modules/FindPackageHandleStandardArgs.cmake:290 (message):
  Could NOT find GLFW3 (missing: GLFW3_LIBRARY)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-4.2/Modules/FindPackageHandleStandardArgs.cmake:654 (_FPHSA_FAILURE_MESSAGE)
  cmake-config/FindGLFW3.cmake:49 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:101 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
error: command 'C:\\Program Files\\CMake\\bin\\cmake.EXE' failed with exit code 1


The GGEMS v1.3 documentation instructs that GLFW should be installed in C:/Program Files (x86). I interpret this to mean there should be a folder C:\Program Files (x86)\GLFW that looks like below. Does it look right?

C:\GGEMS\ggems>dir "C:\Program Files (x86)\GLFW"
 Volume in drive C is OS
 Volume Serial Number is CC8D-AE76

 Directory of C:\Program Files (x86)\GLFW

11/04/2025  07:07 PM    <DIR>          .
11/04/2025  07:05 PM    <DIR>          ..
11/04/2025  05:36 PM    <DIR>          docs
11/04/2025  05:36 PM    <DIR>          include
11/04/2025  05:36 PM    <DIR>          lib-mingw-w64
11/04/2025  05:36 PM    <DIR>          lib-static-ucrt
11/04/2025  05:36 PM    <DIR>          lib-vc2013
11/04/2025  05:36 PM    <DIR>          lib-vc2015
11/04/2025  05:36 PM    <DIR>          lib-vc2017
11/04/2025  05:36 PM    <DIR>          lib-vc2019
11/04/2025  05:36 PM    <DIR>          lib-vc2022
11/04/2025  05:25 PM               904 LICENSE.md
11/04/2025  05:25 PM             2,557 README.md
               2 File(s)          3,461 bytes
              11 Dir(s)  367,315,611,648 bytes free

didier.benoit

Administrator
*****
Newbie
Posts: 18
Logged
At the moment CMake cannot find GLFW because it is probably missing the CMake configuration files that GLFW normally installs.
Even if you already have include/ and lib/, CMake requires the following files to be present:

C:\Program Files (x86)\GLFW\lib\cmake\glfw3\
    ├─ glfw3Config.cmake
    ├─ glfw3ConfigVersion.cmake
    └─ glfw3Targets.cmake

If this folder or these files are missing, then find_package(GLFW3) will always fail. GGEMS expects the CMake version of GLFW — not just the binaries.

Install GLFW from source using admin privilege

git clone https://github.com/glfw/glfw.git
cd glfw
cmake -B build -DCMAKE_BUILD_TYPE=Release  -DCMAKE_INSTALL_PREFIX="C:/Program Files (x86)/GLFW"
cmake --build build --config Release
cmake --install build --config Release

Optional: If you want to automatically add GLFW/GLEW to your environment in PowerShell:

function OpenGL-cmd {
    $env:Path    += ";C:\Program Files (x86)\GLFW\bin;C:\Program Files (x86)\GLEW\bin\Release\x64;"
    $env:Include += ";C:\Program Files (x86)\GLFW\include;C:\Program Files (x86)\GLEW\include;"
    $env:Lib     += ";C:\Program Files (x86)\GLFW\lib;C:\Program Files (x86)\GLEW\lib\Release\x64;"
}
Set-Alias -Name opengl -Value OpenGL-cmd

Then just type "opengl" in the terminal before building GGEMS. Let me know if you want the same instructions for GLEW or GLM.

mwj12

*
Newbie
Posts: 26
Logged
#2
Thanks, GLFW seems to have installed successfully.

I would indeed be grateful for similar instructions for GLEW and GLM. In particular, the GLEW repo referenced in the documentation
https://github.com/nigels-com/glew
does not appear to be CMake-friendly:

C:\Users\MWJ12\Downloads\glew-master\glew-master>cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="C:/Program Files (x86)/GLEW"
CMake Error: The source directory "C:/Users/MWJ12/Downloads/glew-master/glew-master" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

didier.benoit

Administrator
*****
Newbie
Posts: 18
Logged
Hi,

To use GLEW and GLM with GGEMS, please follow these steps:

- GLEW:
You simply need to install the official Windows binary from the GLEW website:
https://glew.sourceforge.net/
Direct download link: https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0-win32.zip/download
Once extracted and installed (typically under "C:/Program Files (x86)"), GLEW will be automatically detected by GGEMS during configuration, thanks to the FIND_PACKAGE(GLEW REQUIRED) command in CMake.
No manual CMake build of GLEW is needed on Windows.

- GLM:
You can install GLM by visiting the official repository:
https://github.com/g-truc/glm
Simply follow the installation recommendations provided there. GLM is a header-only library, so you usually just need to extract it and make sure its include path is visible to CMake.

Hope this helps and makes the setup smoother!