playerproject / player

The Player cross-platform robot device interface & server
GNU General Public License v2.0
60 stars 32 forks source link

Fail to compile on Linux. fatal error: gdk-pixbuf/gdk-pixbuf.h: No such file or directory #22

Closed kevinsmia1939 closed 3 years ago

kevinsmia1939 commented 3 years ago

I am trying to package Gazebo as Flatpak, and I decide to include Player as dependency.

I use openSUSE Tumbleweed. Flatpak builder 1.0.14 Flatpak 1.11.2

But I failed to install Player. I build and install gdk-pixbuf 2.42.6

During Player compilation, it show that it found gdk-pixbuf.

-- Looking for clock_gettime - found
-- Looking for GEOSGeomFromWKB_buf in geos_c
-- Looking for GEOSGeomFromWKB_buf in geos_c - not found
-- Checking for module 'libgnomecanvas-2.0'
--   Package 'libgnomecanvas-2.0', required by 'virtual:world', not found
-- Checking for module 'gtk+-2.0'
--   Package 'gtk+-2.0', required by 'virtual:world', not found
-- Checking for module 'gdk-pixbuf-2.0'
--   Found gdk-pixbuf-2.0, version 2.42.6

But later failed.

/run/build/Player/utils/playerwritemap/playerwritemap.c:46:10: fatal error: gdk-pixbuf/gdk-pixbuf.h: No such file or directory
   46 | #include <gdk-pixbuf/gdk-pixbuf.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I have to run this command for it to work. ln -s /app/include/gdk-pixbuf-2.0/gdk-pixbuf /app/include/gdk-pixbuf

However, doing this cause another issue,

Found 3 struct(s)
[ 29%] Linking C shared library libplayerutil.so
In file included from /run/build/Player/utils/playerwritemap/playerwritemap.c:46:
/app/include/gdk-pixbuf/gdk-pixbuf.h:29:10: fatal error: glib.h: No such file or directory
   29 | #include <glib.h>
      |          ^~~~~~~~
compilation terminated.

But I have glib.h in /usr/include/glib-2.0 Not sure what to do about it.

kevinsmia1939 commented 3 years ago

I fix it now.

Simply apply the patch.

diff -ruN a/cmake/internal/SearchForStuff.cmake b/cmake/internal/SearchForStuff.cmake
--- a/cmake/internal/SearchForStuff.cmake   2021-08-06 00:15:49.144169413 +0700
+++ b/cmake/internal/SearchForStuff.cmake   2021-08-06 00:18:25.104200656 +0700
@@ -171,7 +171,7 @@
         LIST_TO_STRING (GTK_CFLAGS "${GTK_PKG_CFLAGS_OTHER}")
     ENDIF (GTK_PKG_FOUND)

-    pkg_check_modules (GDKPIXBUF_PKG gdk-pixbuf-2.0)
+    pkg_check_modules (GDKPIXBUF_PKG gdk-pixbuf)
     IF (GDKPIXBUF_PKG_FOUND)
         SET (WITH_GDKPIXBUF TRUE)
         LIST_TO_STRING (GDKPIXBUF_LINKFLAGS "${GDKPIXBUF_PKG_LDFLAGS_OTHER}")
richmattes commented 3 years ago

It doesn't look like there's a gdk-pixbuf.pc on opensuse, so the included patch is probably quietly failing and the things that require gdk-pixbuf-2.0 aren't being built.

It looks like the problem is that playerwritemap isn't actually trying to link against gdkpixbuf, it's linking against gtk instead. Can you see if this patch fixes your error?

diff --git a/utils/playerwritemap/CMakeLists.txt b/utils/playerwritemap/CMakeLists.txt
index 639676c1..0f04c3b1 100644
--- a/utils/playerwritemap/CMakeLists.txt
+++ b/utils/playerwritemap/CMakeLists.txt
@@ -3,15 +3,13 @@ IF (BUILD_UTILS_PLAYERWRITEMAP)
     IF (WITH_GDKPIXBUF)
         SET (playerwritemapSrcs playerwritemap.c)

-        INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs ${GTK_PKG_INCLUDE_DIRS})
-        LINK_DIRECTORIES (${GTK_PKG_LIBRARY_DIRS})
+        INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs
+          ${GDKPIXBUF_PKG_INCLUDE_DIRS})
+        LINK_DIRECTORIES (${GDKPIXBUF_PKG_LIBRARY_DIRS})
         PLAYER_ADD_EXECUTABLE (playerwritemap ${playerwritemapSrcs})
         TARGET_LINK_LIBRARIES (playerwritemap playerc playerinterface playercommon
-            ${PLAYERC_EXTRA_LINK_LIBRARIES} ${GTK_PKG_LIBRARIES})
-        SET_SOURCE_FILES_PROPERTIES (${playerwritemapSrcs} PROPERTIES
-            COMPILE_FLAGS "${GTK_CFLAGS}")
-        SET_TARGET_PROPERTIES (playerwritemap PROPERTIES
-            LINK_FLAGS "${GTK_LINKFLAGS}")
+            ${PLAYERC_EXTRA_LINK_LIBRARIES}
+            ${GDKPIXBUF_PKG_LIBRARIES})
     ELSE (WITH_GDKPIXBUF)
         MESSAGE (STATUS "playerwritemap will not be built - GDK pixbuf not found")
     ENDIF (WITH_GDKPIXBUF)
kevinsmia1939 commented 3 years ago

Your patch work, thanks.