Programmers occasionally run into various problems with _acrtused names being multiply defined or being undefined. Essentially, _acrtused is an external reference generated by the compiler in order to bring in the startup code appropriate to a console app, a windows app, a dll app, etc. Different acrtused names are referenced to bring in different startup code. The variations are:
|__acrtused||If WinMain() -or- If 16 or 32 bit DOS compile and main()|
|__acrtused_winc||If 16 bit Windows compile and main()|
|__acrtused_dll||If 16 bit Windows compile and LibMain() -or- If -mn and LibMain() -or- If -mn and DllMain()|
|__acrtused_con||If -mn and main()|
|__wacrtused_con||If -mn and wmain()|
|__wacrtused||If -mn and wWinMain()|
- Detection of main() and DllMain() are done in a case-sensitive manner, WinMain() and LibMain() are done in a case-insensitive manner.
- By "16 bit Windows compile", that means compiling with a 16 bit memory model, and the -W switch or -W[123ADx].
- -mn means a Win32 program.
Troubleshooting problems with startup code at link time
- Message about "__acrtused_??? undefined" from the linker:
- The most likely cause is not linking with the standard runtime library (RTL) for the memory model specified.
- Check that /NOD (no default library search) is not specified for the linker.
- Check that the environment variable LIB (or the LIB in sc.ini) is set to point to the directory where the runtime libraries are (which is typically c:\dm\lib).
- Check that -NL (no default library) is not specified to the compiler.
- Check that only one of main(), WinMain(), LibMain() and DllMain() is defined in your program.
- Check that the module being compiled with main(), etc., is compiled with Digital Mars C/C++ and not some other compiler.
- Check that you are not linking with the runtime library from another compiler.
- Run the utility OBJ2ASM on the object (.obj) files, and search the output to see who is referencing __acrtused_???.
- Linker message about "identifier previous definition different", or "multiply defined", and identifier is an internal name to the runtime library: The most likely cause is that more than one of main(), WinMain(), LibMain() and DllMain() is being defined, so that more than one startup code module is pulled in, resulting in the name collisions.
- Try linking with /NOD and note the unresolved externals and which modules refer to them. If things are really desperate, try pulling the startup code out of the standard runtime libary (making a backup of the original first!) and check to see what symbols are left unresolved. This will tell you who is trying to pull in the extra set of startup code.