gpt4 book ai didi

c++ - 如何配置Clion来编译gtkmm项目

转载 作者:行者123 更新时间:2023-11-30 05:10:33 26 4
gpt4 key购买 nike

我已经从 GTK 复制了一个示例项目

#include <gtkmm.h>

int main(int argc, char *argv[])
{
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");

Gtk::Window window;
window.set_default_size(200, 200);

return app->run(window);
}

当直接从终端编译时,它工作得很好:

g++ main.cpp -o simple `pkg-config gtkmm-3.0 --cflags --libs`

但是当我尝试使用 Clion 进行编译时,它说

fatal error: gtkmm.h: No such file or directory
#include <gtkmm.h>

我的 CMakeLists.txt 看起来像这样:

cmake_minimum_required(VERSION 3.8)
project(songbook)

set(CMAKE_CXX_STANDARD 17)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)

include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})

add_definitions(${GTK3_CFLAGS_OTHER})

set(SOURCE_FILES main.cpp)
add_executable(songbook ${SOURCE_FILES})

target_link_libraries(songbook ${GTK3_LIBRARIES})

我做错了什么?

最佳答案

感谢 https://github.com/DreaminginCodeZH/gtkmmproject 解决了!最终 CMakeLists.txt:

cmake_minimum_required(VERSION 3.8)
project(songbook)

set(CMAKE_CXX_STANDARD 17)
find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0)

include_directories(${GTKMM_INCLUDE_DIRS})
link_directories(${GTKMM_LIBRARY_DIRS})

set(SOURCE_FILES main.cpp MainWindow.cpp MainWindow.h)
add_executable(songbook ${SOURCE_FILES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${GTKMM_LIBRARIES})

关于c++ - 如何配置Clion来编译gtkmm项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45637558/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com