JanWielemaker / ffi

SWI-Prolog dynamic C interface
BSD 2-Clause "Simplified" License
16 stars 6 forks source link

Compilation on mac #2

Open friguzzi opened 5 years ago

friguzzi commented 5 years ago

On a mac with os Mojave, swipl 8.1.3-26-g30498cd0a

doesn't compile, I get



% /Users/rzf/lib/swipl/bin/x86_64-darwin/swipl-ld -Wall -shared -O2 -gdwarf-2 -g3 -o lib/x86_64-darwin/ffi4pl.so c/ffi4pl.c -lffi
ERROR: In file included from c/ffi4pl.c:40:
ERROR: /Users/rzf/lib/swipl/include/SWI-Stream.h:58:10: fatal error: 'wchar.h' file not found
ERROR: #include <wchar.h>
ERROR:          ^~~~~~~~~
% 1 error generated.
% /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc returned code 256
% *** /Users/rzf/lib/swipl/bin/x86_64-darwin/swipl-ld exit status 1
% make: *** [lib/x86_64-darwin/ffi4pl.so] Error 1
ERROR: Process "process(path(make),[all])": exit status: 2
ERROR: In:
ERROR:   [14] throw(error(process_error(...,...),_14266))
ERROR:   [12] '$apply':forall(prolog_pack:member(all,...),prolog_pack:run_process(...,...,...)) at /Users/rzf/lib/swipl/boot/apply.pl:51
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 
´´´
JanWielemaker commented 5 years ago

That is a Mac setup issue. I don't know. I have a very old mac. On any normal system cc should be able to find the core header files, but I guess you need to do something different on the Mac ... Use swipl-ld -v ... to find what it is doing and try to figure out what is wrong.

friguzzi commented 5 years ago

The problem is that macOS has an old version of libffi. With brew the latest version is installed but configure gets the cc of Xcode

JanWielemaker commented 5 years ago

<wchar.h> is a standard C header that comes with the compiler and has nothing to do with libffi. I think swipl-ld calls the compiler found by CMake to compile SWI-Prolog. You might need to call the compiler some other way in MacOS, Try simple using cc from the default path.

friguzzi commented 5 years ago

Hi Jan, this is the procedure I followed for compiling on mac (look at the readme) https://github.com/friguzzi/ffi I couldn't manage to find a way to encode the process in configure.ac and Makefile in a general way. If you're satisfied with the text instructions in the README.md I will send a pull request