Describe the bug
When I use x86-windows freeglut and build as Release/Win32, I get a link error "cannot open file 'freeglutd.lib'".
Environment
To Reproduce
Steps to reproduce the behavior:
Expected behavior
When build as Release, compiler should search for freeglut.lib, not freeglutd.lib.
BTW freeglut 3.2.0 is released, maybe it's time for an upgrade.
FYI - I have the same problem with x64-windows triplet. All release configurations built with freeglut with either system-wide or project only integration fail trying to link freeglutd.lib.
@LilyWangL @JackBoosY @theoractice
I think I found the issue, but how to fix, incorporate into a fix file I'm not sure. Researching it seem for MSVC the NDEBUG/DEBUG macros have to be defined before using them - the one that is, which is unique to MSVC (at least from my research on the internet ) is _DEBUG. So in the file include/GL/freeglut_std.h if I change lines 73 and 91 from:
#ifdef NDEBUG to:
#ifndef _DEBUG
then freeglut release links using the freeglut.lib and debug links using the freeglutd.lib as is expected.
Otherwise the ifdef NDEBUG is always false as its not defined in MSVC and both the release and debug versions link with the freeglutd.lib - thus anytime you use freeglut.dll in other projects the release links fail looking for freeglutd.lib.
Thank you and have a wonderful day.
So this is curious -- line 66 of freeglut_std.h:
/* Windows static library */
# if 1 //ifdef FREEGLUT_STATIC
Reverting that hack gets freeglut:x64-windows building successfully on my system (previously was failing to link freeglutd.lib as described by OP). Still waiting to see whether my ultimate goal of qt5:x64-windows will finally succeed...
FWIW, the ifndef _DEBUG vs ifdef NDEBUG thing made no difference in my case.
@calonx If you built dynamic freeglut, it should not be changed.
This place is changed because ports that depend on it may not include this macro FREEGLUT_STATIC, resulting in link errors.
@JackBoosY cc: @isanych
fix-debug-macro.patch and an updated portfile.cmake on my PC, and not sure what the current status is on github vcpkg.@timautry Please feel free to open a PR to fix it.
Thanks.