glfw3缺少特定于glfw3的引用

glfw3 specific refrences missing with glfw3

本文关键字:glfw3 引用      更新时间:2023-10-16

当我尝试在上编译glfw3的示例代码时http://www.glfw.org/documentation.html(复制/粘贴到测试编译),我得到了以下错误:

/tmp/ccCdEKoi.o: In function main':
example.cpp:(.text+0x38): undefined reference toglfwCreateWindow'
example.cpp:(.text+0x5b): undefined reference to glfwMakeContextCurrent'
example.cpp:(.text+0x7a): undefined reference toglfwWindowShouldClose'
collect2: error: ld returned 1 exit status

我使用g++ example.cpp -o example -lGL -lglfw进行编译,当我安装最新的glfw 3.0.2时,它安装得没有问题。

GLFW3默认构建为libglfw3,而不是像GLFW2那样构建libglfw。因此,您可能仍在链接您的GLFW2安装。

解决方案:

g++ example.cpp -o example -lGL -lglfw3