### /Ge Compiler Option

Syntax: | Default:
/Ge[+|-] | /Ge[+]

Use /Ge- to build a dynamic link library (.DLL) file.

By default, the compiler builds an executable (.EXE) file.

The IBM C and C++ Compilers libraries provide two initialization routines, one for executable modules and one for DLLs. For each object file, the compiler must include a reference to the appropriate initialization routine. The name of this routine is then passed to the linker when the file is linked. Use the /Ge option at compile time to tell the compiler which routine to reference.

The /Ge- option causes the compiler to generate a reference to _dllentry for every module compiled. The /Ge+ option generates a reference to _exeentry only if a main function is found in the source.

The /Ge+ option generates a reference to _winentry only if a WinMain function is found in the source. If no main or WinMain function is included, no linking reference is generated.

If you want to create a library of objects that can be linked into either an executable file or a DLL, use the /Ge+ option when you compile. Typically, none of these objects would contain a definition of main.

If one of the objects does contain a definition of main, you can override the /Ge option when you link your files, as follows:

1. Create a source file that defines _exeentry
2. Compile it into an object file, with the options /C+ (create .obj file only, no linking) and /Ge- (compile for DLL)
3. Link the resulting object file with your other object files

When you link, the definition of _exeentry resolves any references in your other object files. Because you compiled the file with /Ge-, it contains a reference to _dllentry, and the linker links in the correct initialization routines.

Summary of Compiler Options