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

Error installing xml2 from source in Apple Silicon (Macbook Air M2) #420

Closed
can-taslicukur opened this issue Nov 24, 2023 · 1 comment
Closed

Comments

@can-taslicukur
Copy link

This is the error I get when I try to install the package from the terminal (I am not using RStudio).

r$> install.packages("xml2")

Content type 'application/x-gzip' length 272664 bytes (266 KB)
==================================================
downloaded 266 KB

* installing *source* packagexml2...
** packagexml2successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/opt/homebrew/Cellar/libxml2/2.12.0/include/libxml2
Using PKG_LIBS=-L/opt/homebrew/Cellar/libxml2/2.12.0/lib -lxml2 -lz -L/opt/homebrew/Cellar/icu4c/73.2/lib -licui18n -licuuc -licudata -liconv
** libs
using C compiler:Apple clang version 15.0.0 (clang-1500.0.40.1)’
using C++ compiler:Apple clang version 15.0.0 (clang-1500.0.40.1)’
using SDK: ‘’
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I/opt/homebrew/Cellar/libxml2/2.12.0/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -I/opt/homebrew/include -I/opt/homebrew/opt/libomp/include -Xclang -fopenmp -I/opt/homebrew/opt/libxml2/include    -fPIC  -I/opt/homebrew/include -c connection.cpp -o connection.o
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I/opt/homebrew/Cellar/libxml2/2.12.0/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -I/opt/homebrew/include -I/opt/homebrew/opt/libomp/include -Xclang -fopenmp -I/opt/homebrew/opt/libxml2/include    -fPIC  -I/opt/homebrew/include -c init.c -o init.o
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I/opt/homebrew/Cellar/libxml2/2.12.0/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -I/opt/homebrew/include -I/opt/homebrew/opt/libomp/include -Xclang -fopenmp -I/opt/homebrew/opt/libxml2/include    -fPIC  -I/opt/homebrew/include -c xml2_doc.cpp -o xml2_doc.o
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I/opt/homebrew/Cellar/libxml2/2.12.0/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0  -I/opt/homebrew/include -I/opt/homebrew/opt/libomp/include -Xclang -fopenmp -I/opt/homebrew/opt/libxml2/include    -fPIC  -I/opt/homebrew/include -c xml2_init.cpp -o xml2_init.o
xml2_init.cpp:46:3: error: no matching function for call to 'xmlSetStructuredErrorFunc'
  xmlSetStructuredErrorFunc(NULL, handleStructuredError);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/libxml2/2.12.0/include/libxml2/libxml/xmlerror.h:897:5: note: candidate function not viable: no known conversion from 'void (void *, xmlError *)' (aka 'void (void *, _xmlError *)') to 'xmlStructuredErrorFunc' (aka 'void (*)(void *, const _xmlError *)') for 2nd argument
    xmlSetStructuredErrorFunc   (void *ctx,
    ^
1 error generated.
make: *** [xml2_init.o] Error 1
ERROR: compilation failed for packagexml2* removing/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/xml2* restoring previous/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/xml2The downloaded source packages are in/private/var/folders/4z/ml235hpn6ld_6664zy4mb8j00000gn/T/Rtmpnp1LHS/downloaded_packagesWarning message:
In install.packages("xml2") :
  installation of packagexml2had non-zero exit status

I have installed libxml2 via Homebrew and applied post-installation instructions. E.g
In .R/Makevars I've added:

LDFLAGS += -L/opt/homebrew/opt/libxml2/lib
CPPFLAGS += -I/opt/homebrew/opt/libxml2/include

In .zshrc :

export PATH="/opt/homebrew/opt/libxml2/bin:$PATH"

export PKG_CONFIG_PATH="/opt/homebrew/opt/libxml2/lib/pkgconfig"
@can-taslicukur can-taslicukur changed the title Error installing xml2 from source in Apple Silicon Error installing xml2 from source in Apple Silicon (Macbook Air M2) Nov 24, 2023
@hadley
Copy link
Member

hadley commented Nov 30, 2023

Fixed by #417

@hadley hadley closed this as completed Nov 30, 2023
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