如何在Ubuntu上安装gtk开发依赖项?

时间:2022-06-28 06:52:15

I have the code from GTK tutorial in base.c.

我在base.c中有来自GTK教程的代码。

I am working on Ubuntu and when I compile using

我正在使用Ubuntu,当我编译使用时

$ gcc base.c -o base `pkg-config --cflags --libs gtk+-2.0` 

I get the following error

我收到以下错误

Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
base.c:1:20: fatal error: gtk/gtk.h: No such file or directory compilation terminated.

Being new to linux, can someone help me in setting up the environment so that I can compile/run the program successfully?

作为Linux的新手,有人可以帮助我设置环境,以便我可以成功编译/运行程序吗?

1 个解决方案

#1


48  

$ sudo apt-get install libgtk2.0-dev

Generally speaking to build things based on libfoo, you need libfoo-dev.

一般来说,基于libfoo构建东西,你需要libfoo-dev。

In addition, to install anything that is needed to build a package, say gedit, you can run:

另外,要安装构建软件包所需的任何东西,比如说gedit,你可以运行:

$ sudo apt-get build-dep gedit

Searching http://packages.ubuntu.com/ or Synaptic can help.

搜索http://packages.ubuntu.com/或Synaptic可以提供帮助。

#1


48  

$ sudo apt-get install libgtk2.0-dev

Generally speaking to build things based on libfoo, you need libfoo-dev.

一般来说,基于libfoo构建东西,你需要libfoo-dev。

In addition, to install anything that is needed to build a package, say gedit, you can run:

另外,要安装构建软件包所需的任何东西,比如说gedit,你可以运行:

$ sudo apt-get build-dep gedit

Searching http://packages.ubuntu.com/ or Synaptic can help.

搜索http://packages.ubuntu.com/或Synaptic可以提供帮助。