最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

c# - Can't compile beginners tutorial for GTK on Ubuntu 22.04 - Stack Overflow

matteradmin8PV0评论

This is my first stack post, so five me if the formatting etc's a bit off. Im following the beginners GTK tutorial near the end of this page Same issue mentioned here, except those users are on windows.

When I put mcs hello.cs -pkg:gtk-sharp-2.0 into the terminal, I get

Package gtk-sharp-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk-sharp-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk-sharp-2.0' found
error CS8027: Error running pkg-config. Check the above output.

I went on to try installing GTK 3 and 4 using:

sudo apt install libgtk-3-dev
sudo apt install libgtk-4-dev
sudo apt-get update
And tried the previous command with different versions, same output. Using dpkg -s libgtk-3-0 | grep 'Version' shows a version for GTK3, but says V 2 and 4 are not installed. 

Im finding more info about pkg-config, and where gtk-sharp should be.

Looking all over the internet and youtube, I noticed references to GTK, GTK+, GTK# etc, have I installed the wrong thing altogether?

This is my first stack post, so five me if the formatting etc's a bit off. Im following the beginners GTK tutorial near the end of this page Same issue mentioned here, except those users are on windows.

When I put mcs hello.cs -pkg:gtk-sharp-2.0 into the terminal, I get

Package gtk-sharp-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk-sharp-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk-sharp-2.0' found
error CS8027: Error running pkg-config. Check the above output.

I went on to try installing GTK 3 and 4 using:

sudo apt install libgtk-3-dev
sudo apt install libgtk-4-dev
sudo apt-get update
And tried the previous command with different versions, same output. Using dpkg -s libgtk-3-0 | grep 'Version' shows a version for GTK3, but says V 2 and 4 are not installed. 

Im finding more info about pkg-config, and where gtk-sharp should be.

Looking all over the internet and youtube, I noticed references to GTK, GTK+, GTK# etc, have I installed the wrong thing altogether?

Share Improve this question edited Nov 18, 2024 at 15:27 millerluki 3282 silver badges11 bronze badges asked Nov 18, 2024 at 13:27 RandomUserRandomUser 113 bronze badges 2
  • Two points: 1. You do not need two versions at once. Just libgtk-4-dev is enough. 2. Package name as it is known to apt and pkg-config differ. To see how the library is known to pkg-config, do pkg-config --list-all | grep gtk It will print all gtk related packages. – White Owl Commented Nov 18, 2024 at 14:37
  • gtk-dotnet-2.0 Gtk.DotNet - .NET Extensions for Gtk gtk-sharp-2.0 Gtk - Gtk gtk4 GTK - GTK Graphical UI Library gtk4-unix-print GTK - GTK Unix print support gtk4-wayland GTK - GTK Graphical UI Library gtk4-x11 GTK - GTK Graphical UI Library Strange, although not needed I thought we could have multiple versions installed? Ah well. I did find an anser, Ill add it in a sec. – RandomUser Commented Nov 18, 2024 at 20:04
Add a comment  | 

1 Answer 1

Reset to default 0

After reading a lot more I realised GTK, GTK+ and GTK# seem have some different components. I needed to specifically install GTK#, which I did with:

sudo apt install gtk-sharp2

The test script now builds with MCS. Hopefully that’s everything setup and good to go.

Post a comment

comment list (0)

  1. No comments so far