Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Hi I'm trying to compile gnome-packagekit from source git://git.gnome.org/gnome-packagekit and when I try and make I get the error above

error: ‘g_type_init’ is deprecated (declared at /usr/local/include/glib-2.0/gobject/gtype.h:669) [-Werror=deprecated-declarations]
cc1: all warnings being treated as errors

I've looked this up and it seems to be because glib-2.35.4 has deprecated the g_type_init call. (I don't actually know what that means). It also seems to be related to wperror checks according to some commentators. The output of autogen.sh is

            gnome-packagekit 3.7.6
          =============================

prefix:                    /usr/local
compiler:                  gcc
cflags:                    -g -O2
cppflags:                   -Werror -Wall -Wreturn-type -Wdeclaration-after-statement -Wno-uninitialized -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-nonliteral -Wformat-security -Wswitch-default -Winit-self -Wmissing-include-dirs -Wno-strict-aliasing -Wundef -Waggregate-return -Wmissing-format-attribute -g -fexceptions                    gnome-packagekit 3.7.6
              =============================

    prefix:                    /usr/local
    compiler:                  gcc
    cflags:                    -g -O2
    cppflags:                   -Werror -Wall -Wreturn-type -Wdeclaration-after-statement -Wno-uninitialized -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-nonliteral -Wformat-security -Wswitch-default -Winit-self -Wmissing-include-dirs -Wno-strict-aliasing -Wundef -Waggregate-return -Wmissing-format-attribute -g -fexceptions

Which suggests this might have something to do with it.

Wonder if there is an easy way to tell the compiler to use the old version of glib or to ignore werror checks.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

(I don't actually know what that means)

What is means is that starting with glib version 2.35.0, the function g_type_init should no longer be used because the intention is to remove it from the library at some point in the future.

So when compiling older glib programs against glib version 2.35.0 or greater, you should edit the code to put a test around g_type_init

#if !GLIB_CHECK_VERSION(2,35,0)
g_type_init ();
#endif

At first this looks as if g_type_init will only be excluded for glib 2.35.0 but the macro LIB_CHECK_VERSION is in fact defined to return true for the same or greater/newer version than that specified.

Wonder if there is an easy way to tell the compiler to use the old version of glib

You can instruct the compiler and linker to use an older or newer version that the default, but obviously you need to have that version installed which may very well lead to problems with other programs trying to use the wrong version of the glib library.

So, as a general rule, only install multiple versions of library as a last resort, extra especially so for general purpose libraries such as glib which is used by so many programs.

to ignore werror checks.

The -Wall flag on the gcc command tells gcc to flag all warnings, and for a few years now, the default state of gcc is to treat all warnings as errors. If you ask this question on many sites, responders will simply tell you to do a web search.

If you were to check the manual page for gcc, you would find that the best way to deal with the specific issue of a deprecated function is to add

-Wno-deprecated-declarations

to the gcc command in order to just ignore that and still keep the safety of checking for all other warnings with -Wall

share|improve this answer

Comment out the line containing g_type_init. That should solve the problem.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.