Bug 247546 - phonon does not compile on 64-bit linux
Summary: phonon does not compile on 64-bit linux
Status: RESOLVED FIXED
Alias: None
Product: Phonon
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 4.4.2 (KDE 4.5)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Martin Sandsmark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-12 19:05 UTC by felix-kde
Modified: 2010-12-05 21:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.4.3


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description felix-kde 2010-08-12 19:05:51 UTC
Version:           4.4.2 (KDE SC 4.5 final) (using KDE 4.5.0) 
OS:                Linux

The reason is that cmake/FindGLIB2.cmake is faulty.  The glib includes are in /usr/include/glib-2.0, and there is also a platform specific include file called glibconfig.h in /usr/lib64/glib-2.0/include

Note that 64-bit systems usually have both 32-bit and 64-bit versions of glib installed.  So there will be two (different!) versions of glibconfig.h, one in /usr/lib64/glib-2.0/include and one in /usr/lib/glib-2.0/include.  FindGLIB2.h has lib/glib-2.0/include hardcoded.  Note how none of this guessing and detecting is necessary because you can just call pkgconfig to ask for the right paths.  Please remove all this broken code and just call pkgconfig.

BTW: the symptom is that compilation fails with an error like this:

| /usr/include/glib-2.0/glib/gthread.h: In function `gboolean g_once_init_enter(volatile gsize*)':
| /usr/include/glib-2.0/glib/gthread.h:347:6: error: size of array is negative

This is an internal sanity check done by g_atomic_pointer_get, which in this case checks that sizeof(gsize) == sizeof(gpointer), which is not true if you include the 32-bit glibconfig.h on a 64-bit system.

Reproducible: Always

Steps to Reproduce:
compile phonon on 64-bit linux.

Actual Results:  
compile failure

Expected Results:  
no compile failure

use pkgconfig!!!
Comment 1 Martin Sandsmark 2010-08-12 19:23:18 UTC
commit 75532b4bb395f3b14da37ceb0d28619c1df145b7
Author: Martin T. H. Sandsmark <sandsmark@samfundet.no>
Date:   Thu Aug 12 19:22:46 2010 +0200

    Adopt the FindGLIB2.cmake from kdelibs.
    
    BUG: 247546

diff --git a/cmake/FindGLIB2.cmake b/cmake/FindGLIB2.cmake
index e19d6a4..09fd98d 100644
--- a/cmake/FindGLIB2.cmake
+++ b/cmake/FindGLIB2.cmake
@@ -5,36 +5,45 @@
 #  GLIB2_INCLUDE_DIR - the glib2 include directory
 #  GLIB2_LIBRARIES - glib2 library
 
+# Copyright (c) 2008 Laurent Montel, <montel@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
 
 if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
     # Already in cache, be silent
     set(GLIB2_FIND_QUIETLY TRUE)
 endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
 
-if (NOT WIN32)
-   find_package(PkgConfig REQUIRED)
-   pkg_check_modules(PKG_GLIB REQUIRED glib-2.0)
-endif(NOT WIN32)
+find_package(PkgConfig)
+pkg_check_modules(PC_LibGLIB2 QUIET glib-2.0)
+
+find_path(GLIB2_MAIN_INCLUDE_DIR
+          NAMES glib.h
+          HINTS ${PC_LibGLIB2_INCLUDEDIR}
+          PATH_SUFFIXES glib-2.0)
+
+find_library(GLIB2_LIBRARY 
+             NAMES glib-2.0 
+             HINTS ${PC_LibGLIB2_LIBDIR}
+)
 
-find_path(GLIB2_MAIN_INCLUDE_DIR glib.h
-          PATH_SUFFIXES glib-2.0
-          PATHS ${PKG_GLIB_INCLUDE_DIRS} )
+set(GLIB2_LIBRARIES ${GLIB2_LIBRARY})
 
 # search the glibconfig.h include dir under the same root where the library is found
-find_library(GLIB2_LIBRARIES
-             NAMES glib-2.0
-             PATHS ${PKG_GLIB_LIBRARY_DIRS} )
+get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH)
 
 find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
-          PATH_SUFFIXES glib-2.0/include ../lib/glib-2.0/include
-          PATHS ${PKG_GLIB_INCLUDE_DIRS} ${PKG_GLIB_LIBRARIES} ${CMAKE_SYSTEM_LIBRARY_PATH})
+          PATH_SUFFIXES glib-2.0/include
+          HINTS ${PC_LibGLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH})
 
-set(GLIB2_INCLUDE_DIR ${GLIB2_MAIN_INCLUDE_DIR})
+set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}")
 
 # not sure if this include dir is optional or required
 # for now it is optional
 if(GLIB2_INTERNAL_INCLUDE_DIR)
-  set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} ${GLIB2_INTERNAL_INCLUDE_DIR})
+  set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}")
 endif(GLIB2_INTERNAL_INCLUDE_DIR)
 
 include(FindPackageHandleStandardArgs)
Comment 2 Martin Sandsmark 2010-08-12 19:24:42 UTC
I am unable to reproduce this here on my 64bit ArchLinux system (obviously), but I have adopted the findglib2.cmake file from kdelibs, does this fix it (it seems like it should)?
Comment 3 felix-kde 2010-08-12 20:17:46 UTC
Yes, that works for me.