[gtk-osx-users] g-ir-scanner without libtool on macOS
- From: Wataru Shimizu <waruzilla gmail com>
- To: gtk-osx-users-list gnome org
- Subject: [gtk-osx-users] g-ir-scanner without libtool on macOS
- Date: Mon, 5 Feb 2018 18:54:50 +0900
Hi,
I have a question about gobject introspection on macOS.
(Is this mailing list correct place?)
I'm now trying to build gir from a sample library (libsample.dylib) with
g-ir-scanner. On macOS, each dylib has "install name", and it's usually
same as its install path. In my case, install_name is
/usr/local/lib/libsample.dylib because I plan to install it to there.
(I'm not sure what it really should be, but other libraries (e.g.
libgtk-3.0, libglib) installed by homebrew have such install_name).
When I create .gir from libtool library (.la), gir could be generated
as I expected. However I could not find the way to do it from dylib
directly.
[with libtool]
$ glibtool --mode=compile --tag=CC cc -Wall -c \
`pkg-config --cflags gobject-2.0` greeter.c
$ glibtool --mode=link --tag=CC cc -o libsample.la greeter.lo \
-rpath /usr/local/lib `pkg-config --libs gobject-2.0`
$ g-ir-scanner --warn-all --namespace=Sample --nsversion=1.0 \
--libtool=glibtool --library=libsample.la --include=GObject-2.0 \
--pkg-export=sample --output Sample-1.0.gir greeter.c greeter.h \
libsample.la
=> OK, Sample-1.0.gir is generated and it has correct path.
$ cat Sample-1.0.gir | grep "shared-library"
shared-library="/usr/local/lib/libsample.0.dylib"
[without libtool]
$ gcc -Wall -fPIC -c `pkg-config --cflags gobject-2.0` greeter.c
$ gcc -dynamiclib -install_name /usr/local/lib/libsample.dylib \
-o libsample.dylib greeter.o `pkg-config --libs gobject-2.0`
$ g-ir-scanner --warn-all --namespace=Sample --nsversion=1.0 \
--no-libtool --library=sample --include=GObject-2.0 \
--pkg-export=sample --output Sample-1.0.gir greeter.c greeter.h
=> Failed with the following error message.
------------------------------------------------------------------------
dyld: Library not loaded: /usr/local/lib/libsample.dylib
Referenced from: /private/tmp/gir-mac-sample/tmp-introspectoN9qXF/Sample-1.0
Reason: image not found
Command '[u'/private/tmp/gir-mac-sample/tmp-introspectoN9qXF/Sample-1.0',
u'--introspect-dump=/private/tmp/gir-mac-sample/tmp-introspectoN9qXF/functions.txt,/private/tmp/gir-mac-sample/tmp-introspectoN9qXF/dump.xml']'
returned non-zero exit status -6
------------------------------------------------------------------------
I guess a command invoked from g-ir-scanner tried to load /usr/local/lib/
libsample.dylib, but it hasn't been installed yet.
I found some workarounds,
- Create libsample.dylib without "-install_name" option, then modify
Sample-1.0.gir manullay
- Install libsample.dylib into /usr/local/lib before invoking
g-ir-scanner
but they make the build process (Makefile/CMakeLists.txt) complex.
What is the correct way to generate .gir from non-libtool environment on
macOS?
To reproduce my problem easier, I uploaded the full source codes and
command scripts to: https://github.com/wagavulin/gir-mac-sample
Thanks!
----
Wataru Shimizu
<waruzilla gmail com>
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]