opengl - Undefined reference errors when linking GLFW with minGW gcc -


i trying develop opengl application glew , glfw on windows using mingw. in current directory, project/, have directories src/, bin/, , glfw-3.0.4.bin.win64/. have files test.cpp, glew.h, glew.c, , wglew.h in src/ directory.

the directory ./glfw-3.0.4.bin.win64/include/ contains glfw/glfw3.h header file.

the directory ./glfw-3.0.4.bin.win64/lib-mingw/ contains glfw3.dll, glfw3dll.a, , libglfw3.a.

my main file, test.cpp contains,

#include "glew.h" #include "glfw/glfw3.h"  #include <stdio.h>  int main(int argc, char** argv) {     printf("hello, world!\n");      glewinit();     glfwinit(); } 

i compiling program project/ directory running (split 2 lines readability)

gcc -dglew_static -dglfw_dll -o ./bin/test ./src/*.cpp ./src/glew.c  -i ./glfw-3.0.4.bin.win64/include/ -l ./glfw-3.0.4.bin.win64/lib-mingw/ -lglfw3 -lopengl32 

and getting following error:

undefined reference `_imp_glfwinit' 

i think problem has me linking glfw library incorrectly. understand, including compiler option -lglfw3 tell gcc link ./glfw-3.0.4.bin.win64/lib-mingw/glfw3.dll, contains definition glfwinit().

i've looked @ solutions other problems similar mine , suggest things such copying dll file source/binary directories , changing order of -l options, none have seemed solve problem me.

your problem gcc follows strict library naming conventions. attempts find glfw3.dll.a, finds none (because named glfw3dll.a - simple rename fix problem).

next step looks libglfw3.a, , succeeds - static library, while reference declared dynamic in header files (tricky windows declspecs... problem don't exist on e.g. linux). so, cannot find _imp__glfwinit, because in static library called glfwinit, getting error.

removing libglfw3.a 1 of options - in case gcc further , find glfw3.dll , use it.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -