简体   繁体   中英

Type fatal error: gtk/gtk.h: No such file or directory during Eclipse (Oxygen) compilation

I've some errors compiling C code with GTK widgets in Eclipse, indicating that gtk/gtk.h cannot be found. I've already installed GTK+2 and GTK+3; and also included the header paths for GTK but it seems that the Eclipse environment is still unable to find the required header.

Greatly appreciate any advice from the community!

You didn't provide enough information to actually know what is going on, but I guess the include paths you configured are somehow wrong.

My advice would be that you should use pkg-config to obtain the correct compiler flags instead of adding include dirs etc. manually.

This will give you a list of all packages, pkg-config knows are installed on your machine:

pkg-config --list-all

The GTK package should be something like gtk+-3.0

Use this to get the CFLAGS for use with GTK3:

pkg-config --cflags gtk+-3.0

And here is how to get the libraries for the linker stage:

pkg-config --libs gtk+-3.0

So instead of doing something like this:

# Don't do this
gcc -I... main.c

... use something like this:

gcc $(pkg-config --cflags gtk+-3.0) ... main.c

Read the man page of pkg-config for more informations.

There was an Eclipse plugin for pkg-config support, but it doesn't seem to work with Oxygen. I managed to get a building example with these settings, though Eclipse itself won't find the includes.

编译器设定 链接器设置

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM