glew icon indicating copy to clipboard operation
glew copied to clipboard

windows: static build fails on missing pdb file

Open leamas opened this issue 10 months ago • 1 comments

On windows, a static build fails in the install step with errors like:

CMake Error at libs/glew/glew_dir/cmake_install.cmake:55 (file): file INSTALL cannot find
"C:/project/opencpn/plugin_src/build/bin/RelWithDebInfo/glew32.pdb": File exists.

This is about the following snippet in CMakeLists.txt:

if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600) AND (NOT CMAKE_VERSION VERSION_LESS "3.1"))
    install(
        FILES $<TARGET_PDB_FILE:glew>
        DESTINATION ${CMAKE_INSTALL_LIBDIR}
        CONFIGURATIONS Debug RelWithDebInfo
    )
endif()

AFAICT <TARGET_PDB_FILE:glew> refers to the glew target which is the shared library even when doing a static build which makes the install command to fail (?)

Following patch against 2.2.0 makes the build to complete. I'm not convinced this is the correct solution, though.

diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt
index 419c243..2edf957 100644
--- a/build/cmake/CMakeLists.txt
+++ b/build/cmake/CMakeLists.txt
@@ -228,7 +228,10 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/glew.pc
         DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
 )
 
-if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600) AND (NOT CMAKE_VERSION VERSION_LESS "3.1"))
+if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600)
+   AND (NOT CMAKE_VERSION VERSION_LESS "3.1")
+   AND BUILD_SHARED_LIBS
+ )

EDIT: Fix the leading error message which was plain wrong.

leamas avatar May 12 '25 07:05 leamas

fwiw: I'm getting similar warnings (not using cmake) from msvc linker. Can the .pdb files be included?

glew32s.lib(glew.obj) : warning LNK4099: PDB '' was not found with 'glew32s.lib(glew.obj)' or at ''; linking object as if no debug info

Also, it'd be nice if the package included a debug static library to avoid the following warning in debug builds.

LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

(With debug build, defaultlib is LIBCMTD which conflicts with the included release mode static library LIBCMT.)

toptensoftware avatar Sep 30 '25 02:09 toptensoftware