From "LCC-Win32 User's Manual", pages 55-58, by Jacob Navia. The Linker The general format of a link command line is as follows: lcclnk [options] object-files library-files The linker will default to the following import libraries: LIBC.LIB A few C functions are in here KERNEL32.LIB Kernel function calls COMDLG32.LIB Common dialog boxes library USER32.LIB Windows 'user' functions GDI32.LIB GDI functions ADVAPI32.LIB More Windows functions COMCTL32.LIB Library for the common controls of Win32 CRTDLL.LIB Library for the 'C' runtime functions These libraries do not need to be specified in the command line because the linker will search them anyway. The name of the object file can be an expandable file specification. For instance: '*.obj'. If the name of the file begins with an '@', it will be interpreted as a list of object files to be included in the link. For instance you can say: lcclnk @list.lst which will cause lcclnk to open a 'list.lst' file and to read the file names to be used in the link. The contents of that file could be: h:\mywork\src\file1.obj h:\mywork\lib\mylib.lib etc. One line should have only one file name. This option is especially useful if you have too many files in the command line, which is limited by Win32. Command Line Options Syntax Options are introduced with the character '-' or the character '/'. Example: -map or /map are identical options. Registry keys used To find the libraries, lcclnk uses the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\lcc\lcclnk\libpath This is an ASCII_Z key that contains the full path of the libraries directory. If the linker does not find this key, you will be prompted for it at the command line. If you enter a correct path, lcclnk will always use it later. Command Line Switches -o Sets the name of the output file to file name. Insert a space between the o and the name of the file. Example: lcclnk -o myexe.exe If this option is absent, the name of the first file will be used. -errout Write all warnings/error messages to the indicated file name. -subsystem Indicate the type of output file. Subsystem can be one of: 1. Console 2. Windows If you specify console, a console application is created. The standard input, standard error, and standard output are opened. When the program is started, Windows automatically creates a console window. If you specify Windows, a windowed application is created. No console window is created, and stdin, stdout, and stderr are NOT initialized. -stack-commit The default stack reserves 1MB of stack space, and commits 4096 bytes of it. With this option, you can commit more pages than one (4096 bytes). This means that a slight improvement in execution speed can be attained with programs that use a lot of stack. Example: -stack-commit 27000 -reloc This option instructs the linker to build a .reloc section. This section is a table of relocations to apply if the executable cannot be loaded at its preferred load address. This option is necessary under Win32s. This option is automatically turned on for DLLs. -dll This option indicates to the linker that a .dll should be created instead of an .exe. The process of building a DLL is very simple: 1. Compile the source(s) files for your DLL as you would compile normal sources. 2. Link the resulting object files using the option -DLL and provide the linker with the names of the functions exported in a .def file that you include in the link. 3. Produce an import library using the implib utility. EXAMPLE: lcc mylib.c lcclnk -DLL mylib.obj mylib.def implib mydll.dll The format of the .def file is as follows: EXPORTS Function AnotherFunction YetAnotherFunction You write the EXPORTS keyword, followed by the name of each function of the DLL you want to export (i.e., to make visible for use in another executable) in a single line. -map This indicates the name of the map file. In the map file, you will find the addresses of all symbols used in the link and the line number information, if available. The format for the line numbers is simple: Address:line. The address is written in 8 characters prefixed by the '0x', and the line number is written in 4 characters in decimal form. This option allows you to find out where in your program a fault occurred by reading the address from the dialog box that the system displays when a program crashes. This option is not compatible with the -s option, i.e., if you ask to strip all symbols, no line number information can be generated. When creating an executable with the -s option to ship to customers, it is better to do the link twice: One with the debugging information and a mapfile; the other stripped. First create the stripped version and then the full one. The reason behind this is that when both options -s and -map are specified, the linker writes a smaller link file without any line number information. If you create the full link first, and then the stripped, this smaller map file will overwrite the good one. Example: -map myexe.map -s This option indicates that the linker should strip all symbolic and debugging information from the executable. This means the executable cannot be debugged with a debugger, but that its size will be considerably smaller. In addition, the linking speed is increased because the linker has less work to do. Use this option with debugged programs if you believe this to exist. -version nn.nn This option adds the version number to the executable. The numbers are the major version number and the minor version number. A period character separates them. Example: -version 3.8 or -version 99.01 -x Analyzes the symbols that are declared 'extern', but which are never referenced in any other object in the link. There are two cases: 1. The symbol is in the .text section (code section). Even if this symbol is not used in other modules, it can be used in the same module. The linker cannot determine this (without disassembling the whole object file), but you can easily check this. Declare the function 'static' and recompile your source. If it is not used, the compiler will issue a warning. 2. The symbol is in the .data or .bss section. This is a data item and it is surely not used. Delete it from your source. errout= Write all warnings or errors to the file name indicated. Do not include any spaces between the equals sign and the name of the file. Example: errout=link.err Lcclnk writes the errors to stderr by default. If you want the errors in the standard output use: errout=stdout nounderscores When creating a DLL for Visual Basic for instance, it is better to export names without underscores from a DLL. This option will allow this.