gpt4 book ai didi

c++ - OpenGL SOIL 未定义对 glBindTexture、glTexImage2d 等的引用

转载 作者:行者123 更新时间:2023-11-28 07:28:35 25 4
gpt4 key购买 nike

我正在使用 C++ 和 Opengl,我正在尝试使用 SOIL,但是当我编译时,我得到了对 glBindTexture、glTexImage2D 等的 undefined reference 。但是,这仅来自 SOIL.c,而不是我自己的源代码。这是错误产生的内容:

http://pastebin.com/sKrQaBhz

我的显卡是 NVIDIA GeForce GTX 680,我的驱动程序已完全更新。我已将所有内容链接起来,并且正在使用 premake 来管理我的项目。我正在 linux 机器上开发,但是,我试图将它交叉编译到我的 windows 机器上,这会出现此错误。如果我在 linux 上编译它,那就完全没问题了。这是我的 premake4.lua 文件:

http://pastebin.com/T4hsbdz0

我的包含文件是这样的:

#include "opengl/gl_core_3_3.hpp"
#include <GLFW/glfw3.h>
#include <SOIL/SOIL.h>
#include <glm/glm.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include "loadshader.hpp"

我正在使用 mingw32 来编译我的代码。在我使用 SOIL 之前,一切都很好。我从他们位于 lonesock.net 的网页上下载了 SOIL,然后将其复制到 libSOIL.a 及其包含文件中,但它就是不起作用。

最佳答案

链接顺序对 g++ 很重要。试试这个顺序:

links { "SOIL", "glfw3", "opengl32", "gdi32", "glu32" }

(编辑:根据 Premake 论坛中的重复问题修复了 OP 答案:http://industriousone.com/topic/how-use-premake-compile-static-library)

关于c++ - OpenGL SOIL 未定义对 glBindTexture、glTexImage2d 等的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18238729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com