GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Jul 23, 2014 8:09 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Simple CMake Example for GtkGl and Visual Studio
PostPosted: Sun Oct 21, 2012 1:13 pm 
Offline

Joined: Fri Oct 19, 2012 12:25 pm
Posts: 2
Hello everyone,

for my studies at the university I have to do some research in Gtk+OpenGL, CMake and Microsofts Visual Studio.
So first of all i downloaded and installed the Windows Binaries for GtkGlExt. The given example run as they should. For using GtkGl with CMake I added the Variable PKG_CONFIG_PPATH to my Windows-System-Variables. So CMake is able to find the gtkglext-win32.1.0.dll.
Here is my short and simple CMakeLists.txt:

Code:
project (gtk-test)
cmake_minimum_required (VERSION 2.4)

find_package (PkgConfig REQUIRED)

IF(PKG_CONFIG_FOUND)   
    INCLUDE(FindPkgConfig)

    PKG_CHECK_MODULES(GTK gtk+-2.0)
   
    IF(WIN32)
        PKG_CHECK_MODULES(GTKGL gtkglext-win32-1.0)
    ELSE(WIN32)
        PKG_CHECK_MODULES(GTKGL gtkglext-x11-1.0)
    ENDIF(WIN32)

ENDIF(PKG_CONFIG_FOUND)

include_directories (${GTK2_INCLUDE_DIRS})
link_directories (${GTK2_LIBRARY_DIRS})
add_executable (gtk-test main.cpp)
add_definitions (${GTK2_CFLAGS_OTHER})
target_link_libraries (gtk-test ${GTK2_LIBRARIES})


I can run this file with the CMake-GUI without any errors. But when I open the generated VS-Project the include
Quote:
#include <gtk/gtkgl.h>
in my code fails because there is "no such file or directory". I guess there are some GtkGl-entries missing in the include- and link-commands of the CMake-File?

Sorry for my english. My native language is german. I hope somebody can help me!


Top
 Profile  
 
 Post subject: Re: Simple CMake Example for GtkGl and Visual Studio
PostPosted: Sun Oct 21, 2012 11:00 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
You are not using pkg-config correctly. Firstly your project is defining macros as GTK* due to:
LtKoerschgen wrote:
PKG_CHECK_MODULES(GTK gtk+-2.0)

Yet you are using these as GTK2* rather than GTK*:
LtKoerschgen wrote:
include_directories (${GTK2_INCLUDE_DIRS})
link_directories (${GTK2_LIBRARY_DIRS})
add_executable (gtk-test main.cpp)
add_definitions (${GTK2_CFLAGS_OTHER})
target_link_libraries (gtk-test ${GTK2_LIBRARIES})

Surprisingly, you say there are no errors. Ah well, clever compiler maybe.

The reason I think that gtkgl.h isn't found is that the compiler can't find it in the include path. This is because although you have set up GTKGL macros with pkg-config, you haven't actually added them to include_directories etc. Have a look up the documentation. PKG_CHECK_MODULES takes a space delimited list so you can toss all your dependencies into the one macro to include.

P.s. Don't apologise for your English. You're not doing literature but computer science and your command of English is well beyond what is necessary to be understood clearly.


Top
 Profile  
 
 Post subject: Re: Simple CMake Example for GtkGl and Visual Studio
PostPosted: Mon Oct 22, 2012 8:57 pm 
Offline

Joined: Fri Oct 19, 2012 12:25 pm
Posts: 2
Thanks for your help, Paul!

Paul Childs wrote:
PKG_CHECK_MODULES takes a space delimited list so you can toss all your dependencies into the one macro to include.


By "space delimited list" do you mean something like this?
Code:
pkg_check_modules (GTK gtk+-win32-2.0 gtkglext-win32-1.0)
...
include_directories (${GTK_INCLUDE_DIRS} )
link_directories (${GTK_LIBRARY_DIRS} )
add_executable (gtk-test main.cpp)
add_definitions (${GTK_CFLAGS_OTHER} )
target_link_libraries (gtk-test ${GTK_LIBRARIES} )


When I built a VS-Project with that CMakeList Visual Studio said that gtkglext-win32-1.0.lib was missing. I looked trough some tutorials and created that Library (and also gdkglext-win32-1.0.lib) from the given DLL's in the GtkGLExt-Directory. And now the #include <gtk/gtkgl.h> doesn't make any trouble.

I'm still a little bit confused, because when I replace my main.cpp with a larger GtkGL-Example the resulting VS-Project tells me that gtkglext-win32-1.0.dll is missing on my computer.


Top
 Profile  
 
 Post subject: Re: Simple CMake Example for GtkGl and Visual Studio
PostPosted: Tue Oct 23, 2012 4:58 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
LtKoerschgen wrote:
By "space delimited list" do you mean something like this?

Yes that's exactly it.
LtKoerschgen wrote:
...gtkglext-win32-1.0.dll is missing on my computer.

Hmm. I really don't know why you would get such an error if pkg-config has already found and given you access to gtk/gtkgl.h. Probably have to see how this new code could be causing such a difference. I must admit I really don't know much about:
[list=]
opengl
cmake
visual studio
c++
or anything windows
[/list]
Only just got lucky enough to answer due to familiarity with pkg-config. It does sound like you're going a rather awkward way about preparing your program. gtkglext advises use of GNU make (citing potential incompatibility issues in other instances). Furthermore a lot of unix-like based stuff is better compiled on windows using mingw.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group