This is my first question on this site. I am also very new to c++ and am not that great in english, so sorry for that. I know that there are a lot of questions on stackoverflow that sound like mine, but the answers don't seem to work. example: MinGW Linking GLFW gets errors
the link shows one of the many questions i've found. I've been searching for an answer for a couple of days now, so i decided to make an account.
I use windows 10 and have installed mingw correctly(i think). And for GLFW I used the 32-bit binaries from here: https://www.glfw.org/download.html
The code i used is the official example on the glfw page. It is as follows:
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
my mingw version(g++ --version):
g++ (MinGW.org GCC-6.3.0-1) 6.3.0
I've put the "GLFW" folder from the GLFW binaries into "C:\MinGW\include", which works perfectly.
And I've put the file "libglfw3.a" into "C:\MinGW\lib". I've also put the file "libglfw3dll.a" into "C:\MinGW\lib".
my cmd command:
g++ main.cpp -lglfw3 -lopengl32 -lgdi32
I also tried it with -luser32 -lkernel32 and -lmingw32, but all of them do nothing
I tried linking with the dll, by using "g++ main.cpp -lglfw3dll -lopengl32 -lgdi32" and moving the "glfw3.dll" into the project folder... and it worked, but i want to link it statically without the dll(if that is dumb or dosn't work please tell me).
The erorr i'm getting is this:
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(init.c.obj):init.c:(.text+0xb9): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(init.c.obj):init.c:(.text+0xda): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(init.c.obj):init.c:(.text+0x11c): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(init.c.obj):init.c:(.text+0x2bf): undefined reference to `__mingw_realloc'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(input.c.obj):input.c:(.text+0x1016): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(input.c.obj):input.c:(.text+0x1021): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(input.c.obj):input.c:(.text+0x102c): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(input.c.obj):input.c:(.text+0x240c): undefined reference to `__mingw_realloc'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(input.c.obj):input.c:(.text+0x17d6): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0xc2): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0xd0): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0xde): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0x114): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0x122): more undefined references to `__mingw_free' follow
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0x2bd): undefined reference to `__mingw_realloc'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0x392): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0x3a0): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0x3ae): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0x3e4): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0x3f2): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(monitor.c.obj):monitor.c:(.text+0x400): more undefined references to `__mingw_free' follow
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0xe46): undefined reference to `__mingw_realloc'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0xf31): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0xf69): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0xf7b): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x1fbc): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x23c9): undefined reference to `__mingw_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x505c): more undefined references to `__mingw_free' follow
collect2.exe: error: ld returned 1 exit status
As you can see the error has something to do with "__mingw_free", but i don't know what that is.
Again, this is my first post and I started learning c++ two weeks ago, so sorry if this is a dumb question... I hope you can help me, Thanks.