我正在尝试使用Ubuntu可信系统上的g++ 4.9.1链接一个非常简单的GLES2和EGL程序。我使用的是mesa库。
我收到了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,并且定义了所有需要的函数。
发布于 2017-10-18 20:22:59
您应该将库放在命令行的末尾
g++ -std=c++0x -Wall -Werror -o test test.cpp -lEGL -lGLESv2发布于 2015-02-22 14:39:23
我设法修复了这个问题,方法是将C++文件编译为目标文件,然后作为单独的步骤进行链接。我不确定为什么这样做能行得通,而单行编译却不行。
g++ -std=c++0x -Wall -Werror -c -o test.o test.cpp
g++ -o test test.o -lGLESv2 -lEGL我已经向社区提出了这个问题,试图找出原因:Single-command compile and link fails, separate steps work
https://stackoverflow.com/questions/28655099
复制相似问题