Closed HayatoTenryuu closed 2 months ago
The message seems to say that you don't have a proper executable -- possibly there's a missing DLL in your dynamic load path?
This is what I did on Linux (I don't know the equivalent on Windows) ... the only difference I see is that I called my executable likes.exe
, which isn't necessary on Linux but which might be necessary on Windows and the "loaded" messages are slightly different:
$ swipl-ld -o likes.exe likes.cpp likes.pl
% Disabled autoloading (loaded 34 files)
% Disabled autoloading (loaded 5 files)
% Disabled autoloading (loaded 0 files)
% halt
$ ./likes.exe mary
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.8-27-g80f956be2-DIRTY)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
mary likes:
john
potplants
jane
paul
Heartbreak High
sunbathing
$ ldd ./likes.exe
linux-vdso.so.1 (0x00007ffe9deed000)
libswipl.so.9 => /home/peter/.local/lib/swipl/lib/x86_64-linux/libswipl.so.9 (0x00007f012cd27000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f012ca00000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f012ccf1000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f012c81f000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f012ccbe000)
libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f012cc3b000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f012cc1c000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f012c740000)
/lib64/ld-linux-x86-64.so.2 (0x00007f012ced0000)
So, apparently this error only shows up when I try to double-click the exe file. The "disabled autoloading" messages are the same regardless of whether I type ".exe" or not.
When I run it from the terminal as ".\likes mary" or "./likes.exe mary" or any combination of slashes and inclusion/exclusion of ".exe", it just does nothing.
You need the folder holding libswipl.dll, etc, in %PATH%
. I'm not sure that is enough on modern Windows. You may need to copy likes.exe
to this folder or copy the required dlls to the folder holding likes.exe
.
You may want to put your call to likes.exe
into a likes.bat
file that adds the folder with liswipl.dll
to the PATH
(or %PATH%
or whatever Windows does). You can also pass additional parameters to the C++ compiler and linker as described in the swipl-ld
manual page (e.g., there might be a Windows equivalent of -ld-options,-Bstatic
, although this doesn't seem to make any difference on Linux). Specifying -v
to swipl-ld
might give you additional insights.
I don't know enough computer-fu to see anything wrong, except one possible thing which is that I am using 64-bit. My Prolog should also be 64 bit though. Is the master branch of this repo incompatible with x64? I do see an x64 branch...?
Moving libswipl.dll didn't help any, either.
I don't know enough about Windows to help further, but there are people who routinely use Windows at who could possibly help at https://swi-prolog.discourse.group/
I've thrown a question on there, and I'd like to leave this open until we can find a resolution. I want to leave the solution here for posterity.
This issue has been mentioned on SWI-Prolog. There might be relevant details there:
https://swi-prolog.discourse.group/t/swi-prolog-interface-to-c-c/7671/3
Problem solved, apparently I was using an earlier version of Prolog (pre-9.2.6) and therefore it was not working. It should've been obvious, but moving forward if anyone is having issues with the interface, first check the SWI-Prolog version we are using.
I think that SWI-Prolog 9.2.6 has all the latest changes that are also in the development version (9.3.8).
The C++ interface should be stable from now on (except for bug fixes), but there are a few missing things that I'll work on if I have time: https://github.com/SWI-Prolog/packages-cpp/issues
Note that PlTermScoped
is still experimental; there are some subtle interactions between its design and how C++ does "move" semantics that I'm not 100% sure of (in other words, I don't fully understand C++ "move semantics); also it requires at least C++-17 (C++-20 on Windows).
I am new to this, I just looked at the code for likes.cpp and likes.pl, then I compiled them successfully (I think?)
But then when I tried to run the program, I got this error:
Am I stupid or is something actually configured wrong?