C++ glfw3中缺少glfw3特定引用
当我试图在(复制/粘贴到测试编译)上编译glfw3的示例代码时,我遇到了以下错误:C++ glfw3中缺少glfw3特定引用,c++,glfw,C++,Glfw,当我试图在(复制/粘贴到测试编译)上编译glfw3的示例代码时,我遇到了以下错误: /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): undefin
/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
如果我这样做,这将给我一系列与X11相关的错误。我想我以前用谷歌搜索解决过这个问题,所以我会尝试重新搜索错误。没有太多的结果,但有一个修复了它。与X11相关的错误听起来像是静态链接到GLFW。我正在使用
-lglfw3-lX11-lxf86vm-lpthread-lrt-lXrandr-lXi
成功地完成这项工作。