konstantin_doncov
konstantin_doncov

Reputation: 2879

Use GLib in CLion

I trying to compile my test GLib project using CLion. So I added #include "glib-2.0/glib.h" in my cpp file and added include_directories(/usr/include/glib-2.0/glib) in my CMakeLists.txt. But got output in CLion:

fatal error: glib/galloca.h: No such file or directory

So how I can correctly use GLib in my project in CLion?

Upvotes: 3

Views: 2220

Answers (2)

acarlow
acarlow

Reputation: 924

Here's the skeleton I use for glib on my Mac (glib2 and pkgconfig installed via MacPorts):

cmake_minimum_required(VERSION 3.1)
project(HelloGlib)

include(FindPkgConfig)
pkg_check_modules(GLIB glib-2.0 REQUIRED)
include_directories(${GLIB_INCLUDE_DIRS})

set(SOURCE_FILES main.c)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${GLIB_LIBRARIES})

Upvotes: 10

nemequ
nemequ

Reputation: 17472

The include directory is supposed to be /usr/include/glib-2.0 not /usr/include/glib-2.0/glib. Or, more portably, pkg-config --cflags glib-2.0.

Upvotes: 2

Related Questions