naqvis / crystal-vips

Crystal bindings for the libvips image processing library.
MIT License
41 stars 5 forks source link

Undefined reference to g_type_from_name #14

Closed ralsina closed 4 months ago

ralsina commented 5 months ago
> git clone git@github.com:naqvis/crystal-vips.git
Cloning into 'crystal-vips'...
remote: Enumerating objects: 1432, done.
remote: Counting objects: 100% (90/90), done.
remote: Compressing objects: 100% (85/85), done.
remote: Total 1432 (delta 70), reused 9 (delta 3), pack-reused 1342
Receiving objects: 100% (1432/1432), 5.02 MiB | 3.45 MiB/s, done.
Resolving deltas: 100% (1206/1206), done.

/tmp via 🐍 v3.12.3 (ff-cli) took 4s
> cd crystal-vips/

crystal-vips on  main is 📦 v0.1.6 via 🐍 v3.12.3 (ff-cli) via 🔮 v1.12.2
> crystal spec
/usr/bin/ld: V-ips.o0.o: undefined reference to symbol 'g_type_from_name'
/usr/bin/ld: /lib/x86_64-linux-gnu/libgobject-2.0.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Error: execution of command failed with exit status 1: cc "${@}" -o /home/ralsina/.cache/crystal/crystal-run-spec.tmp  -rdynamic -L/usr/bin/../lib/crystal -lvips -lpcre -lm -lgc -lpthread -levent -lrt -lpthread -ldl

This is Ubuntu 22.04 with version 8.12.1-1build1 of libvips

Tried it with revision 0f4d3914985865a020168b0f48ece07416eeb459 of crystal-vips

naqvis commented 5 months ago

Looks like some missing dependency. Are you able to run vips properly? Try running vips --vips-config from console and see if that works.

This shard only dependency is libvips

ralsina commented 4 months ago

Here is output compiling and then running vips in the same machine.

.
ameba: checking...
Dependencies are satisfied
Building: nicolino
crystal build -o /home/ralsina/code/nicolino/bin/nicolino src/main.cr --verbose -d
cc _main.o0.o S-lice40U-I-nt841.o0.o P-ointer40U-I-nt841.o0.o A-rgumentE-rror.o0.o E-xception5858C-allS-tack.o0.o A-rra
Error target nicolino failed to compile:
/usr/bin/ld: V-ips.o0.o: undefined reference to symbol 'g_type_from_name'
/usr/bin/ld: /lib/x86_64-linux-gnu/libgobject-2.0.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Error: execution of command failed with exit status 1: cc "${@}" -o /home/ralsina/code/nicolino/bin/nicolino  -rdynamic

make: *** [Makefile:6: bin] Error 1

nicolino on  main [$!?] is 📦 v0.1.0 via 🔮 v1.12.2 took 46s
> vips --vips-config
enable debug: no
enable deprecated library components: yes
enable modules: no
use fftw3 for FFT: yes
accelerate loops with orc: yes
ICC profile support with lcms: yes (lcms2)
zlib: yes
text rendering with pangocairo: yes
font file support with fontconfig: yes
RAD load/save: yes
Analyze7 load/save: yes
PPM load/save: yes
GIF load:  yes
EXIF metadata support with libexif: yes
JPEG load/save with libjpeg: yes (pkg-config)
JXL load/save with libjxl: no (dynamic module: no)
JPEG2000 load/save with libopenjp2: yes
PNG load with libspng: no
PNG load/save with libpng: yes (pkg-config libpng >= 1.2.9)
quantisation to 8 bit: yes
TIFF load/save with libtiff: yes (pkg-config libtiff-4)
image pyramid save: yes
HEIC/AVIF load/save with libheif: yes (dynamic module: no)
WebP load/save with libwebp: yes
PDF load with PDFium:  no
PDF load with poppler-glib: yes (dynamic module: no)
SVG load with librsvg-2.0: yes
EXR load with OpenEXR: yes
OpenSlide load: yes (dynamic module: no)
Matlab load with matio: yes
NIfTI load/save with niftiio: no
FITS load/save with cfitsio: yes
GIF save with cgif: yes
Magick package: MagickCore (dynamic module: no)
Magick API version: magick6
load with libMagickCore: yes
save with libMagickCore: yes
naqvis commented 4 months ago

An undefined symbol error at runtime usually suggests there are multiple or conflicting versions present on the same machine, so please ensure you're using the latest dependencies and that there is one version only.

Try to run pkg-config vips --libs and verify that linked libraries are present.

ralsina commented 4 months ago

That's not at runtime, it's when doing "shards build".

Anyway, this is getting interesting :-)

> pkg-config vips --libs
Package vips was not found in the pkg-config search path.
Perhaps you should add the directory containing `vips.pc'
to the PKG_CONFIG_PATH environment variable
No package 'vips' found

Inspecting the .deb it does have .pc files, and this works:

> PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig/ pkg-config vips --libs
-L/usr/lib/x86_64-linux-gnu -lvips -lgobject-2.0 -lglib-2.0

I am just going to say the ubuntu libvips package is broken, feel free to close the issue, and thanks for your time!