Making a Standalone Executable

Many people have difficulty making an executable (EXE or DLL) module from an XBasic program, but this need not be the case.  With a bit of setup, XBasic programs can be compiled to create an executable just by double-clicking the program's MAK file. The following method works for XBasic V6.2.0 and above, in Windows 95; it should also work with later Windows versions.

The setup needs to be done only once. In all of the following, replace \XBasic with the path to your XBasic directory.

1. Using a text editor (Notepad will do), put the following lines in your AUTOEXEC.BAT. Do not put any spaces or tabs around the "=".


If the path to your XBasic directory contains spaces (eg., \Program Files\xb), then it may be necessary to use quotes around the paths, as for example


These lines should be placed after any existing definitions of the PATH, INCLUDE, or LIB variables.  Save the edited AUTOEXEC.BAT, and re-boot.

2. Make sure the following files are in the appropriate XBasic directories:

     spasm.exe     nmake.exe     link.exe


     xstart.o, and all RESOURCES, STDLIBS, and LIBS listed in xbasic.mak and in your own .mak file:

     advapi32.lib comdlg32.lib gdi32.lib kernel32.lib msvcrt.lib user32.lib winspool.lib xb.lib

     (There will be more if your program IMPORTs anything other than these libraries or the standard XBasic libraries.)

3. Create the text file NMAKE.BAT, containing the following line

"%XBDIR%\bin\nmake.exe" %1

and save it - for example, in the \XBasic\bin directory. The quotes are only necessary if your XBasic directory path contains spaces (eg., \Program Files\xb). The purpose of this BAT is just to keep the DOS window open when nmake.exe has finished, so you can see results of the compilation.

4. From Explorer's View menu, select Options, then File Types to associate MAK files with NMAKE.BAT. Make this the Default association for this file type.

If you aren't familiar with this procedure, then an alternative is to double-click any .mak file. An "Open With" dialog will appear, asking you which program you want to use to open .mak files. Click "Other", then go to the folder containing nmake.bat, and select it. Also, make sure the checkbox 'Always use this program to open this file' is checked.

This completes the setup.  Now whenever you want to create an EXE, just select 'assembly' from the 'run' menu in the PDE - which creates the .s and .mak files - then double-click the .mak file.  Or, run XBasic from the command line, using the command xb myprogram.x.  Create a DLL the same way, but select 'library' from the 'run' menu instead (or run xb myprogram.x -lib).  (For more information on making a DLL, see Multiple Module Programs.)

One hint: Save the .x source before creating the .s and .mak files, not after. If the source is saved after the assembly (.s) file is created, then nmake will see the .s file as being older than the .x file, and will invoke xb.exe to re-compile the .x.

When running your EXE, remember that you should have copied xbrun.dll into your \Windows folder, and re-named it xb.dll. Also, you can run the EXE from any folder except the XBasic\bin folder; if you run it in this folder, it will link to the wrong xb.dll, and start up the PDE instead of running your program.