Ant*_*ony 5 g++ opengl-es-2.0 egl
我正在尝试在 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'
Run Code Online (Sandbox Code Playgroud)
我正在编译 test.cpp
g++ -std=c++0x -Wall -Werror -lEGL -lGLESv2 -o test test.cpp
Run Code Online (Sandbox Code Playgroud)
我试过切换库的顺序,这有时很重要,但我遇到了同样的问题。这里有我缺少的图书馆吗?
我已经运行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
Run Code Online (Sandbox Code Playgroud)
我已向社区提出问题,试图找出原因:单命令编译和链接失败,单独的步骤有效
小智 5
您应该将库放在命令行的末尾
g++ -std=c++0x -Wall -Werror -o test test.cpp -lEGL -lGLESv2
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5458 次 |
最近记录: |