Error installing 'real' package on MacOS

I’m getting an error trying to install the ‘real’ package on MacOS (Connecting SWI-Prolog 8.1.1 to R).
The error is in configure:2937: error: C compiler cannot create executables

I’m running as sudo.

Any advice is appreciated.

The relevant part from config. is:
configure:2826: checking for C compiler version
configure:2835: swipl-ld --version >&5
clang: The build tool has reset ENV; --env=std required.
/usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang returned code 256
*** swipl-ld exit status 1
configure:2846: ? = 1 configure:2835: swipl-ld -v >&5 clang: The build tool has reset ENV; --env=std required. /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang returned code 256 *** swipl-ld exit status 1 configure:2846: ? = 1
configure:2835: swipl-ld -V >&5
clang: The build tool has reset ENV; --env=std required.
/usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang returned code 256
*** swipl-ld exit status 1
configure:2846: ? = 1 configure:2835: swipl-ld -qversion >&5 clang: The build tool has reset ENV; --env=std required. /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang returned code 256 *** swipl-ld exit status 1 configure:2846: ? = 1
configure:2866: checking whether the C compiler works
configure:2888: swipl-ld -fPIC -pthread -I"/usr/local/Cellar/swipl/8.1.1/lib/swipl/include" conftest.c >&5
clang: The build tool has reset ENV; --env=std required.
/usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang returned code 256
*** swipl-ld exit status 1
configure:2892: $? = 1
configure:2930: result: no
configure: failed program was:
| /* confdefs.h /
| #define PACKAGE_NAME “”
| #define PACKAGE_TARNAME “”
| #define PACKAGE_VERSION “”
| #define PACKAGE_STRING “”
| #define PACKAGE_BUGREPORT “”
| #define PACKAGE_URL “”
| /
end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:2935: error: in `/usr/local/Cellar/swipl/8.1.1/lib/swipl/pack/real’:
configure:2937: error: C compiler cannot create executables

Seems Brew redefines the environment and/or clang. It is a little hard to debug without a Mac, but clang: The build tool has reset ENV; --env=std required gives a lot of hints.

The Prolog pack system provides the prolog_pack:environment/2 hook to extend the build environment. See http://www.swi-prolog.org/pldoc/doc_for?object=prolog_pack%3Aenvironment/2

If you figure out what needs to be passed, please add it to this topic or create a pull request to update the default rules in library(prolog_pack).

A different error also occurs on macOS 10.14.3 when using a manually installed swipl-devel git version:

?- pack_install(real).
...
% gcc -fPIC -pthread -I"/Users/pmoura/lib/swipl/include" -std=c99 -I/Library/Frameworks/R.framework/Resources/include -fopenmp -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -lpcre -llzma -lbz2 -lz -licucore -lm -liconv -L/opt/local/lib -llzma -c -o c/real.o c/real.c
Warning: clang: warning: -framework R: 'linker' input unused [-Wunused-command-line-argument]
Warning: clang: warning: -lpcre: 'linker' input unused [-Wunused-command-line-argument]
Warning: clang: warning: -llzma: 'linker' input unused [-Wunused-command-line-argument]
Warning: clang: warning: -lbz2: 'linker' input unused [-Wunused-command-line-argument]
Warning: clang: warning: -lz: 'linker' input unused [-Wunused-command-line-argument]
Warning: clang: warning: -licucore: 'linker' input unused [-Wunused-command-line-argument]
Warning: clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
Warning: clang: warning: -liconv: 'linker' input unused [-Wunused-command-line-argument]
Warning: clang: warning: -llzma: 'linker' input unused [-Wunused-command-line-argument]
ERROR: clang: error: unsupported option '-fopenmp'
% make: *** [c/real.o] Error 1

The error installing the real package also seems to expose a bug in the handling of packs. After the failure above, I get:

$ swipl
Warning: Package real: no binary for architecture x86_64-darwin
Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.1-18-g6b8c96f10)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- pack_remove(real).
ERROR: pack `real' does not exist
ERROR: In:
ERROR:   [11] throw(error(existence_error(pack,real),_590))
ERROR:   [10] '$pack':'$pack_detach'(real,_628) at /Users/pmoura/lib/swipl/boot/packs.pl:67
ERROR:    [9] prolog_pack:pack_remove_forced(real) at /Users/pmoura/lib/swipl/library/prolog_pack.pl:1442
ERROR:    [7] <user>
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.

I.e. I get a warning at startup that a pack is not functional but then trying to remove it generates and error.

Thanks. Pushed 0521ad37993ac287017aeb85bf357fe4666e3ee3 to resolve this. Note that removing a package simply removes the directory. If it is an attached package it also removes the library directory, but as the directory doesn’t exist any longer that isn’t even necessary.

Thanks for the quick fix. Tested and confirmed.