【问题标题】:Linux Mint Eclipse GLFW 3 Setup problemsLinux Mint Eclipse GLFW 3 设置问题
【发布时间】:2015-01-27 10:49:57
【问题描述】:

在我看来,我已经正确安装和配置了 GLFW 3, 否则我的编译器会告诉我。

glfw3.h 和 glfw3native.h 在 urs/local/include/GLFW/ 中。

libglfw3.a 在 urs/local/lib/ 中。

在 Eclipse 中,我在 Project Propreties->C/C++ Build->Settings->GCC C Linker->Libraries 中配置了以下值:GL、GLU、m、rt、pthread、m、glfw3、X11、Xxf86vm、 Xrandr 和 Xi。

在我的项目中,在 Test.c 我有以下测试代码:

/*
 ============================================================================
 Name        : Test.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
*/
#include <GLFW/glfw3.h>

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */

     if (!glfwInit())
         exit(EXIT_FAILURE);

    return EXIT_SUCCESS;
}

因此,在我看来,以及我在互联网上阅读的内容,这似乎是一个不错的设置。 当我编译它时,它给出了这个:

/usr/local/lib/libglfw3.a(window.c.o): In function `glfwCreateWindow':
window.c:(.text+0x724): undefined reference to `glClear'
//usr/local/lib/libglfw3.a(glx_context.c.o): In function `getFBConfigAttrib':
glx_context.c:(.text+0x4d): undefined reference to `glXGetFBConfigAttrib'
//usr/local/lib/libglfw3.a(glx_context.c.o): In function `chooseFBConfig':
glx_context.c:(.text+0x7a): undefined reference to `glXGetClientString'
glx_context.c:(.text+0xe5): undefined reference to `glXGetFBConfigs'
//usr/local/lib/libglfw3.a(glx_context.c.o): In function `createLegacyContext':
glx_context.c:(.text+0x41f): undefined reference to `glXCreateNewContext'

读到这里,我得出的结论是它没有找到 OpenGL,但是我之前已经制作了 OpenGL 项目并且它可以工作,那么为什么 GLFW 可以找到它呢? 谢谢。

【问题讨论】:

    标签: c linux eclipse glfw


    【解决方案1】:

    经过一番折腾,并祈祷这个问题在几个小时甚至几天内消失。我找到了解决方案……但我不完全理解为什么链接这么难。

    我所做的只是尝试不同的链接器库选项, 这个订单对我有用:

    -lglfw3 -lGL -lGLU -lX11 -Xxf86vm -lXrandr -lpthread -lXi -lm

    希望这对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-09
      • 2012-08-18
      相关资源
      最近更新 更多