如何与OpenGL交叉编译UnixBench?

时间:2017-04-25 03:11:01

标签: c++ opengl opengl-es cross-compiling

我已成功将UnixBench GRAPHIC_TESTS安装到iMX6 Yocto中。 Previous question.

当我尝试启用GRAPHIC_TESTS时,我收到了此错误:

fatal error: GL/gl.h: No such file or directory

所以我将opengl include path添加到Makefile中,如下所示:

CFLAGS = \
 -I/opt/poky/1.6.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include \
 -march=armv7-a -mtune=cortex-a9

freescale 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

1 个答案:

答案 0 :(得分:1)

看起来您正在尝试为OpenGL ES平台编译OpenGL代码;两者不兼容,所以不会起作用。