为什么通过apt-get安装glfw工作但手动编译失败

时间:2018-02-27 20:49:26

标签: c ubuntu opengl glfw

我尝试在ubuntu 16中安装glfw3。我首先按照glfw docs中的说明进行操作:下载了glfw的源代码,通过设置将其构建到共享库中

cmake -DBUILD_SHARED_LIBS=ON 

并输入以下命令安装:

sudo make install

但安装失败了。当我尝试编译找到there的示例代码时,出现了一些未定义的引用错误:

undefined reference to `glfwSetErrorCallback'
undefined reference to `glfwInit'
undefined reference to `glfwWindowHint'
undefined reference to `glfwWindowHint'
undefined reference to `glfwWindowHint'
undefined reference to `glfwWindowHint'
undefined reference to `glfwWindowHint'
undefined reference to `glfwCreateWindow'
undefined reference to `glfwTerminate'
undefined reference to `glfwSetKeyCallback'
undefined reference to `glfwMakeContextCurrent'
undefined reference to `glfwGetProcAddress'
undefined reference to `glfwTerminate'
undefined reference to `glfwGetFramebufferSize'
undefined reference to `glfwGetTime'
undefined reference to `glfwSwapBuffers'
undefined reference to `glfwPollEvents'
undefined reference to `glfwGetTime'
undefined reference to `glfwWindowShouldClose'
undefined reference to `glfwTerminate

我的编译命令是:

g++ glfwtest.c -lglfw -lGL

但是当我改变了我的方法,并通过键入:

直接使用apt-get安装了glfw3
sudo agt-get install libglwf3-dev

我的测试代码使用相同的编译命令成功编译。

有线,有谁知道为什么?

0 个答案:

没有答案