Gtk with colibri IMX8X and eclipse

Hello Everyone,
I would like to add GTK library to eclipse, i compiled the toradex reference multimedia image and built the SDK.
I struggle problem to integrate this SDK to Eclipse. I followed this tutorial and adapted with the new path of the sdk. When I try to compile my program I get this error :

15:41:25 **** Build of configuration Debug for project DP2018 ****
make all 
Building file: ../GUI/dilutionWindow.c
Invoking: Cross GCC Compiler
aarch64-tdx-linux-gcc  -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/tdx-xwayland/5.3.0/sysroots/aarch64-tdx-linux -O0 -g3 -Wall -O2 -pipe -g -feliminate-unused-debug-types  -c --sysroot=/opt/tdx-xwayland/5.3.0/sysroots/aarch64-tdx-linux/ `/opt/tdx-xwayland/5.3.0/sysroots/x86_64-tdxsdk-linux/usr/bin/pkg-config --cflags gtk+-3.0` -MMD -MP -MF"GUI/dilutionWindow.d" -MT"GUI/dilutionWindow.o" -o "GUI/dilutionWindow.o" "../GUI/dilutionWindow.c"
Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gl', required by 'epoxy', not found
In file included from ../GUI/../global.h:8,
                 from ../GUI/../dosing.h:13,
                 from ../GUI/dilutionWindow.h:9,
                 from ../GUI/dilutionWindow.c:11:
/opt/tdx-xwayland/5.3.0/sysroots/aarch64-tdx-linux/usr/include/gtk-3.0/gtk/gtk.h:30:10: fatal error: gdk/gdk.h: No such file or directory
GUI/subdir.mk:30: recipe for target 'GUI/dilutionWindow.o' failed
   30 | #include <gdk/gdk.h>
      |          ^~~~~~~~~~~
compilation terminated.
make: *** [GUI/dilutionWindow.o] Error 1
"make all" terminated with exit code 2. Build might be incomplete.

15:41:25 Build Failed. 3 errors, 0 warnings. (took 123ms)

I cannot find the gl package.
Would you have any tips to resolve this error ?

Hello @a.duytschaever and Welcome to the Toradex Community!

Could you describe us how you created the image and corresponding SDK? Please share all the changes to local.conf and other important files, thus we can reproduce the issue.

Thanks and best regards,
Jaski

Hello @jaski.tx
Thanks for your answer.
In order to create this image and SDK I followed this tutorial.
About the local.conf I added packages like this :

 IMAGE_INSTALL_append = " gtk+3 libzip-dev zlib zip php php-cgi lighttpd lighttpd-module-fastcgi"

you can find in attachment the whole local.conf file.

Thank you for your help

Best regards

Arthur Duytschaever

Hello @a.duytschaever,

Have you already checked this community answer: Adding gtk libraries in eclipse - Technical Support - Toradex Community
It seems to have solved a similar problem to yours.

Please try that and let us know if it worked!

Best regards,
Janani.

Hello @saijanani.tx,

Yes, I am already aware of this solution as I used it previously . It worked perfectly with the BSP/SDK 2.8 on Colibri IMX6.
Now I would like to do the same thing on Colibri IMX8X with the BSP/SDK 5.
I followed the same pattern to configure eclipse only updating the different required paths with the path of the new SDK .

In attachment you can find my build configuration on eclipse.

Best regards

Arthur Duytschaever

Hello @a.duytschaever,

Thank you for your reply. Then I think it could be a path issue.

Could you maybe check if you could locate the gdk.h in the sysroot directory?

find /opt/tdx-xwayland/5.3.0/sysroots/aarch64-tdx-linux -name gdk.h

And could you also try to locate

find /opt/tdx-xwayland/5.3.0/sysroots/aarch64-tdx-linux -name gl.pc

Because if you have GTK, you must also have these and the package should be included. And you might need to add the path to Eclipse?

Best Regards,
Janani

Hello @saijanani.tx,

Thanks for your answer.

When I try to locate gdk.h I have the following output, it seems the package is present

find /opt/tdx-xwayland/5.3.0/sysroots/aarch64-tdx-linux -name gdk.h

I am not sure how I can include it in eclipse, do you have any documentation/tips to do this ?

To the gl.pc file I have found nothing.

I already tried to run this command for gtk±3.0 and gdk-3.0

rd-5@rd5-Inspiron-5482:/opt/tdx-xwayland/5.3.0$ /opt/tdx-xwayland/5.3.0/sysroots/x86_64-tdxsdk-linux/usr/bin/pkg-config --cflags gdk-3.0

Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gl', required by 'epoxy', not found

rd-5@rd5-Inspiron-5482:/opt/tdx-xwayland/5.3.0$ /opt/tdx-xwayland/5.3.0/sysroots/x86_64-tdxsdk-linux/usr/bin/pkg-config --cflags gtk+-3.0

Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gl', required by 'epoxy', not found

I get the same error message.

Thanks for your help

Best regards

Arthur Duytschaever

Hi,

you could follow the instruction for including the path here: Setting Up Include Paths and Macros for C/C++ Indexer | The Eclipse Foundation

Hope this helps!!

Best Regards,
Janani

Hi @saijanani.tx ,
I have same problem with gtkmm:

$ pkg-config --libs --cflags gtkmm-3.0
Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gl', required by 'epoxy', not found

Are you found the solution?

Best regards,
Attila

Hello @neilim ,

Did you try to add the correct path from the steps above?
If you did and still face issues, could you maybe walk us through the steps that you took?

Best Regards,
Janani

Hello @saijanani.tx ,

Yes, I tried it. But I explain my situation:

I have apalis-imx8 with 5.4.0 tdx-xwayland and I built the Reference Multimedia Image with gtk+3 and gtkmm3 packages.

If I source my SDK, I got these:

 $ . /opt/tdx-xwayland/5.4.0/environment-setup-aarch64-tdx-linux

$ which pkg-config
/opt/tdx-xwayland/5.4.0/sysroots/x86_64-tdxsdk-linux/usr/bin/pkg-config

$ /opt/tdx-xwayland/5.4.0/sysroots/x86_64-tdxsdk-linux/usr/bin/pkg-config --cflags gtkmm-3.0
Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gl', required by 'epoxy', not found

But I tried this: Linux SDKs | Toradex Developer Center with steps above and my Eclipse console output:

make all 
Building file: ../main.cpp
Invoking: Cross G++ Compiler
aarch64-tdx-linux-g++  -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/tdx-xwayland/5.4.0/sysroots/aarch64-tdx-linux -O0 -g3 -Wall -O2 -pipe -g -feliminate-unused-debug-types  -c -std=c++98 --sysroot=/opt/tdx-xwayland/5.4.0/sysroots/aarch64-tdx-linux/ `/opt/tdx-xwayland/5.4.0/sysroots/x86_64-tdxsdk-linux/usr/bin/pkg-config --cflags gtkmm-3.0` -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.cpp"
Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gl', required by 'epoxy', not found
../main.cpp:7:10: fatal error: gtkmm.h: No such file or directory
    7 | #include <gtkmm.h>
      |          ^~~~~~~~~
compilation terminated.
make: *** [subdir.mk:20: main.o] Error 1
"make all" terminated with exit code 2. Build might be incomplete.

If I locate gdk.h:

$ find /opt/tdx-xwayland/5.4.0/sysroots/aarch64-tdx-linux -name gdk.h     
/opt/tdx-xwayland/5.4.0/sysroots/aarch64-tdx-linux/usr/include/gtk-3.0/gdk/gdk.h
/opt/tdx-xwayland/5.4.0/sysroots/aarch64-tdx-linux/usr/include/gtk-2.0/gdk/gdk.h

And if I locate gl.pc I have found nothing.

What should I do? Where does gl.pc come from?

Thanks for your help,
br,
neilim

In my opinion you want to build something that is impossible on 5.4 image
GL != GL ES

Dear @MariusM ,
Do you think I can’t use gtk and gtkmm on 5.4?

Hello @neilim,

To avoid the error I replace the following line in the epoxy.pc file :

Requires.private: gl egl

by

Requires.private: egl

For my case it seems to work but I’m not sure about the consequences, I still have a problem to configure my eclipse IDE…

Best regard

Arthur Duytschaever

Hello @a.duytschaever ,
Thank you for your answer. If I remove gl from this line, the pkg-config and a test compile works (but not tested on device).

$ $CXX main.cpp -o test `pkg-config --libs --cflags gtkmm-3.0` -O2

Where:

$ which $CXX
/opt/tdx-xwayland/5.4.0/sysroots/x86_64-tdxsdk-linux/usr/bin/aarch64-tdx-linux/aarch64-tdx-linux-g++

This is good but yes, with eclipse… (with a very simple main.cpp I have 11927 error and 1187 error - the main.cpp is 40 line :sweat_smile:)