0

I recently started using code::blocks on Linux (Linux Mint). I've been trying to install GTK and its dependencies for C++.

I started by downloading each of the dependencies as a .tar.xz file, and then extracting each one into a folder.

Then I went through a few online tutorials, which showed how to point the linker and the compiler to the correct file path, which is where they lost me.

In all these tutorials (which were all for windows, but I don't think that should make too much of a difference), there was either a .lib or similar file in the directory of the library, or there were two folders, one named "include" and the other named "lib" which you could point to. But for all of these libraries that I downloaded, I couldn't find either of those things.

Here you can see the file structure for Pango, one of the dependencies of GTK.

Is there anything really obvious that I'm missing? Did I download the wrong thing? What's going on?

6
  • 1
    Your question at the moment lacks to many details to give a good answer. Maybe you just made a small mistake when following the tutorials. It might help others here (I don't know codeblocks) if you provide the error messages you ar getting. Side note I prefer using build systems that can use package managers, these will download packages for you and setup install/link paths too (but I can't tell you what Ide + CMake + package manager will work best on Mint Linux) Commented Jun 22, 2025 at 18:50
  • I'm not entirely sure how to reply to this reply, I might be doing this wrong, Pepjin Kramer (I post on stack overflow much). But my issue isn't that I'm getting error messages, but that when I set up my Project Build Options, and I try to find the specific file that the linker and the compiler want, I can't find such a file. The files that the linker and the compiler appear to want, and that are shown in the tutorials, aren't present in the directories of the libraries that I have downloaded. I hope that clears things up a bit. Commented Jun 22, 2025 at 18:55
  • Probably you don't need to respond much, just trying to get some extra information (also for fellow readers) But you extracted those files to disk right? So you should know the paths. Did you also unzip the so files? In the end gtk is big with many dependencies ... so a package manager might still be your best bet in the end. Commented Jun 22, 2025 at 19:07
  • 1
    .lib files are windows specific, this tutorial is pretty much useless on linux. on linux you first download the dependencies using the system's package manager (apt on mint), then just link to it using your build system, gtk uses meson so ... ditch code blocks for gtk builder, i think it also allows you to use snaps which simplify packaging. or FWIW you can go for vcpkg + cmake as alternative to apt + meson but the steps are a bit more involved. Commented Jun 22, 2025 at 19:10
  • 5
    Linux Mint should already have all the libraries needed for Gtk development, you just need to use the normal package manager to install them. My guess is that the packages begin with something like libgtk and end with -dev. Also, as IIRC Mint is Debian-based, so you could look for tutorials on how to use these libraries with Debian. And I'm quite frankly surprised that the official Gtk documentation doesn't have a few notes about that. Commented Jun 22, 2025 at 19:13

1 Answer 1

0

I started by downloading each of the dependencies as a .tar.xz file

You did not specify from where you downloaded this file, but the fact that you got a .tar.xz file implies that you did not use the package manager. For Linux, it is a good idea to use your distribution's repositories (unless you need a library version not found there). It removes much of the guesswork.

Linux Mint provides three interfaces to the package manager: Software Manager, Synaptic Package Manager, and the command line. In my experience, Synaptic Package Manager is best for finding development libraries. Search for and install the package libgtk-4-dev. (If you cannot find the package in the graphical interface, try the command line interface; in a terminal, type sudo apt install libgtk-4-dev.) This should give you all the dependencies as well.

To point your IDE to the installed packages, use . The necessary compiler flags are produced by

`pkg-config gtk-4-1 --cflags`

and the linker flags by

`pkg-config gtk-4-1 --libs`

Be sure to type (or copy) the back-ticks (`), as those are significant.

For Code::Blocks in particular, the project build settings are under the "Project" menu, "Build options...". The compiler flags go in the "Compiler settings" tab, "Other compiler options" sub-tab. The linker flags go in the "Linker settings" tab, "Other linker options" text entry box.

Disclaimer: package names can very, but these names should be correct for Linux Mint, Debian, and Ubuntu. Other distributions might use other names. For example, the Fedora package is gtk4-devel, which becomes gtk4 when getting the flags.


If you really, really want to make your download work, we'd need to know which file you downloaded. But I think you're more interested in getting GTK working.


Since you're using GTK and C++, let me point out that gtkmm is "the official C++ interface for the popular GUI library GTK." The package name in Linux Mint 22+ is libgtkmm-4.0-dev. (It looks like the official repositories for older versions of Linux Mint only have version 3, libgtkmm-3.0-dev.) Drop the "lib" and "-dev" for the commands, leaving gtkmm-4.0.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.