I’m trying to run this example:
https://www.swi-prolog.org/pldoc/man?section=foreign-example
I’m using MinGW32 as the toolchain.
This is what happens:
> swipl-ld -goal true -o .\calc.c .\calc.pl -v
eval `swipl.exe --dump-runtime-variables`
PLBASE="c:/program files/swipl"
PLARCH="x64-win64"
PLSOEXT="dll"
PLLIBDIR="c:/program files/swipl/bin"
PLLIB="-lswipl"
PLTHREADS="yes"
gcc.exe -o .\calc.exe -L"c:/program files/swipl/bin" -lswipl
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
gcc.exe returned code 1
*** C:\Program Files\swipl\bin\swipl-ld.exe exit status 1
I think this may be because I’m compiling on windows with .Net installed and the inclusion of different c++ toolchains in the same PATH is messing things up.
Is there any knowledge about compiling with swipl-ld on windows? The same command works fine on WSL (ubuntu) but I think I need to compile for windows (specifically for Unity).
To clarify what I really want to do is call my Prolog code from C (eventually C++ probably). I’m not currently trying to create a foreign predicate (hence why I’m following the C example; the C++ example shows how to compile a foreign predicate).