How to compile GLFW with GCC

29 views Asked by At

I tried compiling GLFW with CMAKE and when I went to link against the .lib files with GCC I got a bunch of mingw errors. I believe this is because of compiler incompatibility. How do I compile GLFW with GCC/ Compile GLFW so my .lib files can be linked against using GCC.

File structure

GameEngine
     -[Core]
          -main.c
     -[Dependencies]
          -[GLFW]
               -[Include]
                    -[GLFW]
                         -glfw3.h
                         -glfw3native.h
               -[lib]
                    glfw3.lib
                    glfw3.pdb
     -build.bat

build.bat

@echo off

SET COMPILER_FLAGS= -I./Dependencies/GLFW/Include 
SET LINKER_FLAGS= -L./Dependencies/GLFW/lib -lopengl32 -lglfw3

gcc %COMPILER_FLAGS% -o foo.exe core/main.c %LINKER_FLAGS%

Errors

Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file

There are many more MinGW errors but I'll spare you

C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./Dependencies/GLFW/lib/glfw3.lib(glfw.dir/Debug/window.obj):(.text$mn+0x9d6): undefined reference to `__security_cookie'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./Dependencies/GLFW/lib/glfw3.lib(glfw.dir/Debug/window.obj):(.text$mn+0xd51): undefined reference to `_RTC_CheckStackVars'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./Dependencies/GLFW/lib/glfw3.lib(glfw.dir/Debug/window.obj):(.text$mn+0xd64): undefined reference to `__security_check_cookie'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./Dependencies/GLFW/lib/glfw3.lib(glfw.dir/Debug/window.obj):(.xdata+0x24): undefined reference to `__GSHandlerCheck'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./Dependencies/GLFW/lib/glfw3.lib(glfw.dir/Debug/window.obj):(.rtc$IMZ+0x0): undefined reference to `_RTC_InitBase'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./Dependencies/GLFW/lib/glfw3.lib(glfw.dir/Debug/window.obj):(.rtc$TMZ+0x0): undefined reference to `_RTC_Shutdown'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./Dependencies/GLFW/lib/glfw3.lib(glfw.dir/Debug/input.obj):(.text$mn+0x1c5a): undefined reference to `__security_cookie'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./Dependencies/GLFW/lib/glfw3.lib(glfw.dir/Debug/input.obj):(.text$mn+0x1db3): undefined reference to `__report_rangecheckfailure'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./Dependencies/GLFW/lib/glfw3.lib(glfw.dir/Debug/null_monitor.obj):(.xdata+0x74): undefined reference to `__GSHandlerCheck'
collect2.exe: error: ld returned 1 exit status
0

There are 0 answers