Errors loading the package real

Hi!
I installed the pack real. But when i try to load it with
?- ['/Users/JCRohner/.local/share/swi-prolog/pack/real/prolog/real.pl'].

I get errors:

ERROR: /Users/JCRohner/.local/share/swi-prolog/pack/real/prolog/real.pl:1832:
ERROR:    /Users/JCRohner/.local/share/swi-prolog/pack/real/prolog/real.pl:1832: Initialization goal raised exception:
ERROR:    dlopen(real, 1): image not found
ERROR:    In:
ERROR:      [60] throw(error(shared_object(open,'dlopen(real, 1): image not found'),context(...,_570)))
ERROR:      [58] <meta call>
ERROR:      [57] with_mutex('$foreign',load_foreign_library(foreign(real),real,default(install))) <foreign>
ERROR:      [54] '$run_init_goal'(shlib:load_foreign_library(...)) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:811
ERROR:      [53] catch(system:'$run_init_goal'(...),_708,system:'$initialization_error'(_730,...,...)) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:562
ERROR:      [52] catch_with_backtrace(system:'$run_init_goal'(...),_766,system:'$initialization_error'(_788,...,...)) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:629
ERROR:

Does anybody have any ideas?

Posted here instead:

Hard to say. On the github issue you also say that the pack install does not work. It is unclear where the binary comes from regarding this problem. For the install problem you give the stack trace, but not the error from the linker (hope it is there). That is what is needed to get a clue. Also important is how Prolog was installed, i.e. was this the binmary bundle, the Macports version, the Homebrew version, a self-compiled version.

The MacOS otool command can help figuring out the shared object dependencies.

Ah ok. Tried reinstalling. Below is every warning and error i get when trying to install. Thanks for the tip about ootool; i’ll try that as well.

I always install with the installers here SWI-Prolog downloads

Thanks!

/JC

?- pack_install(real).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install real@2.1 from http://stoics.org.uk/~nicos/sware/packs/real/real-2.1.tgz Y/n? 
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "real-2.1.tgz" was downloaded 137 times
Package:                real
Title:                  Integrative statistics with R
Installed version:      2.1
Author:                 Nicos Angelopoulos <http://stoics.org.uk/~nicos>, Vitor Santos Costa <http:/www.dcc.fc.up.pt/~vsc>
Maintainer:             Nicos Angelopoulos <http://stoics.org.uk/~nicos>
Packager:               Nicos Angelopoulos <http://stoics.org.uk/~nicos>
Home page:              http://stoics.org.uk/~nicos/sware/real
Download URL:           http://stoics.org.uk/~nicos/sware/packs/real/real-*.tgz
Install "real-2.1.tgz" (1,146,544 bytes) Y/n? 
% checking for swipl... swipl
% checking for swipl-ld... swipl-ld
% configure: checking "Running swipl -dump-runtime-variables"...
% swipl: Usage:
%     1) swipl [options] prolog-file ... [-- arg ...]
%     2) swipl [options] [-o executable] -c prolog-file ...
%     3) swipl --help         Display this message
%     4) swipl --version      Display version information
%     5) swipl --abi-version  Display ABI version key
%     6) swipl --arch         Display architecture
%     7) swipl --dump-runtime-variables[=format]
%                         Dump link info in sh(1) format
% 
% Options:
%     -x state                 Start from state (must be first)
%     -g goal                  Run goal (may be repeated)
%     -t toplevel              Toplevel goal
%     -f file                  User initialisation file
%     -F file                  Site initialisation file
%     -l file                  Script source file
%     -s file                  Script source file
%     -p alias=path            Define file search path 'alias'
%     -O                       Optimised compilation
%     --on-error=style         One of print, halt or status
%     --on-warning=style       One of print, halt or status
%     --tty[=bool]             (Dis)allow tty control
%     --packs[=bool]           Do (not) attach add-ons
%     --signals[=bool]         Do (not) modify signal handling
%     --threads[=bool]         Do (not) allow for threads
%     --debug[=bool]           Do (not) generate debug info
%     --debug-on-interrupt[=bool] Trap the debugger on interrupt
%     --quiet[=bool] (-q)      Do (not) suppress informational messages
%     --traditional            Disable extensions of version 7
%     --home=DIR               Use DIR as SWI-Prolog home
%     --stack-limit=size[BKMG] Specify maximum size of Prolog stacks
% "             PLBASE="
% "             PLARCH="
% "             PLLIBS="
% "             PLLDFLAGS="
% "             PLSHARED="
% "             PLSOEXT="
% checking for gmake... no
% checking for make... 
%     --table-space=size[BKMG] Specify maximum size of SLG tables
%     --shared-table-space=size[BKMG] Maximum size of shared SLG tables
%     --pce[=bool]             Make the xpce gui available
%     --pldoc[=port]           Start PlDoc server [at port]
% 
% Boolean options may be written as --name=bool, --name, --no-name or --noname.
% Both '-' or '_' are accepted as word-separator for long options.
% make
% checking for etags... 
% no
% checking for ctags... 
% ctags
% checking for a BSD-compatible install... 
% /usr/bin/install -c
% checking for gcc... 
% swipl-ld
% 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 we are using the GNU C compiler... 
% yes
% checking whether swipl-ld accepts -g... 
% yes
% checking for swipl-ld option to accept ISO C89... 
% none needed
% checking for library containing strerror... 
% none required
% checking how to run the C preprocessor... 
% swipl-ld -E
% checking for grep that handles long lines and -e... 
% /usr/bin/grep
% checking for egrep... 
% /usr/bin/grep -E
% checking for ANSI C header files... 
% yes
% checking for sys/types.h... 
% yes
% checking for sys/stat.h... 
% yes
% checking for stdlib.h... 
% yes
% checking for string.h... 
% yes
% checking for memory.h... 
% yes
% checking for strings.h... 
% yes
% checking for inttypes.h... 
% yes
% checking for stdint.h... 
% yes
% checking for unistd.h... 
% yes
% checking for size_t... 
% yes
% checking for working alloca.h... 
% yes
% checking for alloca... 
% yes
% checking whether byte ordering is bigendian... 
% no
% checking for R... 
% R
% checking Rinterface.h usability... 
% yes
% checking Rinterface.h presence... 
% yes
% checking for Rinterface.h... yes
% configure: creating ./config.status
% config.status: creating Makefile
% config.status: creating config.h
% gcc -fPIC -pthread -I"/Applications/SWI-Prolog.app/Contents/swipl/include" -std=c99 -I/Library/Frameworks/R.framework/Resources/include  -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -L/usr/local/lib -lpcre2-8 -llzma -lbz2 -lz -licucore -ldl -lm -liconv -L/usr/local/Cellar/xz/5.2.5/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: -lpcre2-8: '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: warning: -ldl: '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]
Warning: clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
Warning: clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
Warning: clang: warning: argument unused during compilation: '-L/usr/local/Cellar/xz/5.2.5/lib' [-Wunused-command-line-argument]
Warning: In file included from c/real.c:2:
Warning: /Applications/SWI-Prolog.app/Contents/swipl/include/SWI-Prolog.h:217:26: warning: redefinition of typedef 'IOSTREAM' is a C11 feature [-Wtypedef-redefinition]
% typedef struct io_stream IOSTREAM;      /* fully defined in SWI-Stream.h */
%                          ^
% /Applications/SWI-Prolog.app/Contents/swipl/include/SWI-Stream.h:230:3: note: previous definition is here
% } IOSTREAM;
%   ^
Warning: c/real.c:338:46: warning: incompatible pointer types passing 'int *' to parameter of type 'size_t *' (aka 'unsigned long *') [-Wincompatible-pointer-types]
Warning:            if (!PL_get_name_arity(t, &tname, &ans) || ans<= 0) {
Warning:                                              ^~~~
Warning: /Applications/SWI-Prolog.app/Contents/swipl/include/SWI-Prolog.h:1361:59: note: expanded from macro 'PL_get_name_arity'
Warning: #define PL_get_name_arity(t,n,a) PL_get_name_arity_sz(t,n,a)
Warning:                                                           ^
Warning: /Applications/SWI-Prolog.app/Contents/swipl/include/SWI-Prolog.h:534:19: note: passing argument to parameter 'arity' here
Warning:                                              size_t *arity) WUNUSED;
Warning:                                                      ^
Warning: c/real.c:355:40: warning: incompatible pointer types passing 'int *' to parameter of type 'size_t *' (aka 'unsigned long *') [-Wincompatible-pointer-types]
Warning:   if ( !PL_get_name_arity(cols, &name, &arity) || arity <=0 || arity < i   )
Warning:                                        ^~~~~~
Warning: /Applications/SWI-Prolog.app/Contents/swipl/include/SWI-Prolog.h:1361:59: note: expanded from macro 'PL_get_name_arity'
Warning: #define PL_get_name_arity(t,n,a) PL_get_name_arity_sz(t,n,a)
Warning:                                                           ^
Warning: /Applications/SWI-Prolog.app/Contents/swipl/include/SWI-Prolog.h:534:19: note: passing argument to parameter 'arity' here
Warning:                                              size_t *arity) WUNUSED;
Warning:                                                      ^
Warning: c/real.c:886:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
Warning:     PL_put_term(t, tail);
Warning:     ^~~~~~~~~~~ ~~~~~~~
Warning: c/real.c:906:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
Warning:     PL_put_term(t, tail);
Warning:     ^~~~~~~~~~~ ~~~~~~~
Warning: c/real.c:920:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
Warning:     PL_put_term(t, tail);
Warning:     ^~~~~~~~~~~ ~~~~~~~
Warning: c/real.c
Warning: :951:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
Warning:     PL_put_term(t, tail);
Warning:     ^~~~~~~~~~~ ~~~~~~~
Warning: c/real.c:966:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
Warning:     PL_put_term(t, tail);
Warning:     ^~~~~~~~~~~ ~~~~~~~
Warning: c/real.c:1030:7: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
Warning:       PL_put_term(t, tail);
Warning:       ^~~~~~~~~~~ ~~~~~~~
Warning: c/real.c:1142:40: warning: incompatible pointer types passing 'int *' to parameter of type 'size_t *' (aka 'unsigned long *') [-Wincompatible-pointer-types]
Warning:   if ( !PL_get_name_arity(tvec, &name, &arity) ||
%                                        ^~~~~~
% /Applications/SWI-Prolog.app/Contents/swipl/include/SWI-Prolog.h:1361:59: note: expanded from macro 'PL_get_name_arity'
% #define PL_get_name_arity(t,n,a) PL_get_name_arity_sz(t,n,a)
%                                                           ^
% /Applications/SWI-Prolog.app/Contents/swipl/include/SWI-Prolog.h:534:19: note: passing argument to parameter 'arity' here
%                                              size_t *arity) WUNUSED;
%                                                      ^
% 10 warnings generated.
% mkdir -p lib/x86_64-darwin
% cc  -shared -L"/Applications/SWI-Prolog.app/Contents/Frameworks" -lswipl -o lib/x86_64-darwin/real.so c/real.o  -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -L/usr/local/lib -lpcre2-8 -llzma -lbz2 -lz -licucore -ldl -lm -liconv -L/usr/local/Cellar/xz/5.2.5/lib -llzma
% ld: library not found for -lpcre2-8
ERROR: clang: error: linker command failed with exit code 1 (use -v to see invocation)
% make: *** [lib/x86_64-darwin/real.so] Error 1
ERROR: Process "process(/usr/bin/make,[])": exit status: 2
ERROR: In:
ERROR:   [26] throw(error(process_error(...,...),_28982))
ERROR:   [22] build_tools:build_step(build,_29026{bin_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',env:[...|...],inquiry:true,pack:real,pack_version:1,src_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',url:'http://stoics.org.uk/~nicos/sware/packs/real/real-2.1.tgz'},_29026{bin_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',env:[...|...],inquiry:true,pack:real,pack_version:1,src_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',url:'http://stoics.org.uk/~nicos/sware/packs/real/real-2.1.tgz'}) at /Applications/SWI-Prolog.app/Contents/swipl/library/build/tools.pl:110
ERROR:   [21] apply:foldl_([build,...|...],build_tools:build_step,_29026{bin_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',env:[...|...],inquiry:true,pack:real,pack_version:1,src_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',url:'http://stoics.org.uk/~nicos/sware/packs/real/real-2.1.tgz'},_29134) at /Applications/SWI-Prolog.app/Contents/swipl/library/apply.pl:316
ERROR:   [17] build_tools:build_steps('<garbage_collected>','/Users/JCRohner/.local/share/swi-prolog/pack/real','<garbage_collected>') at /Applications/SWI-Prolog.app/Contents/swipl/library/build/tools.pl:103
ERROR:   [16] prolog_pack:post_install_foreign(real,'/Users/JCRohner/.local/share/swi-prolog/pack/real','<garbage_collected>') at /Applications/SWI-Prolog.app/Contents/swipl/library/prolog_pack.pl:1164
ERROR:   [15] prolog_pack:pack_post_install(real,'/Users/JCRohner/.local/share/swi-prolog/pack/real',[inquiry(true),...|...]) at /Applications/SWI-Prolog.app/Contents/swipl/library/prolog_pack.pl:1102
ERROR:    [9] toplevel_call('<garbage_collected>') at /Applications/SWI-Prolog.app/Contents/swipl/boot/toplevel.pl:1162
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.
   Exception: (22) build_tools:build_step(build, _88{bin_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real', env:['PATH'='/Applications/SWI-Prolog.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/SWI-Prolog.app/Contents/MacOS:$PATH:/Library/TeX/texbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands', 'SWIPL'='/Applications/SWI-Prolog.app/Contents/MacOS/swipl', 'SWIPL_PACK_VERSION'=1, 'SWIPLVERSION'=80508, 'SWIHOME'='/Applications/SWI-Prolog.app/Contents/swipl', ... = ...|...], inquiry:true, pack:real, pack_version:1, src_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real', url:'http://stoics.org.uk/~nicos/sware/packs/real/real-2.1.tgz'}, _20462) ? creep

Hmm. That is a bug that was fixed in the latest git version of real at GitHub - nicos-angelopoulos/real: Integrative statistics with R and logic programming

@nicos, is the archive not updated?

@jan
No 2.1 does n’t the have the patch, creating windows binaries is
always an effort. However as the user is compiling from source they
can do that from github.

@JCR, have you tried to clone the real github and then from within the
real directory issue
?- pack_install(’.’).

?

Regards,

Nicos

1 Like

Thanks for responding. I tried what you suggested.

  1. I went to GitHub - SWI-Prolog/packages-real: R..eal: native Prolog<->R interface
  2. I chose “Clone” and “Download zip”
  3. From swipl i CDed to packages-real-master/
  4. I did pack_install('.').

Then i got the errors below. I’m on MacOS 10.15.7 with SWI-Prolog (threaded, 64 bits, version 8.5.8).

I am sorry but i can’t decipher what’s wrong.

?- pack_install('.').
ERROR: source_sink `pack_build_path(autoheader)' does not exist
ERROR: In:
ERROR:   [30] throw(error(existence_error(source_sink,...),_19042))
ERROR:   [26] process:process_create(pack_build_path(autoheader),[],[stdout(...),...|...]) at /Applications/SWI-Prolog.app/Contents/swipl/library/process.pl:270
ERROR:   [25] build_tools:run_process(pack_build_path(autoheader),[],[directory('/Users/JCRohner/.local/share/swi-prolog/pack/real'),...]) at /Applications/SWI-Prolog.app/Contents/swipl/library/build/tools.pl:528
ERROR:   [24] setup_call_catcher_cleanup(build_tools:b_setval('$build_tool_env',...),build_tools:run_process(...,[],...),_19184,build_tools:nb_delete('$build_tool_env')) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:663
ERROR:   [22] build_tools:run_process(path(autoheader),[],[directory('/Users/JCRohner/.local/share/swi-prolog/pack/real'),...]) at /Applications/SWI-Prolog.app/Contents/swipl/library/build/tools.pl:517
ERROR:   [21] prolog:build_step(configure,autoconf,'<garbage_collected>',_19316{bin_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',env:[...|...],link:true,pack:real,pack_version:1,rebuild:make,src_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',url:'file:///Users/JCRohner/Downloads/packages-real-master/',version:'1.1.0'}) at /Applications/SWI-Prolog.app/Contents/swipl/library/build/make.pl:83
ERROR:   [20] build_tools:build_step([configure],_19316{env:[...|...],link:true,pack:real,pack_version:1,rebuild:make,src_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',url:'file:///Users/JCRohner/Downloads/packages-real-master/',version:'1.1.0'},_19316{bin_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',env:[...|...],link:true,pack:real,pack_version:1,rebuild:make,src_dir:'/Users/JCRohner/.local/share/swi-prolog/pack/real',url:'file:///Users/JCRohner/Downloads/packages-real-master/',version:'1.1.0'}) at /Applications/SWI-Prolog.app/Contents/swipl/library/build/tools.pl:110
ERROR:   [19] apply:foldl_('<garbage_collected>',build_tools:build_step,'<garbage_collected>',_19522) at /Applications/SWI-Prolog.app/Contents/swipl/library/apply.pl:316
ERROR:   [16] build_tools:build_steps('<garbage_collected>','/Users/JCRohner/.local/share/swi-prolog/pack/real','<garbage_collected>') at /Applications/SWI-Prolog.app/Contents/swipl/library/build/tools.pl:103
ERROR:   [15] prolog_pack:post_install_foreign(real,'/Users/JCRohner/.local/share/swi-prolog/pack/real','<garbage_collected>') at /Applications/SWI-Prolog.app/Contents/swipl/library/prolog_pack.pl:1164
ERROR:   [14] prolog_pack:pack_post_install(real,'/Users/JCRohner/.local/share/swi-prolog/pack/real',[link(true),...|...]) at /Applications/SWI-Prolog.app/Contents/swipl/library/prolog_pack.pl:1102
ERROR:    [9] toplevel_call('<garbage_collected>') at /Applications/SWI-Prolog.app/Contents/swipl/boot/toplevel.pl:1162
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.
^  Exception: (24) setup_call_catcher_cleanup(build_tools:b_setval('$build_tool_env', ['PATH'='/Applications/SWI-Prolog.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/SWI-Prolog.app/Contents/MacOS:$PATH:/Library/TeX/texbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands', 'SWIPL'='/Applications/SWI-Prolog.app/Contents/MacOS/swipl', 'SWIPL_PACK_VERSION'=1, 'SWIPLVERSION'=80508, 'SWIHOME'='/Applications/SWI-Prolog.app/Contents/swipl', ... = ...|...]), build_tools:run_process(pack_build_path(autoheader), [], [directory('/Users/JCRohner/.local/share/swi-prolog/pack/real'), env(['PATH'='/Applications/SWI-Prolog.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/SWI-Prolog.app/Contents/MacOS:$PATH:/Library/TeX/texbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands', 'SWIPL'='/Applications/SWI-Prolog.app/Contents/MacOS/swipl', ... = ...|...])]), _55092, build_tools:nb_delete('$build_tool_env')) ?

It is telling you it cannot find autoconf. The issue is that you are using an old abandoned repository. Use GitHub - nicos-angelopoulos/real: Integrative statistics with R and logic programming instead.

I have deleted the old one.

OK i downloaded the new one, CDed to the directory and did pack_install('.').. It gets further now but still doesn’t work. Is the problem ld: library not found for -lpcre2-8?
Thanks/JC

?- pack_install('.').
% checking for swipl... swipl
% checking for swipl-ld... swipl-ld
% configure: checking "Running swipl --dump-runtime-variables"...
% "             PLBASE=/Applications/SWI-Prolog.app/Contents/swipl"
% "             PLARCH=x86_64-darwin"
% "             PLLIBS="
% "             PLLDFLAGS="
% "             PLSHARED=yes"
% "             PLSOEXT=so"
% checking for gmake... 
% no
% checking for make... 
% make
% checking for etags... 
% no
% checking for ctags... 
% ctags
% checking for a BSD-compatible install... 
% /usr/bin/install -c
% checking for gcc... 
% swipl-ld
% 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 we are using the GNU C compiler... 
% yes
% checking whether swipl-ld accepts -g... 
% yes
% checking for swipl-ld option to accept ISO C89... 
% none needed
% checking for library containing strerror... 
% none required
% checking how to run the C preprocessor... 
% swipl-ld -E
% checking for grep that handles long lines and -e... 
% /usr/bin/grep
% checking for egrep... 
% /usr/bin/grep -E
% checking for ANSI C header files... 
% yes
% checking for sys/types.h... 
% yes
% checking for sys/stat.h... 
% yes
% checking for stdlib.h... 
% yes
% checking for string.h... 
% yes
% checking for memory.h... 
% yes
% checking for strings.h... 
% yes
% checking for inttypes.h... 
% yes
% checking for stdint.h... 
% yes
% checking for unistd.h... 
% yes
% checking for size_t... 
% yes
% checking for working alloca.h... 
% yes
% checking for alloca... 
% yes
% checking whether byte ordering is bigendian... 
% no
% checking for R... 
% R
% checking Rinterface.h usability... 
% yes
% checking Rinterface.h presence... 
% yes
% checking for Rinterface.h... 
% yes
% configure: creating ./config.status
% config.status: creating Makefile
% config.status: creating config.h
% gcc -fPIC -pthread -I"/Applications/SWI-Prolog.app/Contents/swipl/include" -std=c99 -I/Library/Frameworks/R.framework/Resources/include  -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -L/usr/local/lib -lpcre2-8 -llzma -lbz2 -lz -licucore -ldl -lm -liconv -L/usr/local/Cellar/xz/5.2.5/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: -lpcre2-8: '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: -ldl: 'linker' input unused [-Wunused-command-line-argument]
Warning: 
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]
Warning: clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
Warning: clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
Warning: clang: warning: argument unused during compilation: '-L/usr/local/Cellar/xz/5.2.5/lib' [-Wunused-command-line-argument]
Warning: In file included from c/real.c:2:
Warning: /Applications/SWI-Prolog.app/Contents/swipl/include/SWI-Prolog.h:217:26: warning: redefinition of typedef 'IOSTREAM' is a C11 feature [-Wtypedef-redefinition]
% typedef struct io_stream IOSTREAM;      /* fully defined in SWI-Stream.h */
%                          ^
% /Applications/SWI-Prolog.app/Contents/swipl/include/SWI-Stream.h:230:3: note: previous definition is here
% } IOSTREAM;
%   ^
% 1 warning generated.
% mkdir -p lib/x86_64-darwin
% cc  -shared -L"/Applications/SWI-Prolog.app/Contents/Frameworks" -lswipl -o lib/x86_64-darwin/real.so c/real.o  -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -L/usr/local/lib -lpcre2-8 -llzma -lbz2 -lz -licucore -ldl -lm -liconv -L/usr/local/Cellar/xz/5.2.5/lib -llzma
% ld: library not found for -lpcre2-8
ERROR: clang: error: linker command failed with exit code 1 (use -v to see invocation)
% make: *** [lib/x86_64-darwin/real.so] Error 1
ERROR: Process "process(/usr/bin/make,[])": exit status: 2
ERROR: In:
ERROR:   [25] throw(error(process_error(...,...),_23230))
ERROR:   [21] build_tools:build_step(build,_23274{bin_dir:'/Users/XXX/.local/share/swi-prolog/pack/real',env:[...|...],link:true,pack:real,pack_version:1,rebuild:make,src_dir:'/Users/XXX/.local/share/swi-prolog/pack/real',url:'file:///Users/XXX/Downloads/real-master/',version:'2.1'},_23274{bin_dir:'/Users/XXX/.local/share/swi-prolog/pack/real',env:[...|...],link:true,pack:real,pack_version:1,rebuild:make,src_dir:'/Users/XXX/.local/share/swi-prolog/pack/real',url:'file:///Users/XXX/Downloads/real-master/',version:'2.1'}) at /Applications/SWI-Prolog.app/Contents/swipl/library/build/tools.pl:110
ERROR:   [20] apply:foldl_([build,...|...],build_tools:build_step,_23274{bin_dir:'/Users/XXX/.local/share/swi-prolog/pack/real',env:[...|...],link:true,pack:real,pack_version:1,rebuild:make,src_dir:'/Users/XXX/.local/share/swi-prolog/pack/real',url:'file:///Users/XXX/Downloads/real-master/',version:'2.1'},_23398) at /Applications/SWI-Prolog.app/Contents/swipl/library/apply.pl:316
ERROR:   [16] build_tools:build_steps('<garbage_collected>','/Users/XXX/.local/share/swi-prolog/pack/real','<garbage_collected>') at /Applications/SWI-Prolog.app/Contents/swipl/library/build/tools.pl:103
ERROR:   [15] prolog_pack:post_install_foreign(real,'/Users/XXX/.local/share/swi-prolog/pack/real','<garbage_collected>') at /Applications/SWI-Prolog.app/Contents/swipl/library/prolog_pack.pl:1164
ERROR:   [14] prolog_pack:pack_post_install(real,'/Users/XXX/.local/share/swi-prolog/pack/real',[link(true),...|...]) at /Applications/SWI-Prolog.app/Contents/swipl/library/prolog_pack.pl:1102
ERROR:    [9] toplevel_call('<garbage_collected>') at /Applications/SWI-Prolog.app/Contents/swipl/boot/toplevel.pl:1162
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.
   Exception: (21) build_tools:build_step(build, _108{bin_dir:'/Users/XXX/.local/share/swi-prolog/pack/real', env:['PATH'='/Applications/SWI-Prolog.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/SWI-Prolog.app/Contents/MacOS:$PATH:/Library/TeX/texbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands', 'SWIPL'='/Applications/SWI-Prolog.app/Contents/MacOS/swipl', 'SWIPL_PACK_VERSION'=1, 'SWIPLVERSION'=80508, 'SWIHOME'='/Applications/SWI-Prolog.app/Contents/swipl', ... = ...|...], link:true, pack:real, pack_version:1, rebuild:make, src_dir:'/Users/XXX/.local/share/swi-prolog/pack/real', url:'file:///Users/XXX/Downloads/real-master/', version:'2.1'}, _20246) ?

This is where things get hard. The libraries come from this though:

 R CMD config --ldflags

as you can find in configs/configure.in. You can probably install pcre2 using Homebrew or Macports.

Note that you can more easily debug by going to the real directory, load buildenv.sh into your shell (using source buildenv.sh), after which you can run make, etc. from the commandline.

1 Like

Thanks for you help! I’ll make some more attempts.