我正在尝试在 Ubuntu Trusty 系统上使用 g++ 4.9.1 链接一个非常简单的 GLES2 和 EGL 程序。我正在使用台面库。
我收到 EGL 函数的链接器错误:
test.cpp:(.text+0x342): undefined reference to `eglGetDisplay'
test.cpp:(.text+0x389): undefined reference to `eglInitialize'
test.cpp:(.text+0x40f): undefined reference to `eglCreateContext'
test.cpp:(.text+0x458): undefined reference to `eglCreatePbufferSurface'
test.cpp:(.text+0x49e): undefined reference to `eglMakeCurrent'
我正在编译 test.cpp
g++ -std=c++0x -Wall -Werror -lEGL -lGLESv2 -o test test.cpp
我尝试过切换库的顺序,这有时很重要,但我遇到了同样的问题。我在这里缺少图书馆吗?
我已经跑了readelf -Ws /usr/lib/x86_64-linux-gnu/mesa-egl/libEGL.so
并且定义了所有必需的功能。
我设法通过将 C++ 文件编译为目标文件,然后作为单独的步骤进行链接来解决此问题。我不知道为什么这会起作用,而单行编译却不起作用。
g++ -std=c++0x -Wall -Werror -c -o test.o test.cpp
g++ -o test test.o -lGLESv2 -lEGL
我已向社区提出问题,试图找出原因:单命令编译和链接失败,单独的步骤有效 https://stackoverflow.com/questions/28655328/single-command-compile-and-link-fails-separate-steps-work
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)