1

When I run cmake .. in ./build, I get the output:

`-- Checking for module 'gtkmm3'
--   Package 'gtkmm3', required by 'virtual:world', not found
CMake Error at /nix/store/i78xz11da295kd8ynsjmxvi2r56rbhzw-clion-2024.1.3/clion/bin/cmake/linux/x64/share/cmake-3.28/Modules/FindPkgConfig.cmake:619 (message):
  The following required packages were not found:

   - gtkmm3

Call Stack (most recent call first):
  /nix/store/i78xz11da295kd8ynsjmxvi2r56rbhzw-clion-2024.1.3/clion/bin/cmake/linux/x64/share/cmake-3.28/Modules/FindPkgConfig.cmake:841 (_pkg_check_modules_internal)
  CMakeLists.txt:20 (pkg_check_modules)


-- Configuring incomplete, errors occurred!

I have tried using g++ and ran the following command without any errors. g++ -o ./build/bin/button_example ./src/main.cpp pkg-config --cflags --libs gtkmm-3.0'`

This is my nix flake:

{
  description = "A Nix-flake-based C/C++ development environment with GTK support";

  inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";

  outputs = { self, nixpkgs }:
    let
      supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
      forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
        pkgs = import nixpkgs { inherit system; };
      });
    in
    {
      devShells = forEachSupportedSystem ({ pkgs }: {
        default = pkgs.mkShell.override
          {
            # Optionally override stdenv for specific compiler settings:
            # stdenv = pkgs.clangStdenv;
          }
          {
            packages = with pkgs; [
              clang-tools
              cmake
              codespell
              conan
              cppcheck
              doxygen
              gtest
              lcov
              vcpkg
              vcpkg-tool
              gtkmm3
              pkg-config
            ] ++ (if system == "aarch64-darwin" then [ ] else [ gdb ]);
          };
      });
    };
}`

and this is my cmakelists.txt:

# Minimum CMake version
cmake_minimum_required(VERSION 3.21)

# Define the project
project(calculator VERSION 1.0 LANGUAGES CXX)

# Enable C++20 standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)


# Set the output directory for binaries
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Include directories
include_directories(${CMAKE_SOURCE_DIR}/src)

# Find gtkmm-3.0 package using pkg-config
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTKMM REQUIRED gtkmm3)

# Include GTKMM directories and link libraries
include_directories(${GTKMM_INCLUDE_DIRS})
link_directories(${GTKMM_LIBRARY_DIRS})
add_definitions(${GTKMM_CFLAGS_OTHER})

# Add the source files
file(GLOB_RECURSE SOURCES "src/*.cpp")

# Create the executable
add_executable(calculator ${SOURCES})

# Link GTKMM libraries
target_link_libraries(calculator ${GTKMM_LIBRARIES})

I have tried using different gtk versions with no luck. I get the same error no matter what, unless I use g++. I'm new-ish both nix and c++, so don't have many idea's on what else to try.

6
  • If you want to locate gtkmm-3.0 package, then specify exactly that name in pkg_check_modules call: pkg_check_modules(GTKMM REQUIRED gtkmm-3.0) Commented Nov 6, 2024 at 17:19
  • I've just tried that and get the exact same error as before. Commented Nov 6, 2024 at 17:40
  • @Eris there might be a debug or verbose env variable for the pkg-config wrapper script. You can see the source of the script by printing the content of the pkg-config executable in your path Commented Nov 6, 2024 at 18:22
  • Im getting past running cmake .. now, but when i run make, i get: /home/eris/Projects/calculator-cpp/src/main.cpp:1:10: fatal error: gtkmm-3.0: No such file or directory 1 | #include <gtkmm-3.0> | ^~~~~~~~~~~ ive also tried gtkmm3 instead and gtkmm3.h Commented Nov 6, 2024 at 19:12
  • The header file for gtkmm is named gtkmm.h: gnome.pages.gitlab.gnome.org/gtkmm Commented Nov 7, 2024 at 10:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.