"couldn't create GLFW window" when cross-compiling for iMX6


#1

Hi there!

I’ve been trying for the past week to try to compile some of the examples of OF for the Toradex Apalis iMX6Q, which is based in NXP’s iMX6Q, and after dealing with all the Yocto Project dependencies and succesfully mounted the environment and compiled the examples, I’m having an issue when trying to run the examples.

The steps I followed are essentially the following:

  1. Downloaded the of_release for Linux armv7
  2. Generated the sdk from Yocto project used in Toradex’s Apalis iMX6. Found several missing dependencies. (glfw, boost…). Made my appropiate changes to the recipies, and added the dependencies.
  3. Compiled the examples with the SDK succesfully after setting the environment from the SDK plus the needed environmental variables for OF:
export RPI_ROOT=~/SDK/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi
export TOOLCHAIN_ROOT=~/SDK/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi
export PLATFORM_OS=Linux
export PLATFORM_ARCH=armv7l

I had an issue with atomic_base.h (atomic_base.h:514: error: undefined reference to ‘__atomic_fetch_add_8’
), which I solved by adding the flag “-latomic” to CC, CXX and CPP variables.

  1. Generated the image for the module/board.
  2. Some libraries where missing. Resolved those by adding them from my SDK (I need to check on why this are not added automatically in my image but it did the trick).
  3. SCP my example binary and get the error:
root@apalis-imx6:~# ./polygonExample 
[ error ] ofAppGLFWWindow: 65542: GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable
[ error ] ofAppGLFWWindow: couldn't create GLFW window
polygonExample: /usr/src/debug/glfw3/3.2-r0/git/src/window.c:411: glfwWindowShouldClose: Assertion `window != NULL' failed.
polygonExample: /usr/src/debug/glfw3/3.2-r0/git/src/window.c:420: glfwSetWindowShouldClose: Assertion `window != NULL' failed.
Aborted (core dumped)

I thought it could be OpenGL related issue so following this documentation from Toradex, I got the libraries from NXP but still nothing.

I have X perfectly running and I tried compiling a simple HelloWorld window from GLFW which worked.

I’m completely new to OF (and OpenGL, really). I thought that I had the needed OpenGL dependencies, but am I missing something?

The issue is with ofSetupOpenGL as the following code shows the same issue:

#include "ofMain.h"
//#include "ofApp.h"

//========================================================================
int main( ){
    ofSetupOpenGL(1024,768, OF_WINDOW);			// <-------- setup the GL context
	// this kicks off the running of my app
	// can be OF_WINDOW or OF_FULLSCREEN
	// pass in width and height too:
	//ofRunApp( new ofApp());
}

I tried to recompile the libraries I’m compiling against (currently, the examples are compiling against “of_v0.10.0_linuxarmv7l_release/libs/openFrameworksCompiled/lib”) in case is something of those but I couldn’t find any clear information on how to do so (Everything that I’ve seen uses precompiled libraries).

Thanks for any help!

EDIT: I gave it a bit of extra thought and I think the issue is probably related that in my image, I’m not using GLX at all but, for some reason (probably because it is the default option), OF is trying to call GLX through OpenGL calls rather than EGL (that I do have).

I’m currently checking ofAppGLFWWindow.h and I see quite an interesting snippet, which I added some errors to check which ones are getting compiled:

#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI)
	virtual Display* getX11Display(){return nullptr;}
	virtual Window  getX11Window() {return 0;}
	1
#endif

#if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES)
	virtual GLXContext getGLXContext(){return 0;}
	2
#endif

#if defined(TARGET_LINUX) && defined(TARGET_OPENGLES)
	virtual EGLDisplay getEGLDisplay(){return 0;}
	virtual EGLContext getEGLContext(){return 0;}
	virtual EGLSurface getEGLSurface(){return 0;}
	3
#endif

#if defined(TARGET_OSX)
	virtual void * getNSGLContext(){return nullptr;}
	virtual void * getCocoaWindow(){return nullptr;}
#endif

#if defined(TARGET_WIN32)
	virtual HGLRC getWGLContext(){return 0;}
	virtual HWND getWin32Window(){return 0;}
#endif

Which I get what I expected:
The 1 and 3 are getting called and nothing about 2, which makes sense as I don’t want to use GLX. But then, for some reason, instead of using EGL when trying to launch the application, is trying to use GLX calls, right?


Use only EGL/Disabling GLX calls
#2

So I posted a more particular question here. Another solution is to try to use Wayland instead of X11 but that is overall, much more painful, so I’d rather leave it as the ultimate solution.