Accessing anything GLEW related immediately crashes program in MinGW

北慕城南 提交于 2019-12-03 17:07:20
BDL

As I understood there are two questions to answer:

Why does my program crash when I include glewExperimental = GL_TRUE; but not when leaving it away?

Your program crashes because it cannot load the glew library. When you leave this line away, no call to glew is made and the program will most likely not even load it.

Why does my program not find glew32.dll although I copied it into the system32 folder?

If you have a 64-bit operating system, than system32 is the folder where the 64-bit dlls are placed. I know this sounds sic!, but that's how windows works. 32-bit libraries are located in SysWOW64. This SO-answer contains more details about this: why-do-64-bit-dlls-go-to-system32-and-32-bit-dlls-to-syswow64-on-64-bit-windows.

In general you should never place dlls somewhere in the windows folder. This folders are reserved for system libraries/system-wide libraries like drivers etc. The reason for this is, that you get into deep troubles if someone else copies another version of e.g. glew32.dll into the system folder, which will most probably crash you app. The best way to place your own libraries is in the directory your executable lies in.

I was able to resolve by adding the following line to CMakeLists.txt

add_definitions(-DGLEW_STATIC)

I do not understand why the above would work since, to my understanding the following would have had the same affect:

#define GLEW_STATIC
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!