I have a simple c file:
#include <glib.h>
int main(int argc, char *argv[])
{
guchar temp = 1;
GSList *list = NULL;
list = g_slist_append(list, (int []){1});
}
and a simple CMakeLists.txt file:
PROJECT (GLIB_TEST)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_C_COMPILER "/usr/bin/c99")
find_package(PkgConfig)
pkg_check_modules(GLIB REQUIRED glib-2.0)
include_directories(${GLIB_INCLUDE_DIRS})
add_executable(glibtest glibtest.c)
target_link_libraries(glibtest ${GLIB_LIBRARIES})
I use
$ cmake -G'Eclipse CDT4 - Unix Makefiles' -D CMAKE_BUILD_TYPE=Debug ../src
from a "sibling" build directory. I then import the project into eclipse.
All seems well except that certain definitions do not resolve. Specifically in this case, neither "guchar" or "GSList" get resolved even though glib.h is definitely included via "/usr/include/glib-2.0" in the projects "C/C++ Include paths and symbols (I have verified this).
The specific error is "Type 'guchar' could not be resolved" and "Type 'GSList' could not be resolved".
From the command line "make" succeeds without error. Any ideas?