admin管理员组

文章数量:1434960

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.

本文标签: cCan39t compile beginners tutorial for GTK on Ubuntu 2204Stack Overflow