mxcl/homebrew — Issue #10439: GObjectIntrospection 1.31.10 linking fails (Mac OS X 10.6.8)
Author: jeffvanvoorst
Created: 2012-02-24 04:21:01+00:00
State: open

GObjectIntrospection fails to link a test program as it cannot find some cmph symbols.

brew doctor complains about some development libraries I have installed in /usr/local

output can be found at https://gist.github.com/1897413

The failing gcc command is:
```
/usr/bin/gcc-4.2 -I./girepository/cmph -D_REENTRANT -I/usr/local/Cellar/glib/2.30.2/include/glib-2.0 -I/usr/local/Cellar/glib/2.30.2/lib/glib-2.0/include -I/usr/local/Cellar/gettext/0.18.1.1/include -I/usr/local/Cellar/glib/2.30.2/include -fno-strict-aliasing -Wsign-compare -Wcast-align -Wpointer-arith -Wnested-externs -Wmissing-prototypes -Wmissing-declarations -Wchar-subscripts -Wall -Os -w -pipe -march=core2 -msse4 -o cmph-bdz-test cmph_bdz_test-cmph-bdz-test.o -L/usr/local/Cellar/libffi/3.0.10/lib -L/usr/local/Cellar/gettext/0.18.1.1/lib ./.libs/libcmph.a -lm -L/usr/local/Cellar/glib/2.30.2/lib -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lintl -ldl
```

If I install libcmph via homebrew and add it by hand to the above command, the linking step appears to work. As one might expect, whether or not libcmph is installed in /usr/local/lib has no impact on this issue.

Using nm on the lib ./.libs/libcmph.a and /usr/local/lib/libcmph.a + grep for _cmph_search gives

for the gobjectintrospection libcmph.a
```
U _cmph_search_packed
00000000000002d1 T _cmph_search
0000000000001440 N _cmph_search.eh
0000000000000037 T _cmph_search_packed
0000000000001380 N _cmph_search_packed.eh
```

for /usr/local/lib/libcmph.a
```
00000000000002d1 T _cmph_search
0000000000001440 N _cmph_search.eh
0000000000000037 T _cmph_search_packed
0000000000001380 N _cmph_search_packed.eh
U _cmph_search_packed
```

I am not familiar enough with the linker on Mac OS to decipher the problem. Maybe there is an easier solution?