GLFW 编译未定义的引用[重复]

2024-01-25

当我尝试编译我的简单 OpenGl 程序时,我收到未定义的引用,但我不知道为什么,我虽然我的所有设置都正确,但我想不是。有人可以帮我解决我的问题吗?

My Code:

#include <GL\glew.H>
#include <GLFW\glfw3.h>

int         windowWidth  = 980;
int         windowHeight = 640;

int Main()
{
    if (!glfwInit())
        return -1;

    glfwWindowHint(GLFW_SAMPLES, 4); // AA
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    GLFWwindow* window = NULL;

    window = glfwCreateWindow(windowWidth, windowHeight, "Window", NULL, NULL);

    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);
}

控制台消息:

"/C/Development/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/Callum/Documents/NetBeansProjects/Game'
"/C/Development/MinGW/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/game.exe
make.exe[2]: Entering directory `/c/Users/Callum/Documents/NetBeansProjects/Game'
mkdir -p dist/Debug/MinGW-Windows
g++     -o dist/Debug/MinGW-Windows/game build/Debug/MinGW-Windows/main.o -L../../../../../Development/glew\ 1.11.0/lib -L../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw -lglew32 -lglfw3
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(window.c.obj):window.c:(.text+0x5fa): undefined reference to `glClear@4'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(context.c.obj):context.c:(.text+0x41): undefined reference to `glGetIntegerv@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(context.c.obj):context.c:(.text+0xb8): undefined reference to `glGetString@4'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(context.c.obj):context.c:(.text+0x608): undefined reference to `glGetString@4'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(context.c.obj):context.c:(.text+0x76f): undefined reference to `glGetIntegerv@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(context.c.obj):context.c:(.text+0x7b9): undefined reference to `glGetIntegerv@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(context.c.obj):context.c:(.text+0x856): undefined reference to `glGetIntegerv@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x30a): undefined reference to `_imp__CreateDCW@16'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x356): undefined reference to `_imp__GetDeviceCaps@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x3a2): undefined reference to `_imp__DeleteDC@4'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(win32_gamma.c.obj):win32_gamma.c:(.text+0x7b): undefined reference to `_imp__CreateDCW@16'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(win32_gamma.c.obj):win32_gamma.c:(.text+0x91): undefined reference to `_imp__GetDeviceGammaRamp@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(win32_gamma.c.obj):win32_gamma.c:(.text+0x9d): undefined reference to `_imp__DeleteDC@4'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(win32_gamma.c.obj):win32_gamma.c:(.text+0x35b): undefined reference to `_imp__CreateDCW@16'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(win32_gamma.c.obj):win32_gamma.c:(.text+0x36d): undefined reference to `_imp__SetDeviceGammaRamp@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(win32_gamma.c.obj):win32_gamma.c:(.text+0x379): undefined reference to `_imp__DeleteDC@4'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x13b): undefined reference to `_imp__DescribePixelFormat@16'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x926): undefined reference to `_imp__DescribePixelFormat@16'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xa5e): undefined reference to `_imp__DescribePixelFormat@16'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xa80): undefined reference to `_imp__SetPixelFormat@12'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xbaf): undefined reference to `_imp__wglMakeCurrent@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xbca): undefined reference to `_imp__wglGetProcAddress@4'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x10d1): undefined reference to `_imp__wglCreateContext@4'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x10ff): undefined reference to `_imp__wglShareLists@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x1337): undefined reference to `_imp__wglDeleteContext@4'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x14d1): undefined reference to `_imp__wglMakeCurrent@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x1503): undefined reference to `_imp__wglMakeCurrent@8'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x1542): undefined reference to `_imp__SwapBuffers@4'
../../../../../Development/glfw-3.0.4.bin.WIN32/lib-mingw/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x165d): undefined reference to `_imp__wglGetProcAddress@4'
c:/development/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW-Windows/game.exe] Error 1
make.exe[2]: Leaving directory `/c/Users/Callum/Documents/NetBeansProjects/Game'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/Callum/Documents/NetBeansProjects/Game'
make.exe": *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 3s)

以下是我的设置的一些屏幕截图:

https://i.stack.imgur.com/jNtu2.png https://i.stack.imgur.com/jNtu2.png


您需要链接到 OpenGL 库:libopengl32.a,所以你想添加-lopengl32到你的构建命令,或者opengl32到您的 IDE 库。您还应该链接到gdi32以及。 (-lgdi32)

Source: http://www.glfw.org/docs/latest/build.html#build_link http://www.glfw.org/docs/latest/build.html#build_link

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

GLFW 编译未定义的引用[重复] 的相关文章

  • C++ 维护子类对象的混合集合

    如果我在这里错过了一个相当基本的概念 我很抱歉 但我正在尝试弄清楚如何维护多个类类型的集合 所有类类型都派生自同一个父类 并且在检索它们时仍然可以访问它们的特定于子类的方法从集合中 作为上下文 我有一个基类 BaseClass 和许多类 例
  • 静态只读字符串数组

    我在我的 Web 应用程序中使用静态只读字符串数组 基本上数组有错误代码 我将所有类似的错误代码保存在一个数组中并检查该数组 而不是检查不同常量字符串中的每个错误代码 like public static readonly string m
  • C++ 是否可以在 MacOS 上与 OpenMP 和 boost 兼容?

    我现在已经尝试了很多事情并得出了一些结论 也许 我监督了一些事情 但似乎我无法完成我想要的事情 问题是 是否有可能使用 OpenMP 和 boost 在 MacOS High Sierra 上编译 C 一些发现 如果我错了请纠正我 Open
  • 查找进程的完整路径

    我已经编写了 C 控制台应用程序 当我启动应用程序时 不使用cmd 我可以看到它列在任务管理器的进程列表中 现在我需要编写另一个应用程序 在其中我需要查找以前的应用程序是否正在运行 我知道应用程序名称和路径 所以我已将管理对象搜索器查询写入
  • JNI 将 Char* 2D 数组传递给 JAVA 代码

    我想从 C 代码通过 JNI 层传递以下指针数组 char result MAXTEST MAXRESPONSE 12 12 8 3 29 70 5 2 42 42 在java代码中我写了以下声明 public static native
  • Visual Studio 在构建后显示假错误

    我使用的是 Visual Studio 2017 构建后 sln在调试模式下 我收到错误 但是 当我通过双击错误列表选项卡中的错误来访问错误时 错误会从页面中消失 并且错误数量也会减少 我不太确定这种行为以及为什么会发生这种情况 有超过 2
  • 对 std::vector 进行排序但忽略某个数字

    我有一个std vector
  • IQueryable 单元或集成测试

    我有一个 Web api 并且公开了一个端点 如下所示 api 假期 name name 这是 Web api 的控制器 get 方法 public IQueryable
  • 在视口中查找 WPF 控件

    Updated 这可能是一个简单或复杂的问题 但在 wpf 中 我有一个列表框 我用一个填充数据模板从列表中 有没有办法找出特定的数据模板项位于视口中 即我已滚动到其位置并且可以查看 目前我连接到了 listbox ScrollChange
  • 为什么我的单选按钮不起作用?

    我正在 Visual C 2005 中开发 MFC 对话框应用程序 我的单选按钮是 m Small m Medium 和 m Large 它们都没有在我的 m Summary 编辑框中显示应有的内容 可能出什么问题了 这是我的代码 Pizz
  • 检测到严重错误 c0000374 - C++ dll 将已分配内存的指针返回到 C#

    我有一个 c dll 它为我的主 c 应用程序提供一些功能 在这里 我尝试读取一个文件 将其加载到内存 然后返回一些信息 例如加载数据的指针和内存块的计数到 c Dll 成功将文件读取到内存 但在返回主应用程序时 程序由于堆损坏而崩溃 检测
  • WPF DataGridTemplateColumn 组合框更新所有行

    我有这个 XAML 它从 ItemSource 是枚举的组合框中选择一个值 我使用的教程是 http www c sharpcorner com uploadfile dpatra combobox in datagrid in wpf h
  • 在屏幕上获取字符

    我浏览了 NCurses 函数列表 似乎找不到返回已打印在屏幕上的字符的函数 每个字符单元格中存储的字符是否有可访问的值 如果没有的话Windows终端有类似的功能吗 我想用它来替换屏幕上某个值的所有字符 例如 所有a s 具有不同的特征
  • 打印大型 WPF 用户控件

    我有一个巨大的数据 我想使用 WPF 打印 我发现WPF提供了一个PrintDialog PrintVisual用于打印派生的任何 WPF 控件的方法Visual class PrintVisual只会打印一页 因此我需要缩放控件以适合页面
  • C++ new * char 不为空

    我有一个问题 我在 ASIO 中开发服务器 数据包采用尖头字符 当我创建新字符时 例如char buffer new char 128 我必须手动将其清理为空 By for int i 0 i lt 128 i buffer i 0x00
  • String.Empty 与 "" [重复]

    这个问题在这里已经有答案了 可能的重复 String Empty 和 有什么区别 https stackoverflow com questions 151472 what is the difference between string
  • 使用 omp_set_num_threads() 将线程数设置为 2,但 omp_get_num_threads() 返回 1

    我有以下使用 OpenMP 的 C C 代码 int nProcessors omp get max threads if argv 4 NULL printf argv 4 s n argv 4 nProcessors atoi argv
  • 为boost python编译的.so找不到模块

    我正在尝试将 C 代码包装到 python 中 只需一个类即可导出两个函数 我编译为map so 当我尝试时import map得到像噪音一样的错误 Traceback most recent call last File
  • Objective-C / C 给出枚举默认值

    我在某处读到过关于给枚举默认值的内容 如下所示 typedef enum MarketNavigationTypeNone 0 MarketNavigationTypeHeirachy 1 MarketNavigationTypeMarke
  • 如何将十六进制字符串转换为无符号长整型?

    我有以下十六进制值 CString str str T FFF000 如何将其转换为unsigned long 您可以使用strtol作用于常规 C 字符串的函数 它使用指定的基数将字符串转换为 long long l strtol str

随机推荐