Open Watcom is a C/C++ compiler suite (including FORTRAN) for Windows, handy for those Linux users who wish/need to program in Windows environment but don’t have one. This is the only successful programming tool that runs under WINE! Still, that doesn’t mean it works fine without errors. That’s also the fun part because you get the opportunity to use commands more often for compiling, linking and then running the program.
Installing Open Watcom
You can download the software from here.
And for configuration, it’s better to select the target and host as Win32 (NT/Win95/Win32s), well that depends on which platform you are intending to develop for. But if you have no idea then you are best left with Win32 as this will allow your compiled program to run on Win XP and later versions (yeah Win 10 counts too).
Starting ‘hello’ project
Let’s launch Open Watcom using application launcher and run a sample hello world program. Press alt+f2 and type in this command:
CTRL + n to start a new project. And [assuming target for Win32] for now, we’ll be working on Character mode executable program then press the ins key on your keyboard to insert the source file. Specify its name as hello.c in the dialog box, Click Add and close it.
Double-click it and you’ll get a new editor window.
REMEMBER not to close this editor window once you’ve opened it until you are sure you won’t be working on the project. Otherwise, you’ll be greeted with an error the next time you try to re-open the editor again.
Code in hello program on the editor and then (5 seconds later) it’s time to compile your hello world program. There are two ways to compile: GUI or CLI.
For Command Line Interface method you have to launch ‘system’ under file menu from the editor window then compile link as described below -
wcc386 -bt=nt hello.c
wcl386 -bt=nt hello.obj
By the way, if you’ve configured Watcom differently on your system, for instance enabling all target and host platforms you might be trying this way -
Well, that looks similar to GCC on Linux but the issue with this is that you are compiling for the 16-bit processor. You’d have to look at the history of microprocessors for the better understanding of processor numbering, why 32-bit are often referred to as 386, 486, 586.
So the above wcc386 actually compiles your hello world program for 32-bit Windows OS and the extra argument -bt=nt actually means “Binary target” and for ‘nt’ you got it this way NT. All lines from Win XP till 10 are families of Windows NT.
If you haven’t closed the previous instance of CMD key in this -
hello or .\hello
Unfortunately, the GUI way of running this text based program is an issue (no visual output) and the solution will be presented later.
Keep in mind that this solution is also not really a solution when you have a program that has to pass arguments in the main function and in that case you’ve to stick to the previous method of compiling, linking and running using the console program.
Now the best part about this is GUI saves a lot of time and eases you the programmer from having to type in compiler commands and arguments all the time. Here’s how you’d do to launch Watcom
Fire up your terminal and key in this:
REMEMBER never close the terminal even when nothing more can be done on it (i.e. unusable). Open your hello world program and click those in sequence.
Well, when Run was clicked the output was piped to the terminal and you’d have noticed this.
So for all the programs that don’t need argument passing in main() or those that implement WinAPI in which an actual window is created.
Ah-ha! You might have this syndrome of closing windows just for the sake of switching it. Unbreakable habit. Then you have the option to change the text editor of your choice; by clicking on File of the IDE window and selecting Set Text Editor. This will ease without error messages as you close and reopen the text editor
And don’t forget if you intend to use notepad++ or any executable file as your editor then -
Enter editor parameters: %f
Editor type: Executable
All well knitted now and you are on the right way to program your way outta here. And for the guys here who insist codeblocks is better and runs on win, additional tool (PlayOnLinux) is required to successfully set it up but note that Watcom consumes fewer resources and comes with rich API to develop Windows applications. Happy programming!
Submit your topic