Glulx doesn't work without the Inform library?

I compiled the basic Hello World program from DM4 chapter 1.2 in Inform 6 targeting Glulx:

!  "Hello world" example program
[ Main;
  print "Hello world^";
];

It compiles without errors but the program doesn’t work in any interpreters I have on Mac. Both Zoom and Inform 7’s built-in interpreter show a gray screen without any output, and Quixe crashes on startup with a “Quixe init: glk_put_jstring: invalid stream” error message.

Just wanted to confirm that this is expected (some Glulx initialization stuff is necessary that the Inform library would do) and not an interpreter issue?

This seems vaguely similar to a problem that I suspected was in the compiler, library, or interpreter. It turned out to be a very longstanding bug in the Frotz core. I’ll poke at this one from a few different angles.

That is as expected. When a Glulx interpreter starts up, it won’t have any I/O system selected, so there’s no way for it to generate any output that you would see. The usual sequence would be something like:

  1. Set Glk as the I/O system with something like “@setiosys 2 0;”.
  2. Create a Glk text buffer window to be the main window.
  3. Set the main window’s stream as the default stream.
  4. Now you can call “print” and have something appear.

Have a look at “GGInitialise()” in parserm.h in Inform library 6/11 or later to see an example of this.

2 Likes

The minimum you need is the following:

[ Main win;
	@setiosys 2 0; ! select Glk I/O system
	win = glk($0023, 0, 0, 0, 3, 0); ! glk_window_open
	glk($002F, win); ! glk_set_window
];

For example: https://github.com/erkyrath/glk-dev/blob/master/unittests/arraylimittest.inf

1 Like

Ok, that’s understandable although a bit unfortunate that literally the first thing that DM4 tells you to do can fail so subtly.

To be fair, the DM4 was written almost entirely before Glulx. I think it might be only mentioned once. To compile to Glulx you need the -G switch which the DM4 doesn’t even list as an option!

1 Like