本文介绍了EGL链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图链接一个非常简单的GLES2&在Ubuntu Trusty系统上使用g ++ 4.9.1的EGL程序。我正在使用mesa库。

I'm trying to link a really simple GLES2 & EGL program using g++ 4.9.1, on a Ubuntu Trusty system. I'm using the mesa libraries.

我收到EGL函数的链接器错误:

I'm getting linker errors for EGL functions:

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'

我正在用

g++ -std=c++0x -Wall -Werror -lEGL -lGLESv2 -o test test.cpp

我尝试切换库的顺序,这有时很重要,但是我遇到同样的问题。有没有我在这里失踪的图书馆?

I've tried switching the order of libraries, which sometimes matters, but I get the same problem. Is there a library I'm missing here?

我运行了 readelf -Ws / usr / lib / x86_64-linux-gnu / mesa -egl / libEGL.so 并定义了所有必需的函数。

I've run readelf -Ws /usr/lib/x86_64-linux-gnu/mesa-egl/libEGL.so and all of the required functions are defined.

推荐答案

通过编译C ++文件到一个目标文件来解决这个问题,然后作为一个单独的步骤进行链接。我不确定为什么这种方法有效,而单行编译没有。

I managed to fix this by compiling the C++ file to an object file, and then linking as a separate step. I'm not sure why this works, when the one-line compilation doesn't.

g++ -std=c++0x -Wall -Werror -c -o test.o test.cpp
g++ -o test test.o -lGLESv2 -lEGL

我已将问题提交给社区试图弄清楚为什么:单命令编译和链接失败,单独的步骤工作

I've put the question to the community to try to figure out why: Single-command compile and link fails, separate steps work

这篇关于EGL链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 11:07