我已将没有UnixBench
的GRAPHIC_TESTS
成功安装到iMX6 Yocto中。 Previous question.
当我尝试启用GRAPHIC_TESTS
时,出现此错误:
fatal error: GL/gl.h: No such file or directory
所以我将opengl包含路径添加到Makefile中,如下所示:
CFLAGS = \
-I/opt/poky/1.6.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include \
-march=armv7-a -mtune=cortex-a9
飞思卡尔iMX6 yocto看起来不支持OpenGL。所以改变了这个:
# GL_LIBS = -lGL -lXext -lX11
# to this ↓
GL_LIBS = -lGLESv2 -lEGL -lGAL -lXext -lX11
并更改了源代码:
//#include <GL/gl.h>
//#include <GL/glx.h>
// to this ↓
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
然后我得到一个新的错误:
src/ubgears.c: In function 'gear':
src/ubgears.c:163:17: error: 'GL_FLAT' undeclared (first use in this function)
glShadeModel(GL_FLAT);
^
src/ubgears.c:163:17: note: each undeclared identifier is reported only once for each function it appears in
src/ubgears.c:168:12: error: 'GL_QUAD_STRIP' undeclared (first use in this function)
glBegin(GL_QUAD_STRIP);
^
src/ubgears.c:182:12: error: 'GL_QUADS' undeclared (first use in this function)
glBegin(GL_QUADS);
^
src/ubgears.c:267:17: error: 'GL_SMOOTH' undeclared (first use in this function)
glShadeModel(GL_SMOOTH);
^
src/ubgears.c: In function 'reshape':
src/ubgears.c:320:17: error: 'GL_PROJECTION' undeclared (first use in this function)
glMatrixMode(GL_PROJECTION);
^
src/ubgears.c:327:17: error: 'GL_MODELVIEW' undeclared (first use in this function)
glMatrixMode(GL_MODELVIEW);
^
src/ubgears.c: In function 'init':
src/ubgears.c:341:14: error: 'GL_LIGHT0' undeclared (first use in this function)
glLightfv(GL_LIGHT0, GL_POSITION, pos);
^
src/ubgears.c:341:25: error: 'GL_POSITION' undeclared (first use in this function)
glLightfv(GL_LIGHT0, GL_POSITION, pos);
^
src/ubgears.c:343:13: error: 'GL_LIGHTING' undeclared (first use in this function)
glEnable(GL_LIGHTING);
^
src/ubgears.c:349:21: error: 'GL_COMPILE' undeclared (first use in this function)
glNewList(gear1, GL_COMPILE);
^
src/ubgears.c:350:27: error: 'GL_AMBIENT_AND_DIFFUSE' undeclared (first use in this function)
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
^
src/ubgears.c:366:13: error: 'GL_NORMALIZE' undeclared (first use in this function)
glEnable(GL_NORMALIZE);
^
src/ubgears.c: At top level:
src/ubgears.c:378:30: error: unknown type name 'GLXContext'
Window *winRet, GLXContext *ctxRet)
^
src/ubgears.c: In function 'main':
src/ubgears.c:561:4: error: unknown type name 'GLXContext'
此代码可能仅用于OpenGL,而不用于OpenGLES。
如果有人对此有任何想法,请分享。
更新:
Yocto中有
glxgears -info
,我在here中检查了源代码。它是由OpenGL而不是OpenGL ES编写的! iMX6应该仅支持OpenGL ES。怎么运行的?解:
是我的错我指出了错误的OpenGL库和标头。
# GL_LIBS = -lGL -lXext -lX11
# to this ↓
GL_LIBS = -lXext -lX11 /work/fsl-release-bsp/build-x11/tmp/sysroots/imx6qsabresd/usr/lib/libGL.so
最佳答案
看起来您正在尝试为OpenGL ES平台编译OpenGL代码;两者不兼容,因此无法正常工作。
关于c++ - 如何通过OpenGL交叉编译UnixBench?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43600921/