[BUG] Argus/Argus.h includes X11.h, which breaks everything

Hello! I have noticed a huge problem caused by Argus/Argus.h inclusion (in /usr/src/jetson_multimedia_api/argus/include), which redefines fundamental programming terms like Bool, None, KeyPress, etc

Here’s the include tree, which leads to the problem (starts from /usr/src/jetson_multimedia_api/include/Argus/Argus.h).
Argus/Argus.h -> Argus/Types.h -> EGL/egl.h -> EGL/eglplatform.hX11/Xlib.h and <X11/Xutil.h>

So Xlib.h and Xutil.h has prehistoric #define’s, like (I didn’t post all of them, there are many more):

...
#define Bool int
#define Status int
#define True 1
#define False 0
...
#define XValue  	0x0001
#define YValue		0x0002
#define WidthValue  	0x0004
#define HeightValue  	0x0008
...

So the problem is that any time something wants to do something with Bool, Status, XValue word, everything literally breaks, because X11 redefines it and is not namespaced. For example, the Qt framework uses them, so it’s literally impossible to compile Qt with Argus by default, if the Qt include uses any of these words in their code.

.

There is also a relatively simple solution to this, if you don’t need EGL display on X11.

There are actually 2 eglplatform.h files on Jetson by default. One is located in /usr/src/jetson_multimedia_api/include/EGL/eglplatform.h and the other one is /usr/include/EGL/eglplatform.h.

The one used by Argus include is in multimedia api folder, is older than the one in /usr/include folder and it actually has a fix for this problem (using X11)

/usr/src/jetson_multimedia_api/include/EGL/eglplatform.h file checks only if the device is __unix__ or __APPLE__ and always includes X11

#elif defined(__unix__) || defined(__APPLE__)

/* X11 (tentative)  */
#include <X11/Xlib.h>
#include <X11/Xutil.h>

typedef Display *EGLNativeDisplayType;
typedef Pixmap   EGLNativePixmapType;
typedef Window   EGLNativeWindowType;

however the /usr/include/EGL/eglplatform.hfile has an extra defines EGL_NO_X11 and USE_X11

#elif defined(__unix__) && defined(EGL_NO_X11)

typedef void             *EGLNativeDisplayType;
typedef khronos_uintptr_t EGLNativePixmapType;
typedef khronos_uintptr_t EGLNativeWindowType;

#elif defined(__unix__) || defined(USE_X11)

/* X11 (tentative)  */
#include <X11/Xlib.h>
#include <X11/Xutil.h>

typedef Display *EGLNativeDisplayType;
typedef Pixmap   EGLNativePixmapType;
typedef Window   EGLNativeWindowType;

#elif defined(__APPLE__)

typedef int   EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
typedef void *EGLNativeWindowType;

So the problem is solved by replacing /usr/src/jetson_multimedia_api/include/EGL/eglplatform.h with /usr/include/EGL/eglplatform.h and including #define EGL_NO_X11 in your code, which includes Argus/Argus.h

I hope that someone from Nvidia will see this and include the eglplatform.h replacement in an update or find a different solution to this problem.

Thanks!

Hi,
Thanks for reporting this. We will check it with our teams.

So after copying

/usr/include/EGL/eglplatform.h

to overwrite

/usr/src/jetson_multimedia_api/include/EGL/eglplatform.h

The Argus samples cannot be built. Have to add

#define EGL_NO_X11

to successfully build the samples. Is this correct?

Hello!

Samples can be built, however, if I’m using Argus in a project, that uses miscellaneous libraries/frameworks (like Qt), then project cannot be built because very generic terms like XValue, Status are redefined by X11, which is included by Argus.

I’m sure that there are many libraries that use these terms in their namespace. Excluding X11 via eglplatform.h using defined(EGL_NO_X11) fixes this as mentioned in the post.

Basically - you cannot include Argus without including X11 now.
Replacing the eglplatform.h adds a define, which can include Argus without X11.

The fundamental problem is that X11 is not namespaced, so defines override literally everything else you have in the project.

Hi,
The header files in 5.0.1 DP is updated. FYI.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.