Anything GTK/GDK related is not found Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Midnightas
Knows some wx things
Knows some wx things
Posts: 39
Joined: Fri Feb 02, 2018 1:48 pm

Anything GTK/GDK related is not found

Post by Midnightas »

I'm building a wxWidgets project with CMake but can't even get a wxHelloWorld going.
CMake generates the files normally, but when running make I get a preprocessor error from wx/defs.h saying "No Target! You should use wx-config program for compilation flags!"
After that, every error I get is related to GTK.

I would've assumed that CMake would add all required libraries.

Here's just a portion of all the errors:

Code: Select all

In file included from /usr/local/include/wx-3.1/wx/cursor.h:57:0,
                 from /usr/local/include/wx-3.1/wx/event.h:21,
                 from /usr/local/include/wx-3.1/wx/wx.h:24,
                 from /home/midnightas/cpp/XXXXX/include/XXXXX.h:4,
                 from /home/midnightas/cpp/XXXXX/src/XXXXX.cpp:1:
/usr/local/include/wx-3.1/wx/gtk/cursor.h:43:5: error: ‘GdkCursor’ does not name a type
     GdkCursor *GetCursor() const;
     ^
In file included from /usr/local/include/wx-3.1/wx/colour.h:213:0,
                 from /usr/local/include/wx-3.1/wx/window.h:24,
                 from /usr/local/include/wx-3.1/wx/wx.h:38,
                 from /home/midnightas/cpp/XXXXX/include/XXXXX.h:4,
                 from /home/midnightas/cpp/XXXXX/src/XXXXX.cpp:1:
/usr/local/include/wx-3.1/wx/gtk/colour.h:26:20: error: ‘GdkColor’ does not name a type
     wxColour(const GdkColor& gdkColor);
                    ^
/usr/local/include/wx-3.1/wx/gtk/colour.h:48:11: error: ‘GdkColor’ does not name a type
     const GdkColor *GetColor() const;
And my CMake:

Code: Select all

cmake_minimum_required(VERSION 3.5)
project(XXXXX)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

set(CMAKE_CXX_STANDARD 11)

find_package(wxWidgets 3.1 REQUIRED core base gl)
find_package(CURL REQUIRED)

file(GLOB_RECURSE SOURCES
	src/*.cpp
	include/*.h
)
add_executable(xxxxx ${SOURCES})

include_directories(${CURL_INCLUDE_DIRS} ${wxWidgets_INCLUDE_DIRS} "${PROJECT_SOURCE_DIR}/include")
target_link_libraries(xxxxx ${CURL_LIBRARIES} ${wxWidgets_LIBRARIES})
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Anything GTK/GDK related is not found

Post by DavidHart »

Hi,
"No Target! You should use wx-config program for compilation flags!"
Perhaps your CMakeLists.txt can't find wx-config. If so then it's unsurprising that compilation fails.

I suggest you add VERBOSE=1 and some strategic message() statements to try to find out why. And, as a sanity check, try doing in a terminal:
wx-config --cxxflags

Regards,

David
Midnightas
Knows some wx things
Knows some wx things
Posts: 39
Joined: Fri Feb 02, 2018 1:48 pm

Re: Anything GTK/GDK related is not found

Post by Midnightas »

Here's the only command it runs before the error:

Code: Select all

/usr/bin/c++    -I/usr/local/lib/wx/include/gtk3-unicode-3.1 -I/usr/local/include/wx-3.1 -I/home/midnightas/cpp/Bogle/include  -std=gnu++11 -o CMakeFiles/bogle.dir/src/Bogle.cpp.o -c /home/midnightas/cpp/Bogle/src/Bogle.cpp
It seems to be including gtk3-unicode.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Anything GTK/GDK related is not found

Post by doublemax »

Why are you using Cmake under Linux anyway? With the "official" way using the provided makefiles, building wx and its samples should be very simple.
Use the source, Luke!
Midnightas
Knows some wx things
Knows some wx things
Posts: 39
Joined: Fri Feb 02, 2018 1:48 pm

Re: Anything GTK/GDK related is not found

Post by Midnightas »

Because I'm going to be also building this from Windows.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Anything GTK/GDK related is not found

Post by doublemax »

Because I'm going to be also building this from Windows.
Building wxGTK under Windows is probably not done very often. Did you read <wxdir>/docs/msw/gtk.txt ?
Use the source, Luke!
Midnightas
Knows some wx things
Knows some wx things
Posts: 39
Joined: Fri Feb 02, 2018 1:48 pm

Re: Anything GTK/GDK related is not found

Post by Midnightas »

No, I'm planning on building wxWidgets on Windows and Linux using CMake.
CMake on a Linux system would automatically also include wxGTK when compiling.
And it seems to be correctly including yet for some reason GCC says that no GTK-related types exist.

Everything worked nicely when I didn't use CMake.
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Anything GTK/GDK related is not found

Post by DavidHart »

Everything worked nicely when I didn't use CMake.
More information would help us to help you. I don't know if you noticed this bit of my post:
Perhaps your CMakeLists.txt can't find wx-config. If so then it's unsurprising that compilation fails.
I suggest you add VERBOSE=1 and some strategic message() statements to try to find out why. And, as a sanity check, try doing in a terminal:
wx-config --cxxflags
If you tried those suggestions perhaps you could post the results...
Midnightas
Knows some wx things
Knows some wx things
Posts: 39
Joined: Fri Feb 02, 2018 1:48 pm

Re: Anything GTK/GDK related is not found

Post by Midnightas »

I said in an above post the command that it runs.
It contained what `wx-config --cxxflags` outputted.
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Anything GTK/GDK related is not found

Post by DavidHart »

It contained what `wx-config --cxxflags` outputted.
Ah, that's good to know.

And the output of the debugging message() statements? And of running cmake with ' VERBOSE=1' ?
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 548
Joined: Fri Nov 03, 2006 2:00 pm

Re: Anything GTK/GDK related is not found

Post by stahta01 »

What wxWidgets version are you using?

3.1.0
3.1.1rc
git master branch

Tim S.
Midnightas
Knows some wx things
Knows some wx things
Posts: 39
Joined: Fri Feb 02, 2018 1:48 pm

Re: Anything GTK/GDK related is not found

Post by Midnightas »

stahta01 wrote:What wxWidgets version are you using?

3.1.0
3.1.1rc
git master branch

Tim S.
`wx-config --version` just says "3.1.1"
Last edited by Midnightas on Sat Feb 24, 2018 9:57 pm, edited 1 time in total.
Midnightas
Knows some wx things
Knows some wx things
Posts: 39
Joined: Fri Feb 02, 2018 1:48 pm

Re: Anything GTK/GDK related is not found

Post by Midnightas »

DavidHart wrote:
It contained what `wx-config --cxxflags` outputted.
Ah, that's good to know.

And the output of the debugging message() statements? And of running cmake with ' VERBOSE=1' ?
I found the command it ran already with VERBOSE=1
Midnightas
Knows some wx things
Knows some wx things
Posts: 39
Joined: Fri Feb 02, 2018 1:48 pm

Re: Anything GTK/GDK related is not found

Post by Midnightas »

This turned out to be another case where the person's forgotten one single line of code.

I forgot to add:

Code: Select all

include(${wxWidgets_USE_FILE})
Post Reply