Linking libraries problem caused by glib pkg-config file


(Stephan Siemen) #1

Hi,

we had problems linking our software recently on MacOS 10.12.5 with the latest homebrew. The compiler tried to link libraries as Frameworks which failed because they were actual libraries. This was caused by spurious “-Wl,-framework” in the link line. After some detective work we traced them back to the pkg-config file of ‘glib’ at

/usr/local/lib/pkgconfig/glib-2.0.pc

We could fix the file for our system, but this is of course no permanent solution. I have the fixed and original file included below.

Could this please be changed permanently in Homebrew? Sorry, for not doing this ourselves, but not sure how to do it yet.

Thanks
Stephan

########################### F I X E D ############################
prefix=/usr/local/Cellar/glib/2.52.3
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: GLib
Description: C Utility Library
Version: 2.52.3
Requires.private: libpcre
Libs: -L${libdir} -lglib-2.0 -L/usr/local/opt/gettext/lib -lintl -Wl,-framework,CoreFoundation
Libs.private: -L/usr/local/Cellar/pcre/8.40/lib -lpcre -lintl -Wl,-framework,CoreFoundation -liconv -Wl,-framework,Carbon -Wl,-framework,Foundation
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include -I/usr/local/opt/gettext/include

########################### O R I G I N A L ############################
prefix=/usr/local/Cellar/glib/2.52.3
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: GLib
Description: C Utility Library
Version: 2.52.3
Requires.private: libpcre
Libs: -L${libdir} -lglib-2.0 -L/usr/local/opt/gettext/lib -lintl -Wl,-framework -Wl,CoreFoundation
Libs.private: -L/usr/local/Cellar/pcre/8.40/lib -lpcre -lintl -Wl,-framework -Wl,CoreFoundation -liconv -Wl,-framework,Carbon -Wl,-framework,Foundation
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include -I/usr/local/opt/gettext/include


(Joshua McKinney) #2

Hi Stephan, thanks for doing the diagnosis on the problem. The most appropriate way to move forward with this is to submit a PR at https://github.com/Homebrew/homebrew-core.

Read the contributing docs for more info. The best part of doing it this way is you will be able to test the homebrew formula changes locally to ensure that they solve your problem.


(Stephan Siemen) #3

Thanks Joshua. Fired off my pull request: https://github.com/Homebrew/homebrew-core/pull/15693