[CMake] Unable to find GTK with cmake on Ubuntu

Pierrick Grasland pierrick.grasland at gmail.com
Fri Dec 19 05:38:11 EST 2008


Hi.

I though I resolved my problem, but not.

Actually,  my project can link gtk2 with my C source file, with the
following include :

#include <gtk-2.0/gtk/gtk.h>

But, within gtk.h, gtk includes are linked with the following :

#include <gtk/gdk.h> (for example)

So, I can't build since I don't have access to my widgets.

Like before, my CMakeLists.txt is something like that :

SET(CMAKE_MODULE_PATH "/home/bobby/workspace/SipSec/gui")

FIND_PACKAGE(GTK2 COMPONENTS gtk)
include_directories (${GTK2_INCLUDE_DIRS})

set( GUI_SRC gtkCallback.c interface.c widgetUI.c)
add_library (sipsecgui  ${GUI_SRC} )
target_link_libraries(sipsecgui ${GTK2_LIBRARIES} )

How can I tell CMake to link Gtk2 as <gtk/*> instead of <gtk-2.0/gtk/*> ?

Any ideas someone ?


On Fri, Dec 19, 2008 at 11:14 AM, Pierrick Grasland <
pierrick.grasland at gmail.com> wrote:

> Found it !
>
> ${GTK2_INCLUDE_DIR} != ${GTK2_INCLUDE_DIR*S*}
>
> Sorry for bothering you.
>
>
>
> On Fri, Dec 19, 2008 at 11:12 AM, Pierrick Grasland <
> pierrick.grasland at gmail.com> wrote:
>
>> Ok.
>>
>> I modify my CMakeLists.txt :
>>
>> SET(CMAKE_MODULE_PATH "/home/bobby/workspace/SipSec/gui")
>>
>> FIND_PACKAGE(GTK2 COMPONENTS gtk)
>> include_directories (${GTK2_INCLUDE_DIR})
>>
>> set( GUI_SRC gtkCallback.c interface.c widgetUI.c)
>> add_library (sipsecgui  ${GUI_SRC})
>> target_link_libraries(sipsecgui ${GTK2_LIBRARIES} )
>>
>> But gcc respond with :
>>
>> /home/bobby/workspace/SipSec/gui/gtkCallback.h:12:21: erreur: gtk/gtk.h :
>> Aucun fichier ou dossier de ce type (ie File not exist)
>>
>>
>> On Fri, Dec 19, 2008 at 10:45 AM, Philip Lowman <philip at yhbt.com> wrote:
>>
>>> On Fri, Dec 19, 2008 at 4:40 AM, Pierrick Grasland <
>>> pierrick.grasland at gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I just tried FindGTK2.cmake
>>>>
>>>> It correctly locate GTK2 library, but when I trying to build my project,
>>>> GCC output a lot of error in GTK lib ...
>>>>
>>>> It seems to be unable to find definition of GTK.
>>>>
>>>> I copy / paste here my CMakeLists.txt (I think I forgot something) :
>>>>
>>>> SET(CMAKE_MODULE_PATH "/home/bobby/workspace/SipSec/gui")
>>>>
>>>> FIND_PACKAGE(GTK2 COMPONENTS gtk)
>>>> include_directories (${GTK2_GTK_INCLUDE_DIR})
>>>>
>>>> set( GUI_SRC gtkCallback.c interface.c widgetUI.c)
>>>> add_library (sipsecgui  ${GUI_SRC} ${GTK2_GTK_LIBRARIES})
>>>> target_link_libraries(sipsecgui ${GTK2_GTK_LIBRARIES} )
>>>>
>>>>
>>>> and some errors from GCC output :
>>>>
>>>> /usr/include/gtk-2.0/gtk/gtktextbufferrichtext.h:90: erreur: expected
>>>> declaration specifiers before «G_END_DECLS»
>>>> In file included from /usr/include/gtk-2.0/gtk/gtk.h:176,
>>>>                  from /home/bobby/workspace/SipSec/gui/gtkCallback.h:12,
>>>>                  from /home/bobby/workspace/SipSec/gui/gtkCallback.c:7:
>>>> /usr/include/gtk-2.0/gtk/gtktextview.h:53: erreur: expected declaration
>>>> specifiers before «GtkTextWindowType»
>>>> /usr/include/gtk-2.0/gtk/gtktextview.h:57: erreur: storage class
>>>> specified for parameter «GtkTextView»
>>>>
>>>
>>>
>>> Due to GTK's dependencies (header files in a dozen different directories
>>> and many libraries) when using this module you should use:
>>>
>>> INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
>>> and
>>> TARGET_LINK_LIBRARIES(foo ${GTK2_LIBRARIES})
>>>
>>> The module appends all the stuff in two large lists exposed as
>>> GTK2_INCLUDE_DIRS and GTK2_LIBRARIES.
>>>
>>> --
>>> Philip Lowman
>>>
>>
>>
>>
>> --
>> Pierrick Grasland
>>
>>
>
>
> --
> Pierrick Grasland
>
>


-- 
Pierrick Grasland
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081219/333f0f05/attachment-0001.htm>


More information about the CMake mailing list