GollyGang / ready

A cross-platform implementation of various reaction-diffusion systems and PDEs.
GNU General Public License v3.0
776 stars 60 forks source link

failure to compile on KDE Ubuntu 18.04 - gtk-2.0 v wx-3.0 conflict? #72

Closed rugbyRoad closed 4 years ago

rugbyRoad commented 4 years ago

Using the linux instructions provided on you Githup page, I was trying to compile the most recent 'ready' on my KDE/ubuntu 18.04 machine and ran into an error. If I included gtk-2.0-devel libraries, i got the fail response listed in the 'with-gtk-2.0' code below. The error states there is a conflict between wx-3.0 library defintions and the gtk-2.0 library definitions.

On the other hand, if I eliminate the gtk-2.0 library, then I get a different error listed below in the section --without-gtk-2.0--, which says that it can't find the gdk/gdkx.h file . I tried eliminating the include for gdk/gdkx.h in the line of xVTKRenderWindowInteractor.cxx:66, but that just generated more errors.

Any suggestions would be appreciated. Blake

-------------------------------------- - with gtk-2.0------------ 94%] Building CXX object CMakeFiles/ready.dir/src/gui/wxVTKRenderWindowInteractor.cxx.o In file included from /usr/include/gtk-2.0/gdk/gdkscreen.h:32:0, from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:31, from /usr/include/gtk-2.0/gdk/gdk.h:32, from /usr/include/gtk-2.0/gdk/gdkprivate.h:30, from /usr/include/gtk-2.0/gdk/gdkx.h:30, from /opt/ready/ready/src/gui/wxVTKRenderWindowInteractor.cxx:66: /usr/include/gtk-2.0/gdk/gdktypes.h:114:39: error: conflicting declaration ‘typedef struct _GdkDrawable GdkWindow’ typedef struct _GdkDrawable GdkWindow; ^~~~~ In file included from /usr/include/wx-3.0/wx/wxprec.h:12:0, from /opt/ready/ready/src/gui/wxVTKRenderWindowInteractor.h:41, from /opt/ready/ready/src/gui/wxVTKRenderWindowInteractor.cxx:21: /usr/include/wx-3.0/wx/defs.h:3464:31: note: previous declaration as ‘typedef struct _GdkWindow GdkWindow’ typedef struct _GdkWindow GdkWindow; ^~~~~ /opt/ready/ready/src/gui/wxVTKRenderWindowInteractor.cxx: In member function ‘long int wxVTKRenderWindowInteractor::GetHandleHack()’: /opt/ready/ready/src/gui/wxVTKRenderWindowInteractor.cxx:396:53: error: cannot convert ‘GdkWindow {aka _GdkWindow}’ to ‘GdkDrawable {aka _GdkDrawable}’ for argument ‘1’ to ‘XID gdk_x11_drawable_get_xid(GdkDrawable*)’ Window win = gdk_x11_drawable_get_xid(gdk_window); ^ In file included from /usr/include/wx-3.0/wx/wxprec.h:12:0, from /opt/ready/ready/src/gui/wxVTKRenderWindowInteractor.h:41, from /opt/ready/ready/src/gui/wxVTKRenderWindowInteractor.cxx:21: /usr/include/wx-3.0/wx/defs.h:3464:20: note: class type ‘GdkWindow {aka _GdkWindow}’ is incomplete typedef struct _GdkWindow GdkWindow; ------------------------------ without gtk-2.0-------------- 94%] Building CXX object CMakeFiles/ready.dir/src/gui/wxVTKRenderWindowInteractor.cxx.o /opt/ready/ready/src/gui/wxVTKRenderWindowInteractor.cxx:66:12: fatal error: gdk/gdkx.h: No such file or directory

include <gdk/gdkx.h>

        ^~~~~~~~~~~~

compilation terminated.

timhutton commented 4 years ago

It's odd because we compile on Ubuntu18.04 with gtk2 and wx3.0.4. Here is a recent build: https://github.com/GollyGang/ready/runs/579490973 and the specific build output: https://travis-ci.com/github/GollyGang/ready/jobs/318494302 Here is the Travis build script section for that platform: https://github.com/GollyGang/ready/blob/gh-pages/.travis.yml#L89

The only thing I can think is that cmake is finding the wrong versions of things. Maybe worthwhile making a fresh build folder and pasting in a reply here the output of cmake.

timhutton commented 4 years ago

Also, as an experiment, can you try the binary in here: https://github.com/GollyGang/ready/releases/download/0.10.1/Ready-0.10.1-Ubuntu18.04-64bit.zip

I just made that using Ubuntu 18.04 running under WSL on Windows, so I'm curious to see if it works for you.

claudeha commented 4 years ago

Ran into this one also.

Checking for GTK3 first then falling back to GTK2 if not found, works much better than the other way round, at least on Debian Bullseye (current testing):

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c72d091..25bc71f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -359,14 +359,14 @@ else()
     ENDIF(VTK_USE_COCOA)
   else()
     find_package(PkgConfig)
-    pkg_check_modules(GTK2 QUIET gtk+-2.0)
-    if(GTK2_FOUND)
-      include_directories(${GTK2_INCLUDE_DIRS})
-      link_libraries(${GTK2_LIBRARIES})
-    else()
-      pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
+    pkg_check_modules(GTK3 QUIET gtk+-3.0)
+    if(GTK3_FOUND)
       include_directories(${GTK3_INCLUDE_DIRS})
       link_libraries(${GTK3_LIBRARIES})
+    else()
+      pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
+      include_directories(${GTK2_INCLUDE_DIRS})
+      link_libraries(${GTK2_LIBRARIES})
     endif()
     SET(WXGLCANVASLIBS "gl")
   endif()

Seems I have both installed somehow.

timhutton commented 4 years ago

Thanks for diagnosing that this problem was caused when both gtk2 and gtk3 were installed. I managed to repro this and I've pushed a fix where we search for wxWidgets first and then use the matching version of gtk.

@rugbyRoad and @claudeha - let me know if it doesn't work for you and we can reopen this issue.