Adding gtk libraries in eclipse

I have a Colibri T20 and I am planning to program it using gtk libraries. I have seen in one of your post on developer site that you also use gtk with eclipse. I have tried searching for how to add gtk libraries in eclipse but I am not able to find good link.

I have installed gtk and glade and I am able to run and compile it alone but then how to add it in eclipse. Also I want to know that I followed Hello World program in linux tutorial on developer page. I want to know that I have setup my eclipse hello world project with gcc cross compiler so is it really possible to add gtk libraries with cross compiler. Because every result I have found on google is using the linux gcc. If yes then how to add them. Please point me to some useful links.

The following steps have to be followed.

  • Build and install the SDK as per the article in default path /usr/local/oecore-x86_64

  • Source the environment script in terminal. Note the space between the dot and rest of command.

    . /usr/local/oecore-x86_64/environment-setup-armv7at2hf-neon-angstrom-linux-gnueabi

  • Please make sure to launch Eclipse from the same terminal shell where you sourced the above script else project will not work.

    eclipse &

  • The basic instructions for Eclipse configuration are described here for a simple hello world project.
    Linux SDKs | Toradex Developer Center

After Step 4, some additional settings have to be specified depending on the library requirements, in this case gtk.

These properties are under
Project → Properties → C/C++ Build → Settings → Tool Settings

Currently these are the basic settings for any Eclipse gtk project assuming gtk±2.0

  • Cross GCC Compiler

Command: ${CC}

Miscellaneous → Other flags:

${CFLAGS} -c --sysroot=/usr/local/oecore/x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/ `/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/pkg-config --cflags gtk+-2.0`
  • Cross G++ Compiler

Command: ${CXX}

Miscellaneous → Other flags:

${CXXFLAGS} -c -std=c++98  --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/ `/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/pkg-config --cflags gtk+-2.0`

Note the use of pkg-config in this step and next.

  • Cross G++ Linker

Command: ${CXX}

Miscellaneous → Linker flags:

${LDFLAGS} `/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/pkg-config --libs gtk+-2.0`
  • Cross GCC Assembler

Command: ${AS}

I think there is some misunderstanding. I followed this tutorial and then I followed this tutorial and I am able to run and debug the hello world project on t20. Now I want to add the gtk library into the hello world cross compiler project. You described in about open embedded. pls correct me if i am wrong

OpenEmbedded is required to generate an SDK so that header files and libraries are available for cross compilation. Without an SDK it is not possible to have a correct setup for development of applications for the target beyond simple applications like hello world.

Please also have a look at this community post.

I studied the openembedded and I am building the complete toolchain. I actually have two system on which I have two setup the toolchain and sdk. Is it possible to just copy and paste the oe-core directory to the 2nd system because both the systems are same i.e. ubuntu 16.04 64bit (instead of downloading it again on 2nd system).

Is it possible to just copy and paste the oe-core directory to the 2nd system because both the systems are same i.e. ubuntu 16.04 64bit (instead of downloading it again on 2nd system).

It’s not the recommended way, please have a clean oe-core build setup. May be what we can reuse is the ‘downloads’ directory in the build where all the package sources are downloaded to.

does the sdk provided for default images of toradex have gtk libraries or do i need to add gtk libraries in the os?

I am using embedded linux v2.7 provided by toradex and the same sdk
kindly help,
S.Nishanth Kumar

gtk-2.0 and gtk-3.0 is included in the regular bsp and sdk. You can look for it using find . -name gtk in the SDK library.
Best regards,
Jaski

The configurations above are for gtk±2.0, what to do with gtk3.0 can i just change the last ?

Regards,
S.Nishanth

yeah in the cflags you put gtk+-3.0 instead of gtk2.0.