Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Trying to use Open Watcom V1.9

This thread is locked; no one can reply to it. rss feed Print
Trying to use Open Watcom V1.9
OgreVorbis
Member #21,046
September 2021

I'm trying to use Allegro to make DOS games. A long time ago I tried DJGPP and it wouldn't compile and was just generally sub-par.
I want to use open watcom for several reasons, speed, simplicity, the IDE.

So I found this alleg.lib compiled for open watcom:
http://matejhorvat.si/en/dos/allegwat/index.htm

I placed that in the appropriate libs folder. I then copied all the allegro include files into the watcom include "h" folder. I added the two switches to the compiler /s /3s.

I figured that's all I needed to do.

When I compile a small example program, it has errors cause it starts reading the aldjgpp.h file even though there is an alwatcom.h. In the program I just #include "allegro.h"

So in one of the headers, it must be telling it to use the djgpp version. I thought #define ALLEGRO_WATCOM might work, but didn't.

It's crazy there is a watcom header, I just can't make it use it.

Maybe there will be more errors down the road, but I want to keep trying.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

OgreVorbis
Member #21,046
September 2021

Thanks for getting back so fast. ;D

I did define ALLEGRO_WATCOM, so how should I check if it's defined, you mean like ifdef.

Is there anything I should put in the linker/compiler options? I just put that define right at the beginning of the main source.

BTW I am not an ultimate C programmer. I mostly use C#, so it's possible I'm doing something wrong, but I am skilled enough to use allegro.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

ALLEGRO_DJGPP and ALLEGRO_WATCOM are defined by the build process. You should not define them yourself.

If you can't compile a simple hello allegro program that includes allegro.h, then you probably need to recompile allegro yourself for WATCOM.

If it's including aldjgpp.h something is definitely wrong.

EDIT
I would follow the build instructions given by the link you shared to build allegro yourself.

DanielH
Member #934
January 2001
avatar

So I found this alleg.lib compiled for open watcom:
http://matejhorvat.si/en/dos/allegwat/index.htm

Did you follow the instructions on that page for compiling Allegro? I've only used DHGPP for DOS, so cannot help with compiling for Watcom.

OgreVorbis
Member #21,046
September 2021

I FIGURED IT OUT!

Two problems:
1. I had to run the fix.bat watcom. I thought that was part of the build process for allegro itself and considering I downloaded the pre-compiled lib, I skipped that step. However, this step is still necessary to tell allegro it's using watcom.

2. This is the big one. The alleg.lib file does NOT go under "Library Files" in the linker switches. It goes under "Libraries" instead. I found this confusing cause I don't know the purpose of that.

So to anyone who wants to do this:
----------------------------------
First - download the pre-compiled alleg.lib from that link.
Download the allegro source also and extract it.
Run fix.bat watcom.
Copy the lib you downloaded to .\WATCOM\lib386\dos
Copy the fixed include files into .\WATCOM\h
.\WATCOM\h\ALLEGRO\PLATFORM\ALWATCOM.H, comment out line 36.
Make a new project in WATCOM using DOS/4GW.
Goto Linker Switches #2 and put alleg.lib under Libraries (NOT Library Files).
Goto C Compiler switches #5 and disable stack depth check.
Goto C Compiler switches #10 and select 80386 stack-based calling -3s.

That should do it. Now you can just add the exhello.c (hello world example) to your project and do a makeall. Copy DOS/4GW.exe into the program's folder and run DOSBox. It's working!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

OgreVorbis
Member #21,046
September 2021

FFFFFFFFFFFFF.

No, it doesn't FULLY work, I was mistaken. For some reason it only works with the simple hello world, but for anything more than that, it doesn't work at all. I figured the hello world would be enough to show it working, but NO!

exhello.c(38): Error! E1058: Cannot use typedef 'BITMAP' as a variable
exhello.c(38): Error! E1011: Symbol 'bmp' has not been declared
exhello.c(38): Warning! W111: Meaningless use of an expression
exhello.c(39): Error! E1058: Cannot use typedef 'PALETTE' as a variable
exhello.c(39): Error! E1009: Expecting ';' but found 'pal'
exhello.c(40): Error! E1011: Symbol 'pal' has not been declared
exhello.c(40): Warning! W102: Type mismatch (warning)
exhello.c(40): Note! I2003: source conversion type is 'int '
exhello.c(40): Note! I2004: target conversion type is 'struct RGB *'
exhello.c(40): Note! I2002: 'load_bitmap' defined in: D:\WATCOM\h\allegro\datafile.h(91)

And, there's more...

amarillion
Member #940
January 2001
avatar

If a symbol is not declared, then you're probably not including the right header files. Can you share some code?

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

OgreVorbis
Member #21,046
September 2021

The code is just an extension of the exhello.c I'm now just trying to display an image on the screen.

#SelectExpand
1#include <allegro.h> 2 3int main(void) 4{ 5 /* you should always do this at the start of Allegro programs */ 6 if (allegro_init() != 0) 7 return 1; 8 9 /* set up the keyboard handler */ 10 install_keyboard(); 11 12 /* set a graphics mode sized 320x200 */ 13 if (set_gfx_mode(GFX_VESA3, 640, 480, 0, 0) != 0) { 14 allegro_message("Unable to set any graphic mode\n%s\n", allegro_error); 15 return 1; 16 } 17 18 /* set the color palette */ 19 //set_palette(desktop_palette); 20 21 /* clear the screen to white */ 22 clear_to_color(screen, makecol(255, 255, 255)); 23 24 /* you don't need to do this, but on some platforms (eg. Windows) things 25 * will be drawn more quickly if you always acquire the screen before 26 * trying to draw onto it. 27 */ 28 //acquire_screen(); 29 BITMAP *bmp; 30 PALETTE pal; 31 bmp = load_bitmap("MOUNTAIN.PCX", pal); 32 set_palette(pal); 33 blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h); 34 35 /* write some text to the screen with black letters and transparent background */ 36 textout_centre_ex(screen, font, "Hello, world!", SCREEN_W/2, SCREEN_H/2, makecol(0,0,0), -1); 37 38 /* you must always release bitmaps before calling any input functions */ 39 release_screen(); 40 41 /* wait for a key press */ 42 readkey(); 43 44 destroy_bitmap(bmp); 45 46 return 0; 47} 48 49END_OF_MAIN()

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Peter Hull
Member #1,136
March 2001

Did you try including winalleg.h instead of allegro.h?
(as recommended by Bob in 2003?)

[edit] oops1 - sorry Edgar you'd already suggested that, oops2 - sorry Ogre you did mention you were making DOS games in your first post :-X

OgreVorbis
Member #21,046
September 2021

I can't post an update here anymore. Maybe the thread was locked, so I edit this post.

The reason was that this is C89 and doesn't support declaring variables in the middle of a code block. The variables all had to be moved to the top AND IT'S NOW WORKING PERFECTLY 100%.
;D
So my procedure above works fine, you just need to be sure to follow the C89 standards.

Original post:

No, none of that worked. Same results.
......

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

You can't reply to your own post to prevent double posting. You can however edit your post and send it to the top.

Now that I've replied, you can reply again.

I'm interested in getting Watcom to work, since CMake supports Watcom WMake files.

Go to: