Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installation from source fails on arm64 if incompatible /usr/local/lib/libpng.dylib exists #169

Open
kevinushey opened this issue Jul 26, 2023 · 2 comments

Comments

@kevinushey
Copy link

For reference, the installation log:

* installing *source* package ‘svglite’ ...
** package ‘svglite’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C++ compiler: ‘Apple clang version 14.0.3 (clang-1403.0.22.14.1)’
using C++11
using SDK: ‘’
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Users/kevin/Library/R/arm64/4.3/library/cpp11/include' -I'/Users/kevin/Library/R/arm64/4.3/library/systemfonts/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c cpp11.cpp -o cpp11.o
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Users/kevin/Library/R/arm64/4.3/library/cpp11/include' -I'/Users/kevin/Library/R/arm64/4.3/library/systemfonts/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c devSVG.cpp -o devSVG.o
clang++ -arch arm64 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o svglite.so cpp11.o devSVG.o -lpng -lz -L/opt/homebrew/opt/libomp/lib -lomp -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: ignoring file /usr/local/lib/libpng.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
installing to /Users/kevin/Library/R/arm64/4.3/library/00LOCK-svglite/00new/svglite/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘svglite’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/kevin/Library/R/arm64/4.3/library/00LOCK-svglite/00new/svglite/libs/svglite.so':
  dlopen(/Users/kevin/Library/R/arm64/4.3/library/00LOCK-svglite/00new/svglite/libs/svglite.so, 0x0006): symbol not found in flat namespace '_png_create_info_struct'
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/kevin/Library/R/arm64/4.3/library/svglite’
Warning in install.packages("svglite", type = "source") :
  installation of package 'svglite' had non-zero exit status

Would it be worth including a configure script that prefers libraries found in /opt/homebrew/lib if on arm64 macOS?

@kevinushey
Copy link
Author

(you could also argue it's my fault for having both an x86_64 installation of Homebrew in /usr/local, as well as the regular arm64 installation in /opt/homebrew ...)

@DavisVaughan
Copy link
Member

I also have this issue!

I think systemfonts gets around this by having a configure script that generates the Makevars:
https://github.com/r-lib/systemfonts/blob/main/configure
https://github.com/r-lib/systemfonts/blob/main/src/Makevars.in

which for me makes:

CXX_STD = CXX11

PKG_CPPFLAGS=-I/opt/homebrew/opt/freetype/include/freetype2 -I/opt/homebrew/opt/libpng/include/libpng16
PKG_OBJCXXFLAGS=-fobjc-arc

DARWIN_LIBS = -framework CoreText -framework Foundation
DARWIN_OBJECTS = mac/FontManagerMac.o
UNIX_OBJECTS = unix/FontManagerLinux.o

PKG_LIBS = -L/opt/homebrew/opt/freetype/lib -L/opt/homebrew/opt/libpng/lib -lfreetype -lbz2 -lpng16 -lz $(DARWIN_LIBS)
OBJECTS = caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o \
  ft_cache.o string_shape.o font_metrics.o font_fallback.o string_metrics.o \
  emoji.o cache_store.o init.o $(DARWIN_OBJECTS)

all: clean

clean:
	rm -f $(SHLIB) $(OBJECTS)

and that works well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants