我收到此错误:
raphy@raohy:~/wxWidgets$ cmake -B builddir
-- Setting build type to 'Debug' as none was specified.
-- The C compiler identification is GNU 12.3.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.1")
-- Looking for GDK_WINDOWING_WAYLAND
-- Looking for GDK_WINDOWING_WAYLAND - not found
-- Looking for GDK_WINDOWING_X11
-- Looking for GDK_WINDOWING_X11 - not found
CMake Error at /usr/local/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find GTK3 (missing: GTK3_INCLUDE_DIRS GTK3_LIBRARIES)
Call Stack (most recent call first):
/usr/local/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
build/cmake/modules/FindGTK3.cmake:51 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
build/cmake/toolkit.cmake:81 (find_package)
build/cmake/main.cmake:15 (include)
CMakeLists.txt:100 (include)
-- Configuring incomplete, errors occurred!
但libgtk-3-dev
已经安装:
raphy@raohy:~/wxWidgets$ sudo apt-get install build-essential libgtk-3-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
build-essential is already the newest version (12.10ubuntu1).
libgtk-3-dev is already the newest version (3.24.38-5ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 18 not upgraded.
raphy@raohy:/usr/include$ ls -lah | grep gtk
-rw-r--r-- 1 root root 1,4K mar 16 2023 canberra-gtk.h
drwxr-xr-x 4 root root 4,0K dic 22 19:17 gtk-2.0
drwxr-xr-x 5 root root 4,0K dic 23 12:28 gtk-3.0
drwxr-xr-x 6 root root 4,0K dic 22 10:11 gtk-4.0
drwxr-xr-x 4 root root 4,0K dic 31 11:47 gtkmm-4.0
drwxr-xr-x 3 root root 4,0K dic 22 19:17 gtk-unix-print-2.0
drwxr-xr-x 7 root root 4,0K dic 29 13:26 webkitgtk-4.0
raphy@raohy:/usr/lib/x86_64-linux-gnu$ ls -lah | grep libgtk3
-rwSr--r-- 1 root root 35K set 1 2022 libgtk3-nocsd.so.0
并且.bahrc
:
export PATH=$PATH:/usr/include/gtk-3.0
export GTK_PATH=$PATH:/usr/lib/x86_64-linux-gnu/
操作系统:Ubuntu 23.10
raphy@raohy:~$ pkg-config --libs gtk+-3.0
-lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz
-latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0
-lgobject-2.0 -lglib-2.0
cmake
:
raphy@raohy:~$ which cmake
/usr/local/bin/cmake
raphy@raohy:~$ cmake --version
cmake version 3.28.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
如何让 Ubuntu 检测 gtk3 库?
答案1
已解决感谢@DanielT 和@steeldriver:
这个问题与我之前的 CMake 安装有关,可能安装得比较混乱
我删除了与 CMake 安装相关的所有内容,然后从头开始重新编译和安装
之后一切都很顺利