简体   繁体   中英

Constantly getting an error: fatal error: gtk/gtk.h: No such file or directory

I'm working on a project that consists of a number of .c files. Therefore, to simplify things I'm using cmake to build files. The following code is in my CMakeLists.txt:

set(SOURCE_FILES
        utils.c
        importLXCat.c
        monte_carlo.c
        object.c
        vector.c
        errors.c
        scalar.c
        d2_matrix.c
        mt19937ar.c
        randn.c)

link_libraries(m)

add_library(methes_core ${SOURCE_FILES})

Then, in the terminal I build the cake using cmake -H. -Bbuild cmake -H. -Bbuild . Everything is fine till now.

In the next step, when I complete building using cmake --build build -- -j3 , I get the error: gtk/gtk.h: No such file or directory.

I've used #include <gtk/gtk.h> in a couple of C files in my project.

It'd be great if someone can help me.

You should link your program to GTK.

1) Look for gtk using: find_package(GTK REQUIRED)

2) Since GTK seems not a Modern CMake target, then use:

target_include_directories(methes_core PRIVATE ${GTK_INCLUDE_DIR})
target_link_libraries(methes_core PRIVATE ${GTK_LIBRARIES})

note: Hope In the future, we can only do target_link_libraries(methes_core PRIVATE gtk::gtk) for step 2...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM