Building CheapGLK on windows?

This seems like a pretty rookie question, but when I try

gcc main.c -o cheapglk.exe

I get the following errors:

undefined reference to gli_initialize_misc' undefined reference toglkunix_startup_code’
undefined reference to glk_exit' undefined reference toglk_main’
undefined reference to glk_exit' undefined reference togli_stream_open_pathname’
undefined reference to `gli_stream_open_pathname’

This suggests there’s a Glulx DLL I need to use that I don’t know about. I probably missed it in Zarf’s readmes.

But does anyone know what libraries etc I need to add to get the compile working?


I can’t really help with Windows details, but, cheapglk is a library, not a complete executable.

(Either way, you’d want to compile *.c, not just main.c.)

So, what you want to do is compile cheapglk as a static library or a DLL.

Since you’re running gcc, it seems like you have an environment where you could also run make. If so, the makefile that ships with cheapglk ought to handle this. If not, these instructions might help.

After you’ve done that, you can compile an interpreter, linking it with the cheapglk library that you’ve already built.

Well, I haven’t been able to get the makefile to run, but based on

and what I read in the makefile, I pulled all the files from

Then in that directory I ran the commands

gcc -c -o cgfref.o cgfref.c
gcc -c -o cggestal.o cggestal.c
gcc -c -o cgmisc.o cgmisc.c
gcc -c -o cgstream.o cgstream.c
gcc -c -o cgstyle.o cgstyle.c
gcc -c -o cgwindow.o cgwindow.c
gcc -c -o cgschan.o cgschan.c
gcc -c -o cgdate.o cgdate.c
gcc -c -o cgunicod.o cgunicod.c
gcc -c -o main.o main.c
gcc -c -o gi_dispa.o gi_dispa.c
gcc -c -o gi_blorb.o gi_blorb.c
gcc -c -o cgblorb.o cgblorb.c

So I have a bunch of .o files now. This looks like the long way to do it, but I didn’t see any other way.

nmake -f Makefile (which didn’t work before)

now produces libcheapglk.a It didn’t work before, when I tried nmake -f Makefile off the bat. It also produces Makefile.cheapglk.

Then I pulled the glulxe repo into a sister director and figured I should run these commands by hand in order to create glulxe.exe, which I assume can read in STDIO to the game command prompt and output story text.

gcc -c -o main.o main.c -I…\cheapglk
gcc -c -o files.o files.c -I…\cheapglk
gcc -c -o vm.o vm.c -I…\cheapglk
gcc -c -o exec.o exec.c -I…\cheapglk
gcc -c -o funcs.o funcs.c -I…\cheapglk
gcc -c -o operand.o operand.c -I…\cheapglk
gcc -c -o string.o string.c -I…\cheapglk
gcc -c -o glkop.o glkop.c -I…\cheapglk
gcc -c -o heap.o heap.c -I…\cheapglk
gcc -c -o serial.o serial.c -I…\cheapglk
gcc -c -o search.o search.c -I…\cheapglk
gcc -c -o accel.o accel.c -I…\cheapglk
gcc -c -o float.o float.c -I…\cheapglk
gcc -c -o gestalt.o gestalt.c -I…\cheapglk
gcc -c -o osdepend.o osdepend.c -I…\cheapglk
gcc -c -o profile.o profile.c -I…\cheapglk

And I have a bunch of object files but I don’t know what to do. I feel like I’m missing something here, and I can’t interpret what’s in the makefile. I think switching the / to \ made a bit of progress, but that’s it.

Thanks again for your help so far!

Have you tried this?

gcc -o glulxe *.o -l../cheapglk/cheapglk

Hmm. I think a big problem is that I don’t have MinGW, and that would make it a lot easier.

I had GCC from a Strawberry Perl, but I don’t think it processed makefiles. So I didn’t really have the whole package.

Now the problem is

c:\Users\Andrew\Documents\GitHub\cheapglk has libcheapglk.a and all the other *.o files

c:\Users\Andrew\Documents\GitHub\glulxe>gcc -o glulxe *.o -l …\cheapglk\cheapglk
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/4.9.2/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -l…\cheapglk\cheapglk

I don’t have a cheapglk.a/o file, only libcheapglk.a/o, but even changing the -l argument, or -l to capital L or i or I (a long shot, but these are the main ones I know,) I’ve got nothing to work.

Still, a lot of other code I remember from other contexts is making a lot of sense…which gives me faith I’ll eventually see what I’m doing wrong and have a eureka moment. Thanks again for the help so far.

Try -LC:/Users/Andrew/Documents/GitHub/cheapglk -lcheapglk