Describe the bug
Building OpenGL Examples with MSVC does not work.
To Reproduce
Steps to reproduce the behavior:
- Have glew2.2.0 win64 downloaded from:
https://sourceforge.net/projects/glew/files/glew/2.2.0/glew-2.2.0-win32.zip/download
- I unzipped it and the location of the x64 builds is in:
D:/code/lib/glew-2.2.0/bin/Release/x64
D:/code/lib/glew-2.2.0/lib/Release/x64
- I moved the .lib and .dlls to the main directories (from the standard MSVC dirs):
cd D:/code/lib/glew-2.2.0/bin/Release/x64
mv *.dll ../..
cd D:/code/lib/glew-2.2.0/lib/Release/x64
mv *.lib ../..
- I had to call cmake with all this (this needs work in the CMakeLists files):
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=D:/code/lib/glew-2.2.0 -DFLTK_BUILD_EXAMPLES=ON -DCMAKE_CXX_FLAGS=-ID:/code/lib/glew-2.2.0/include
CMake does find glew32.
CMake compiles properly.
- Error:
CMake does not link properly with the glew32.lib (DLL), getting errors like (maybe I am missing a preprocessor definition of the OpenGL3test is missing #include "windows.h"?
LINK: command "C:\PROGRA1\MICROS1\2022\COMMUN1\VC\Tools\MSVC\14391.335\bin\Hostx64\x64\link.exe /nologo examples\CMakeFiles\OpenGL3test.dir\OpenGL3test.cxx.obj /out:bin\examples\OpenGL3test.exe /implib:bin\examples\OpenGL3test.lib /pdb:bin\examples\OpenGL3test.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:windows -LIBPATH:D:\code\applications\mrv2\BUILD-Msys-amd64\Release\FLTK-prefix\src\FLTK\build\src..\lib lib\fltk_gl.lib D:\code\lib\glew-2.2.0\lib\glew32.lib opengl32.lib glu32.lib lib\fltk.lib comctl32.lib ws2_32.lib gdiplus.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:bin\examples\OpenGL3test.exe.manifest" failed (exit code 1120) with the following output:
OpenGL3test.cxx.obj : error LNK2019: símbolo externo __glewBindBuffer sin resolver al que se hace referencia en la función "public: virtual void __cdecl SimpleGL3Window::draw(void)" (?draw@SimpleGL3Window@@UEAAXXZ)
Workaround
Linking against the static glew32 (ie. glew32s) works.
diff --git a/CMake/resources.cmake b/CMake/resources.cmake
index e5d6f8c9f..e755f89db 100644
--- a/CMake/resources.cmake
+++ b/CMake/resources.cmake
@@ -152,7 +152,7 @@ endif((NOT APPLE) OR FLTK_BACKEND_X11)
find_library(LIB_freetype freetype)
find_library(LIB_GL GL)
find_library(LIB_MesaGL MesaGL)
-find_library(LIB_GLEW NAMES GLEW glew32)
+find_library(LIB_GLEW NAMES GLEW glew32s glew32)
find_library(LIB_jpeg jpeg)
find_library(LIB_png png)
find_library(LIB_zlib z)
However this prefers static builds instead of shared builds which is contrary to the normal behavior.
find_package(GLEW)
seems to solve the issue (at least on Windows) by having different target variables for static or shared builds.
Expected behavior
FLTK should allow a variable to get passed to find the GLEW library.
It should use find_package(GLEW) to find glew as it is more solid.
It should work with either static or shared (DLL) builds.
It should print out the location where GLEW was found.
FLTK Version
- Version: 1.4
- Downloaded and self-built from: Git
- If from Git, branch: master
FLTK Configure / Build Options
See steps to reproduce.
Operating System / Platform:
- OS: Windows
- OS Version: 11
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: <fltk/fltk/issues/959@github.com>
[ Direct Link to Message ] |