0
votes

I am trying to compile a simple tutorial program utilising glfw with minimal opengl. My issue appears to be that the glfw library is stubbornly refusing to be dynamically linked. The relevant make command is:

"C:\Program Files\mingw-w64\mingw64\bin\g++" -Wall -m64 -D GLFW_DLL -l opengl32 -l glfw3 main.o -o triangle <br />

The main.o file is compiled from a c++ file, main.cpp by:

"C:\Program Files\mingw-w64\mingw64\bin\g++" -c -Wall -m64 -D GLFW_DLL main.cpp -o main.o 

Every reference to the glfw functions made inside the code is causing an undefined reference to the relevant implementation functions (eg. __imp_glfwInit for glfwInit => undefined reference to '__imp_glfwInit')
Build system is mingw-w64 [windows] using make via the command line, with glfw 3.0.4. The glfw lib is 64 bit and the latest stable build avaliable. It consists of the files:

  • glfw3.dll
  • glfw3dll.a
  • libglfw3.a
    Which are the 'WIN-64' 'lib-mingw'

    After extensive searches (GLFW help pages useless[deal either with 2.7.2 which doesn't apply or doesn't have useful information in the case of 3.0.4], most of stackoverflow deals with static linking, ect) I have been unable to find a solution which works.

    Is there something I am missing dealing with the linker that is not making me able to dynamically link?
    Clarification on any errors I am making or a solution of some form that would still allow me to use the dynamic libraries would be greatly appreciated
1

1 Answers

1
votes

It appears that the provided files do not work with mingw-w64, and are only compatible with 64bit mingw. Thus the only option left is linking against the dll (with thanks to greatwolf: https://stackoverflow.com/a/17734362/2396393). The code to compile to objects thus became:

"C:\Program Files\mingw-w64\mingw64\bin\g++" -Wall -m64 -D GLFW_DLL main.o -o triangle ./lib/glfw3.dll -l opengl32 

Where the dll glfw3 is located in the lib folder