简体   繁体   English

C - 在 Makefile MinGW32 - Windows10 中静态链接 GLFW

[英]C - Staticaly link GLFW in Makefile MinGW32 - Windows10

It is my first time trying to link external libraries to a C file.这是我第一次尝试将外部库链接到 C 文件。 I read that I can use a Makefile and this is what I have:我读到我可以使用 Makefile 这就是我所拥有的:

all: src/main.c
    gcc src/main.c -o main.exe -IC:\src\C\GameTry\dependencies\include -LC:\src\C\GameTry\dependencies\lib -lglfw3 -lgdi32 -lglew32s

clean:
    rm *.o

The reason I included -lgdi32 is beacuse the official glfw documentation states that:我包含-lgdi32的原因是因为官方 glfw 文档指出:

When using MinGW to link an application with the static version of GLFW, you must also explicitly link with gdi32使用 MinGW 将应用程序与 static 版本的 GLFW 链接时,您还必须显式链接 gdi32

This makefile works but OpenGL throws the warning corrupt.drectve at end of def file repeatedly many times and it throws undefined reference to '__security_cookie' error may times aswell which causes the program to not compile.此 makefile 有效,但 OpenGL corrupt.drectve at end of def file并且它抛出undefined reference to '__security_cookie'也可能多次导致程序无法编译。 I have looked all arround the internet and haven't been able to find an answer.我已经在互联网上四处寻找,但无法找到答案。 I believe these errors have something to do with the default MSVN libraries but I'm not sure我相信这些错误与默认的 MSVN 库有关,但我不确定

VScode 终端错误

If you have libglfw3.a that matches your compiler and platform (make sure to not mix win32 and win64), then a .def file should not be needed.如果您的libglfw3.a与您的编译器和平台相匹配(确保不要混合使用 win32 和 win64),则不需要.def文件。

Somehow the linker is picking up a .def file anyway. linker 无论如何都会以某种方式获取.def文件。

If there is a .def for glfw3, can you try to remove or rename it and try again?如果 glfw3 有.def ,您可以尝试删除或重命名它并重试吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM