Using GTK library in CLion

I'm new to GTK and I want to use CLion to code using this library.
I'm on Ubuntu and I'v installed libgtk-3.0-dev but when I want to build the project I get this :
fatal error: gtk-3.0: No such file or directory

4 comments
Comment actions Permalink

Hi Amir.

Could you please specify how you've configured your CMakeLists.txt for working with GTK?

0
Comment actions Permalink

Hi
this is my CMakeList

cmake_minimum_required(VERSION 3.2)
project(test1)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp)
add_executable(test1 ${SOURCE_FILES})
0
Comment actions Permalink

Hi Amir.

Sorry for the dealy.
Could you please share your project with us? You can send it to clion-support at jetbrains.com.
It would help us to investigate the problem.
Also please find out some useful information about CMake and GTK3 here:
http://francesco-cek.com/cmake-and-gtk-3-the-easy-way/

0
Comment actions Permalink

thank you
I studied about CMake and I changed my CMake file like this and the problem is gone now.


cmake_minimum_required(VERSION 3.2)
project(SimpleCalculatorPro)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

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})

add_executable(SimpleCalculatorPro SCP.cpp Calculator.cpp Calculator.h Arithmetics.cpp Arithmetics.h History.cpp History.h Interface.cpp Interface.h)
target_link_libraries(SimpleCalculatorPro ${GTK3_LIBRARIES}
)
1

Please sign in to leave a comment.