Subject: Re: DLL loading problem with plcon

From: Jan Wielemaker <[email-masked]>
Date: Wed, 9 Aug 2000 15:25:35 +0200

On Wed, 09 Aug 2000, Lionel Ains wrote:
>> De : Jan Wielemaker <[email-masked]>
>> To create executables, just do
>>
>> 	plcon -g go -o myprog -c prog.pl
>>
>> which will create myprog(.exe on Windows).
>>
>> 	Regards --- Jan
>You're perfectly right, it's quite complicated but I've switched back to this command line compilation
>after having problems with plcon.exe. I was using the "plcon -o" command line as well before having
>problems with DLL loading.
>In fact, I've realised that plcon was not crashing but simply not outputting messages anymore.
>After loading the foreign language library, no prompt, nor even compilation message is printed
>anymore. Prolog is still running but all its output is muted.
>However, I can get all the messages when I redirect the output to a file on plcon's command-line.
>This must be the reason why I don't have any problem with plwin.exe because I guess that the output
>to the Window is handled a different way.

Yes.  All I/O of Prolog is handed by Prolog streams.  By default the
user I/O streams refer to the POSIX file descriptors 0, 1 and 2.  In
case of plwin.exe, these are rebound to functions reading from and
writing to this window.

So, if your library plays around with these file descriptors, plcon.exe
will be affected, but plwin.exe not.  This looks like the most promising
thing to look at.

>Would there be a few Prolog environment variables that I could check to be sure that the output is set
>correctly?

Not really.  To confirm my hypothesis you could try to add a foreign
procudure

say_hello()
{ msg = "Hello World\n";

  write(0, msg, strlen(msg));
  return TRUE;
}

If this doesn't write after loading the library you should try to find
out what the library is doing to the filedescriptor.

	Regards --- Jan