Using the Compiler from the Command Line

The compiler can be used from the command line without the IDE. This action assumes you have the \lcc\bin directory in your PATH environment variable.

c:\lcc\project> type hello.c

#include <stdio.h>

int main(void) {

     printf(« hello\n ») ;

     return 0 ;

}

c:\lcc\project> lcc hello.c                      (1)

c:\lcc\project> lcclnk hello.obj                 (2)

c:\lcc\project> hello.exe                        (3)

hello

c:\lcc\project>

You must first compile the source file. You call up the compiler (lcc.exe). Next, you should link the resulting object file with lcclnk, the linker (2). The program can then be executed by typing its name.

Below you will find the command line options for the compiler and the linker.

To build a Windows executable using some resources, the sequence of commands could be:

c:\lcc\project> lcc win.c

c:\lcc\project> lrc win.rc

c:\lcc\project> lcclnk -subsystem windows win.obj win.res

c:\lcc\project> win

The only difference is that you should compile your resources using the lrc resource compiler and add the resulting windows.res to your link command line. Please note that you should specify ‘subsystem Windows’ in the linker command line to avoid having a blank window appear whenever you start your program.

A simpler way is to use the lc.exe command line utility. It will call the linker automatically, and the resource compiler if it finds an rc file. The above example could have been compiled with:

c:\lcc\project> lc win.c win.rc -subsystem windows