hpjansson / chafa

📺🗿 Terminal graphics for the 21st century.
https://hpjansson.org/chafa/
GNU Lesser General Public License v3.0
2.98k stars 64 forks source link

Building on macOS intel failed - Library not loaded: '@rpath/libjpeg.9.dylib' #224

Closed peterjc closed 1 month ago

peterjc commented 1 month ago

Attempting to install on macOS Intel, with many libraries installed via conda:

$ uname -srm
Darwin 21.6.0 x86_64

Fetched with git:

$ git clone https://github.com/hpjansson/chafa.git
Cloning into 'chafa'...
remote: Enumerating objects: 7986, done.
remote: Counting objects: 100% (1936/1936), done.
remote: Compressing objects: 100% (440/440), done.
remote: Total 7986 (delta 1603), reused 1674 (delta 1486), pack-reused 6050 (from 1)
Receiving objects: 100% (7986/7986), 3.20 MiB | 3.62 MiB/s, done.
Resolving deltas: 100% (5786/5786), done.
$ cd chafa/

Then ran ./autogen.sh --prefix $HOME

``` $ ./autogen.sh --prefix $HOME Running libtoolize... libtoolize: putting auxiliary files in '.'. libtoolize: copying file './ltmain.sh' libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'. libtoolize: copying file 'm4/libtool.m4' libtoolize: copying file 'm4/ltoptions.m4' libtoolize: copying file 'm4/ltsugar.m4' libtoolize: copying file 'm4/ltversion.m4' libtoolize: copying file 'm4/lt~obsolete.m4' libtoolize: Consider adding '-I m4' to ACLOCAL_AMFLAGS in Makefile.am. Missing optional tool: gtk-doc Without this, no developer documentation will be generated. Running aclocal... Running automake... configure.ac:45: installing './compile' configure.ac:15: installing './missing' chafa/Makefile.am: installing './depcomp' Running autoconf... configure.ac:57: warning: The macro `AC_PROG_CC_STDC' is obsolete. configure.ac:57: You should run autoupdate. ./lib/autoconf/c.m4:1666: AC_PROG_CC_STDC is expanded from... configure.ac:57: the top level Running ./configure --enable-maintainer-mode --prefix /Users/USERNAME ... checking for a BSD-compatible install... /Users/USERNAME/mambaforge/bin/install -c checking whether sleep supports fractional seconds... yes checking filesystem timestamp resolution... 2 checking whether build environment is sane... yes checking for a race-free mkdir -p... /Users/USERNAME/mambaforge/bin/mkdir -p checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking xargs -n works... yes checking whether make supports the include directive... yes (GNU style) checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether the compiler supports GNU C... yes checking whether gcc accepts -g... yes checking for gcc option to enable C11 features... none needed checking whether gcc understands -c and -o together... yes checking dependency style of gcc... gcc3 checking for stdio.h... yes checking for stdlib.h... yes checking for string.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for strings.h... yes checking for sys/stat.h... yes checking for sys/types.h... yes checking for unistd.h... yes checking for wchar.h... yes checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking whether _XOPEN_SOURCE should be defined... no checking whether build environment is sane... yes checking whether to enable maintainer-specific portions of Makefiles... yes checking for an ANSI C-conforming const... yes checking for gcc... (cached) gcc checking whether the compiler supports GNU C... (cached) yes checking whether gcc accepts -g... (cached) yes checking for gcc option to enable C11 features... (cached) none needed checking whether gcc understands -c and -o together... (cached) yes checking dependency style of gcc... (cached) gcc3 checking how to run the C preprocessor... gcc -E checking for ar... ar checking the archiver (ar) interface... ar checking build system type... x86_64-apple-darwin21.6.0 checking host system type... x86_64-apple-darwin21.6.0 checking how to print strings... printf checking for a sed that does not truncate output... /usr/bin/sed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for fgrep... /usr/bin/grep -F checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 786432 checking how to convert x86_64-apple-darwin21.6.0 file names to x86_64-apple-darwin21.6.0 format... func_convert_file_noop checking how to convert x86_64-apple-darwin21.6.0 file names to toolchain format... func_convert_file_noop checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r checking for file... file checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for archiver @FILE support... no checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking for sysroot... no checking for a working dd... /Users/USERNAME/mambaforge/bin/dd checking how to truncate binary pipes... /Users/USERNAME/mambaforge/bin/dd bs=4096 count=1 checking for mt... no checking if : is a manifest tool... no checking for dsymutil... dsymutil checking for nmedit... nmedit checking for lipo... lipo checking for otool... otool checking for otool64... no checking for -single_module linker flag... yes checking for -exported_symbols_list linker flag... yes checking for -force_load linker flag... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... yes checking for gcc option to produce PIC... -fno-common -DPIC checking if gcc PIC flag -fno-common -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin21.6.0 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking whether C compiler accepts -Wstack-usage=131072... no checking whether C compiler accepts -Wfor-loop-analysis... yes checking whether C compiler accepts -Wlogical-op... no checking whether C compiler accepts -Wlogical-op-parentheses... yes checking for pkg-config... /Users/USERNAME/mambaforge/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for glib-2.0 >= 2.26... yes checking for freetype2 >= 2.0.0... yes checking for libavif... no checking for libjpeg... yes checking for librsvg-2.0... yes checking for libtiff-4... yes checking for libwebp libwebpdemux... yes checking for libjxl libjxl_threads... no checking for xsltproc... /usr/bin/xsltproc checking for XML catalog (/etc/xml/catalog)... not found checking for xmlcatalog... /Users/USERNAME/mambaforge/bin/xmlcatalog checking for DocBook XML DTD V4.1.2 in XML catalog... not found checking whether to generate man pages... no checking for ctermid... yes checking for getrandom... no checking for mmap... yes checking for sigaction... yes checking for sys/ioctl.h... yes checking for termios.h... yes checking for windows.h... no checking for windres... no checking for -Bsymbolic linker flag... no checking for gcc __builtin_cpu_init function... yes checking for gcc __builtin_cpu_supports function... yes checking for working MMX intrinsics... yes checking for working SSE 4.1 intrinsics... yes checking for working AVX2 intrinsics... yes checking for working 64bit popcnt intrinsics... yes checking for working 32bit popcnt intrinsics... yes checking for -fvisibility=hidden compiler flag... yes checking whether C compiler accepts -ffast-math... yes checking that generated files are newer than configure... done checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating chafa/Makefile config.status: creating chafa/chafaconfig.h config.status: creating chafa/internal/Makefile config.status: creating chafa/internal/smolscale/Makefile config.status: creating libnsgif/Makefile config.status: creating lodepng/Makefile config.status: creating chafa.pc config.status: creating docs/Makefile config.status: creating docs/version.xml config.status: creating examples/Makefile config.status: creating tests/Makefile config.status: creating tests/data/Makefile config.status: creating tests/data/bad/Makefile config.status: creating tests/data/good/Makefile config.status: creating tools/Makefile config.status: creating tools/chafa/Makefile config.status: creating tools/completions/Makefile config.status: creating tools/fontgen/Makefile config.status: creating config.h config.status: config.h is unchanged config.status: executing depfiles commands config.status: executing libtool commands Build man page .............. no Rebuild API documentation ... no (--enable-gtk-doc) Support MMX ................. yes Support SSE 4.1 ............. yes Support AVX2 ................ yes Support popcount32 .......... yes Support popcount64 .......... yes Build command-line tool ..... yes With AVIF loader ............ no With GIF loader ............. yes (internal) With JPEG loader ............ yes With PNG loader ............. yes (internal) With QOI loader ............. yes (internal) With SVG loader ............. yes With TIFF loader ............ yes With WebP loader ............ yes With JXL loader ............. no With XWD loader ............. yes (internal) Install prefix .............. /Users/USERNAME You can now type gmake or make to build the project. Some optional libraries were not found. You may want to install these and run configure again (package names may be different on your system). On Fedora, openSUSE or similar: libavif-devel libjxl-devel On Debian, Ubuntu or similar: libavif-dev libjxl-dev ```

Then make:

``` $ make (CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh '/Users/USERNAME/repositories/chafa/missing' autoheader) rm -f stamp-h1 touch config.h.in rm -f stamp-h1 cd . && /bin/sh ./config.status config.h config.status: creating config.h config.status: config.h is unchanged /Library/Developer/CommandLineTools/usr/bin/make all-recursive Making all in chafa gcc -E -CC chafa-term-seq-doc-in.h -o chafa-term-seq-doc.h cd .. && \ /bin/sh ./config.status chafa/chafaconfig.h config.status: creating chafa/chafaconfig.h /Library/Developer/CommandLineTools/usr/bin/make all-recursive Making all in internal Making all in smolscale /bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -Wall -Wextra -Wmissing-prototypes -Wwrite-strings -Wunused-macros -Wundef -Wpointer-arith -Werror=format-security -Wfor-loop-analysis -Wlogical-op-parentheses -ffast-math -fvisibility=hidden -DSMOL_WITH_AVX2 -g -O2 -MT libsmolscale_la-smolscale.lo -MD -MP -MF .deps/libsmolscale_la-smolscale.Tpo -c -o libsmolscale_la-smolscale.lo `test -f 'smolscale.c' || echo './'`smolscale.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -Wall -Wextra -Wmissing-prototypes -Wwrite-strings -Wunused-macros -Wundef -Wpointer-arith -Werror=format-security -Wfor-loop-analysis -Wlogical-op-parentheses -ffast-math -fvisibility=hidden -DSMOL_WITH_AVX2 -g -O2 -MT libsmolscale_la-smolscale.lo -MD -MP -MF .deps/libsmolscale_la-smolscale.Tpo -c smolscale.c -fno-common -DPIC -o .libs/libsmolscale_la-smolscale.o /bin/sh ../libtool --tag=CC --mode=link gcc -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -Wall -Wextra -Wmissing-prototypes -Wwrite-strings -Wunused-macros -Wundef -Wpointer-arith -Werror=format-security -Wfor-loop-analysis -Wlogical-op-parentheses -ffast-math -fvisibility=hidden -DLODEPNG_NO_COMPILE_ENCODER -DLODEPNG_NO_COMPILE_DISK -DLODEPNG_NO_COMPILE_CPP -DLODEPNG_NO_COMPILE_CRC -I/Users/USERNAME/mambaforge/include/glib-2.0 -I/Users/USERNAME/mambaforge/lib/glib-2.0/include -I/Users/USERNAME/mambaforge/include -g -O2 -o term-info-test term-info-test.o -L/Users/USERNAME/mambaforge/lib -lglib-2.0 -lintl ../chafa/libchafa.la libtool: link: gcc -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -Wall -Wextra -Wmissing-prototypes -Wwrite-strings -Wunused-macros -Wundef -Wpointer-arith -Werror=format-security -Wfor-loop-analysis -Wlogical-op-parentheses -ffast-math -fvisibility=hidden -DLODEPNG_NO_COMPILE_ENCODER -DLODEPNG_NO_COMPILE_DISK -DLODEPNG_NO_COMPILE_CPP -DLODEPNG_NO_COMPILE_CRC -I/Users/USERNAME/mambaforge/include/glib-2.0 -I/Users/USERNAME/mambaforge/lib/glib-2.0/include -I/Users/USERNAME/mambaforge/include -g -O2 -o .libs/term-info-test term-info-test.o -L/Users/USERNAME/mambaforge/lib ../chafa/.libs/libchafa.dylib -lglib-2.0 -lintl -lm --- --- Success! You can now run tools/chafa/chafa, or install everything --- using make install or sudo make install. --- --- NOTE: You may have to run sudo ldconfig after installing. --- ```

Then make install

``` $ make install Making install in chafa /Library/Developer/CommandLineTools/usr/bin/make install-recursive Making install in internal Making install in smolscale make[5]: Nothing to be done for `install-exec-am'. make[5]: Nothing to be done for `install-data-am'. make[5]: Nothing to be done for `install-exec-am'. make[5]: Nothing to be done for `install-data-am'. /Users/USERNAME/mambaforge/bin/mkdir -p '/Users/USERNAME/lib' /bin/sh ../libtool --mode=install /Users/USERNAME/mambaforge/bin/install -c libchafa.la '/Users/USERNAME/lib' libtool: install: /Users/USERNAME/mambaforge/bin/install -c .libs/libchafa.0.dylib /Users/USERNAME/lib/libchafa.0.dylib libtool: install: (cd /Users/USERNAME/lib && { ln -s -f libchafa.0.dylib libchafa.dylib || { rm -f libchafa.dylib && ln -s libchafa.0.dylib libchafa.dylib; }; }) libtool: install: /Users/USERNAME/mambaforge/bin/install -c .libs/libchafa.lai /Users/USERNAME/lib/libchafa.la libtool: install: /Users/USERNAME/mambaforge/bin/install -c .libs/libchafa.a /Users/USERNAME/lib/libchafa.a libtool: install: chmod 644 /Users/USERNAME/lib/libchafa.a libtool: install: ranlib /Users/USERNAME/lib/libchafa.a /Users/USERNAME/mambaforge/bin/mkdir -p '/Users/USERNAME/lib/chafa/include' /Users/USERNAME/mambaforge/bin/install -c -m 644 chafaconfig.h '/Users/USERNAME/lib/chafa/include' /Users/USERNAME/mambaforge/bin/mkdir -p '/Users/USERNAME/include/chafa' /Users/USERNAME/mambaforge/bin/install -c -m 644 chafa.h chafa-canvas.h chafa-canvas-config.h chafa-common.h chafa-features.h chafa-frame.h chafa-image.h chafa-placement.h chafa-symbol-map.h chafa-term-db.h chafa-term-info.h chafa-term-seq-def.h chafa-util.h chafa-version-macros.h '/Users/USERNAME/include/chafa' Making install in docs make[2]: Nothing to be done for `install-exec-am'. Making install in examples make[2]: Nothing to be done for `install-exec-am'. make[2]: Nothing to be done for `install-data-am'. Making install in libnsgif make[2]: Nothing to be done for `install-exec-am'. make[2]: Nothing to be done for `install-data-am'. Making install in lodepng make[2]: Nothing to be done for `install-exec-am'. make[2]: Nothing to be done for `install-data-am'. Making install in tools Making install in chafa /Users/USERNAME/mambaforge/bin/mkdir -p '/Users/USERNAME/bin' /bin/sh ../../libtool --mode=install /Users/USERNAME/mambaforge/bin/install -c chafa '/Users/USERNAME/bin' libtool: install: /Users/USERNAME/mambaforge/bin/install -c .libs/chafa /Users/USERNAME/bin/chafa make[3]: Nothing to be done for `install-data-am'. Making install in fontgen make[3]: Nothing to be done for `install-exec-am'. make[3]: Nothing to be done for `install-data-am'. Making install in completions make[3]: Nothing to be done for `install-exec-am'. make[3]: Nothing to be done for `install-data-am'. make[3]: Nothing to be done for `install-exec-am'. make[3]: Nothing to be done for `install-data-am'. Making install in tests Making install in data Making install in bad make[4]: Nothing to be done for `install-exec-am'. make[4]: Nothing to be done for `install-data-am'. Making install in good make[4]: Nothing to be done for `install-exec-am'. make[4]: Nothing to be done for `install-data-am'. make[4]: Nothing to be done for `install-exec-am'. make[4]: Nothing to be done for `install-data-am'. make[3]: Nothing to be done for `install-exec-am'. make[3]: Nothing to be done for `install-data-am'. --- --- Success! You can now run tools/chafa/chafa, or install everything --- using make install or sudo make install. --- --- NOTE: You may have to run sudo ldconfig after installing. --- make[2]: Nothing to be done for `install-exec-am'. /Users/USERNAME/mambaforge/bin/mkdir -p '/Users/USERNAME/lib/pkgconfig' /Users/USERNAME/mambaforge/bin/install -c -m 644 chafa.pc '/Users/USERNAME/lib/pkgconfig' ```

Finally tried to run the tool:

$ chafa -h
dyld[47322]: Library not loaded: '@rpath/libjpeg.9.dylib'
  Referenced from: '/Users/USERNAME/bin/chafa'
  Reason: tried: '/usr/local/lib/libjpeg.9.dylib' (no such file), '/usr/lib/libjpeg.9.dylib' (no such file)
Abort trap: 6

The output of autogen.sh claims it did find libjpeg though. Presumably it found it here:

$ ls -1 ~/mambaforge/lib/libjpeg.*
/Users/USERNAME/mambaforge/lib/libjpeg.8.2.2.dylib
/Users/USERNAME/mambaforge/lib/libjpeg.8.dylib
/Users/USERNAME/mambaforge/lib/libjpeg.9.dylib
/Users/USERNAME/mambaforge/lib/libjpeg.a
/Users/USERNAME/mambaforge/lib/libjpeg.dylib
hpjansson commented 1 month ago

Thanks for the thorough report. We use pkg-config to detect most libraries, including libjpeg. You get this one, most likely due to being in your $PATH:

checking for pkg-config... /Users/USERNAME/mambaforge/bin/pkg-config

This pkg-config finds the libjpeg.dylib in its own prefix (/Users/USERNAME/mambaforge/), but when you run Chafa, /Users/USERNAME/mambaforge/lib is not in the dynamic library search path, so it can't load the library that was configured.

There are several solutions, depending on what you want:

peterjc commented 1 month ago

The first suggestion works for me, thank you:

$ DYLD_FALLBACK_LIBRARY_PATH="/$HOME/mambaforge/lib" chafa --version
Chafa version 1.15.0

Loaders:  GIF JPEG PNG QOI SVG TIFF WebP XWD
Features: mmx sse4.1 popcnt avx2
Applying: mmx sse4.1 popcnt avx2

Copyright (C) 2018-2023 Hans Petter Jansson et al.
Incl. libnsgif copyright (C) 2004 Richard Wilson, copyright (C) 2008 Sean Fox
Incl. LodePNG copyright (C) 2005-2018 Lode Vandevenne
Incl. QOI decoder copyright (C) 2021 Dominic Szablewski

This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Long term I'd prefer to install chafa from conda (and have some experience with writing recipes for conda-forge), but in the short term I will try this:

$ mv ~/bin/chafa ~/bin/.chafa
$ nano ~/bin/chafa # see below
$ chmod a+x ~/bin/chafa
$ cat ~/bin/chafa
#!/bin/bash
# Wrapper to call the real chafa binary with path magic for libjpeg
DYLD_FALLBACK_LIBRARY_PATH="/$HOME/mambaforge/lib" $HOME/bin/.chafa $@

This appears to be enough to use within offpunk https://offpunk.net/