使用MinGW设置GLFW [英] Setting up GLFW with MinGW

查看:354
本文介绍了使用MinGW设置GLFW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用GLFW学习OpenGL,但是遇到了一些问题.

I'm trying to learn OpenGL with GLFW, but I'm having some problems.

这是我的main.cpp:

This is my main.cpp:

#include <GL/glfw.h>

int main()
{
    glfwInit();
    glfwSleep( 1.0 );
    glfwTerminate();
}

这是我项目的文件夹结构:

This is my project's folder structure:

Project
+- glfw.dll
+- main.cpp

这是我提取GLFW文件的地方:

This is where I extracted the GLFW files:

MinGW
+- include
|   +- GL
|      +- glfw.h
+- lib
   +- libglfw.a
   +- libglfwdll.a

这就是我尝试构建程序的方式:

And this is how I try to build the program:

g++ main.cpp -o main.exe -lglfwdll

这些是我得到的错误:

C:\Users\Dark\AppData\Local\Temp\cc0ZgTVp.o:main.cpp:(.text+0xf): undefined reference to `_glfwInit'
C:\Users\Dark\AppData\Local\Temp\cc0ZgTVp.o:main.cpp:(.text+0x25): undefined reference to `_glfwSleep'
C:\Users\Dark\AppData\Local\Temp\cc0ZgTVp.o:main.cpp:(.text+0x2a): undefined reference to `_glfwTerminate'
collect2.exe: error: ld returned 1 exit status

我想念什么吗?

推荐答案

此处下载二进制文件根据您的环境.

Download the binaries here according to your environment.

Project
+- glfw3.dll (You can put it in System32 or SysWOW64 instead.)
+- main.cpp

MinGW
+- include
|   +- GLFW
|      +- glfw3.h
+- lib
   +- libglfw3.a
   +- libglfw3dll.a (Renamed from glfw3dll.a)

g++ -c main.cpp
g++ -o main.exe main.o -lglfw3dll -lopengl32

这篇关于使用MinGW设置GLFW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆