Some progress and a few unexpected results:
1.Installed crlibm
from MacPorts; verified that crlibm.h
was in opt/local/includes
and libcrlibm.a
in opt/local/lib/
.
- Added the following to
cmake/Config.cmake
:
if(USE_GMP)
check_include_file(crlibm.h HAVE_CRLIBM_H)
check_library_exists(crlibm crlibm_init "" HAVE_CRLIBM)
endif()
if(HAVE_CRLIBM)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} crlibm)
endif()
so using the USE_GMP
flag as an enabler for adding crlibm
to the build (both LGPL). However cmake
can’t find the files in MacPorts even though it says it’s using the MacPorts config:
$ cmake -DCMAKE_INSTALL_PREFIX=$HOME -G Ninja ..
-- Configuring SWI-Prolog-8.5.10
-- Using Macports packages from /opt/local
-- Looking for crlibm.h
-- Looking for crlibm.h - not found
-- Looking for crlibm_init in crlibm
-- Looking for crlibm_init in crlibm - not found
-- Could NOT find Qt5Widgets (missing: Qt5Widgets_DIR)
-- Configuring done
-- Generating done
-- Build files have been written to: /Volumes/Mac Pro HD/Developer/swipl-devel/SWIP_crlibm/swipl-devel/build
Then, as a workaround, added copies of the relevant files to /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr
. and it now works (sample from stdout):
-- Looking for crlibm.h
-- Looking for crlibm.h - found
-- Looking for crlibm_init in crlibm
-- Looking for crlibm_init in crlibm - found
- Make cmake flags available to C preprocessor in
src/config.h.cmake
by adding:
#cmakedefine HAVE_CRLIBM_H @HAVE_CRLIBM_H@
#cmakedefine HAVE_CRLIBM @HAVE_CRLIBM@
- Define an unmodifiable environment flag
float_correct
that just reflects the value of HAVE_CRLIBM
to verify the above works. Required adding atom definition to ATOMS
and pl-arith.c
, i.e.,conditional #include <crlibm.h>
and initArith
function now has:
#ifdef HAVE_CRLIBM
setPrologFlag("float_correct", FT_ATOM, "true");
#else
setPrologFlag("float_correct", FT_ATOM, "false");
#endif
After rebuilding:
?- current_prolog_flag(float_correct,CR).
CR = true.
So far, so good.
- Add a call to
crlibm_init()
to initArith
. Linking now fails:
Undefined symbols for architecture x86_64:
"_crlibm_init", referenced from:
_initArith in pl-arith.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
For whatever reason (missing config, incompatible library file, ??) the linker can’t resolve crlibm_init
defined in CRlibm.h
as:
extern unsigned long long crlibm_init(void);
Any suggestions to how to get past this?