Skip to content

freeglut: fix static linking on MSVC#2669

Open
bitrunner wants to merge 1 commit intomesonbuild:masterfrom
bitrunner:freeglut-3.8.0-2
Open

freeglut: fix static linking on MSVC#2669
bitrunner wants to merge 1 commit intomesonbuild:masterfrom
bitrunner:freeglut-3.8.0-2

Conversation

@bitrunner
Copy link
Contributor

The -DFREEGLUT_LIB_PRAGMAS=0 compiler argument needs to be used when building freeglut as a static library on windows MSVC to avoid freeglut_std.h injecting a dependency on the non-existent freeglut_staticd.lib or freeglut_static.lib into the resultant libfreeglut.a via comment pragma. FREEGLUT_LIB_PRAGMAS only has relevance on Windows when building with MSVC, so this change makes it only defined in that context.

This fixes the following link error when using freeglut as a static library subproject with MSVC:
LINK : fatal error LNK1104: cannot open file 'freeglut_staticd.lib'

I tested this successfully building freeglut as a static and shared library subproject and linking it with an executable on windows and Linux.

The -DFREEGLUT_LIB_PRAGMAS=0 compiler argument needs to be used when
building freeglut as a static library on windows to avoid freeglut_std.h
injecting a dependency on the non-existent freeglut_staticd.lib into the
resultant libfreeglut.a via comment pragma.  FREEGLUT_LIB_PRAGMAS only
has relevance on Windows when building with MSVC, so it's only defined
in that context now.

This fixes the following link error when using freeglut as a static
library subproject with MSVC:
LINK : fatal error LNK1104: cannot open file 'freeglut_staticd.lib'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant