Fix build with clang on Windows
I noticed that the CMake build does not work on Widows, using clang. The error message was complaining about .rc files. I changed the CMakeLists.txt file, to only include those files with MSVC, and then it worked.
The issue seems similar to this: https://github.com/curl/curl/issues/7765 , where it has issues with the unicode copyright character
VALUE "LegalCopyright", "� 2002-2019 Nigel Stewart & Milan Ikits & Marcelo Magallon\0"
I suspect here: https://github.com/nigels-com/glew/blob/9fb23c3e61cbd2d581e33ff7d8579b572b38ee26/auto/src/glew.rc#L123-L124 -
it could either be replaced with (c), or a escaped unicode character with L"" by the looks of it.
I can confirm, that changing the .rc files solves the issue. Looks like the .rc files have been updated in the repo in commit 35d928bc77cc5d9515f06ca27ac6f86c0298feba (Fixed failing build on Windows when using LLVM). It was committed on 20 Feb 2022, but the latest release is from 10 Jan 2021.
So probably a new release would fix the issue.
Sorry for disappearing. Is there any chance for a new release with this fix included?
I encountered the same problem.
DEV ENV
compiler: llvm (clang/clang++) v20.1.6
std (headers): mingw v15.1.0
terminal: windows terminal
project generator: cmake v4.0.2
build system: ninja v1.12.1
shell: pwsh v7.5.1
package manager: scoop
machine: windows 10
steps to replicate
- git clone https://github.com/nigels-com/glew.git
- cd to project directory
- cd to build directory
- cmake build
cmake -S .\cmake -B build -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_C_COMPILER_TARGET=x86_64-windows_gnu -DCMAKE_CXX_COMPILER_TARGET=x86_64-windows_gnu -DCMAKE_POLICY_VERSION_MINIMUM="3.5" -DCMAKE_BUILD_TYPE=Debug && ninja -C build
gives me error such as
CMake Error at CMakeLists.txt:114 (add_library):
Cannot find source file:
I tried this solution and this doesn't seem work. (errors is more of missing headers and source files) by looking at auto directory this is likely to be solve by running make -C auto
@nigels-com is there a reason for not doing this inside cmake ?
@rudolfheszele assuming this will be under native windows only (no msys) like mine, this likely wouldn't work either
doing make -C auto gives me error
process_begin: CreateProcess(NULL, touch OpenGL-Registry/.dummy, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:97: OpenGL-Registry/.dummy] Error 2
I think this is more of issue#363
I resolve it by building it from the release snapshot reference
- download release snapshot
- extract (tgz, zip)
- cd to project directory
- cd to build directory
cmake -S .\cmake -B build -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_C_COMPILER_TARGET=x86_64-windows_gnu -DCMAKE_CXX_COMPILER_TARGET=x86_64-windows_gnu -DCMAKE_POLICY_VERSION_MINIMUM="3.5" -DCMAKE_BUILD_TYPE=Debug && ninja -C build
p.s. adjust the build script accordingly
The issue seems similar to this: curl/curl#7765 , where it has issues with the unicode copyright character
VALUE "LegalCopyright", "� 2002-2019 Nigel Stewart & Milan Ikits & Marcelo Magallon\0"I suspect here:
https://github.com/nigels-com/glew/blob/9fb23c3e61cbd2d581e33ff7d8579b572b38ee26/auto/src/glew.rc#L123-L124
it could either be replaced with
(c), or a escaped unicode character withL""by the looks of it.
I think this is more of issue#363
CMake Error at CMakeLists.txt:114 (add_library): Cannot find source file:I tried this solution and this doesn't seem work. (errors is more of missing headers and source files) by looking at auto directory this is likely to be solve by running
make -C auto@nigels-com is there a reason for not doing this inside cmake ?
The main reason is that the cmake setup is more portable (including MS Visual Studio or macOS XCode for example) than the GNU make, perl, bash setup for generating the GLEW sources. Over the years there has been the idea of migrating all the code generation to python, but a lack of progress.