Friday, May 3, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 3884  / 2 Years ago, sun, june 26, 2022, 10:59:48

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.


More From » package-management

 Answers
6

(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


[#32422] Monday, June 27, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elecerna

Total Points: 140
Total Questions: 121
Total Answers: 107

Location: Northern Ireland
Member since Sun, Nov 21, 2021
3 Years ago
;