linux - /usr/bin/ld: ../freeglut/libfreeglut_static.a(freeglut_state.o): 未定义对 Box2d 中符号“XGetWindowAttributes”的引用
问题描述
我遵循了这个,它向我展示了安装步骤。
我以前安装了依赖项。
unzip Box2D_v2.1.2.zip
cd Box2D_v2.1.2/Box2D/Build
cmake ..
make
在 make 的最后一步,我收到以下消息。
/usr/bin/ld: ../freeglut/libfreeglut_static.a(freeglut_state.o): undefined reference to symbol 'XGetWindowAttributes'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
我在网上搜索了每个人都说用-X11
标志编译,但这是一个 make 文件,我不太关心
解决方案
出现此错误是因为未为 Linux 配置CMakeLists.txt
文件。Testbed
要解决此问题,请打开文件Box2D_v2.1.2/Box2D/Testbed/CMakeLists.txt
并相应地更改以下行。
由此:
if(APPLE)
# We are not using the Apple's framework version, but X11's
include_directories( /usr/X11/include )
link_directories( /usr/X11/lib )
set (OPENGL_LIBRARIES GL GLU GLUT X11)
endif(APPLE)
对此:
if(UNIX)
# We are not using the Apple's framework version, but X11's
include_directories( /usr/X11/include )
link_directories( /usr/X11/lib )
set (OPENGL_LIBRARIES GL GLU X11)
endif(UNIX)
这对我有用。
推荐阅读
- javascript - Nuxt @onloadstart 不使用 beforeCreate 触发功能
- nestjs - 在 Nestjs 中禁用 X-Powered-By 不起作用
- variables - GitHub Actions:我可以为作业的环境字段使用变量吗?
- mysql - FileBeat 不提取 MySQL 日志?
- jquery - 如何使用 jquery(wordpress)用 span 标签包装部分文本?
- java - AWS IoT 客户端:MqttException:连接意外关闭
- excel - Excel 文档自定义数字格式
- python - 为什么顺序在这个链式分配中很重要?
- mysql - kafka sink 从 mysql 到 postgres
- raspberry-pi - 更新 wpa_supplicant.conf 树莓派