swipl-devel
swipl-devel copied to clipboard
load_foreign_library crashes/hangs when loading a newly created C dll compiled and linked with cygwin gcc
load_foreign_library crashes/hangs when loading a newly created C dll compiled and linked with cygwin gcc
On Windows 7 operating system, 64 bit. Version of swipl is 7.2.3 (a year old) Version of cygwin64 gcc is: 5.4.0 (hot off the press)
To eliminate any issues introduced by improperly coded C, I've simply taken the C source for dlltest.dll (dlltest.c) authored by Jan, then compiled and linked as follows:
swipl-ld -c dlltest.c
swipl-ld -shared -o dlltest dlltest.obj
Within swi-prolog,
load_foreign_library('
Either exists swi-prolog or hangs. By the way, when I used the dlltest.dll that comes shipped with swi-prolog everything works well.
I've also tried wrapping the path to the file with foreign predicate, as well as dropping the dlltest.dll in the swipl/bin directory, same problem. When I use the MinGW gcc compiler, swipl-ld falls as the link phase, claiming it can't find the PL_ functions.
These issues are hard. If I'm not mistaken, cygwin generated code cannot be used in applications using the MS C runtime libs. May also be a calling convention issue. You can only use cygwin if you also compile the core Prolog system with cygwin.
Using MinGW should work, at least in theory. Use -v to see what it is doing. It should be passing the SWI-Prolog core library.
Hi Jan, thank you for your prompt reply. :-)
I ll focus then on MinGW; in the meantime, I ve been successful with a static link to with a main C program to swipl.a ( I recall, don't have it on n front of me) but I lose some of the goodies , I get with swipe-win.exe such as the graphical debugger.
By the way, I m the guy who knows Annie who recently posted a blurb on the swipl news portion of your cite. It regarded my use of Prolog for data generation purposes (a kind of reverse SQL, if u will).
My use of Swi Prolog has been enjoyable over the last year; the documentation has been very helpful, and I appreciate the huge effort you have contributed to this mission over the last several decades.
If there are ways I can support the Swi Prolog mission , please suggest them to me.
Sincerely Donald Maffly
Sent from my iPhone
On Dec 30, 2016, at 1:14 AM, Jan Wielemaker <[email protected]mailto:[email protected]> wrote:
These issues are hard. If I'm not mistaken, cygwin generated code cannot be used in applications using the MS C runtime libs. May also be a calling convention issue. You can only use cygwin if you also compile the core Prolog system with cygwin.
Using MinGW should work, at least in theory. Use -v to see what it is doing. It should be passing the SWI-Prolog core library.
You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/SWI-Prolog/swipl-devel/issues/190#issuecomment-269749196, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AXrkAeOSlBsJhxfuGEzospLh0la-eAcbks5rNMt1gaJpZM4LXyD6.
@dmaffly It would be great if you could support the SWI-Prolog mission! We have a couple of Windows-specific issues in this tracker, but not that much experience with the Windows platform. Maybe you can help us out with some of these (or others)?