The way Import Library (.lib) is generated depends on two things:
1) EXPORTUNFROZEN command in your .mmp file
2) .DEF files
Important thing to understand while developing a DLL is use of EXPORTUNFROZEN command in your mmp file, as you are still in development mode, changes to the DLL are expected quite often, hence EXPORTUNFROZEN should be used until you release your DLL. When EXPORTUNFROZEN command is used, Import Library (.dso does similar work as import library .lib) is created as a part of linking process.
.Def file is Module Definition File which provides information about exported functions, their attributes and ordinals.
- .Def plays an important role in maintaining Binary Compatibility.
- Code using your dll is linked to specific ordinal ( ordinal is an identifier or number given to each of an exported method in your .DEF file ). Hence your ordinals should remain the same other wise the applications which have already been built to use your DLL may not work, and this can be said as Binary Break.
- Hence using .Def file, we maintain the ordinal order such that all the new exported functions are appended to the end preserving the old order which maintains the Binary Compatibility enabling applications which have already been built to use old DLL will work with the new DLL as well.
Build your project in normal way for whatever Platform you want, then use abld freeze command to generate the .DEF file, you will get a message like " File not found - OK if freezing for first time", as it cannot find the .DEF file for freezing.
GoTo >> Project >> Freeze Exports
- By default, the build tools generates / creates BWINS directory for .DEF file for emulator which is at the same level as the directory containing the .mmp file, and similarly the ARM def file in a EABI directory.
- .mmp file does not need to provide location of the .DEF files explicitly, If the files are stored in those above default locations.
- .mmp file should specify the location using the deffile keyword, if you are storing .DEF files in some other location than the default one.
- Now as we have separate .DEF files for each target, you need to use #if defined macros to select the correct .DEF file, depending on the target for which the project is being built.
#if defined(WINS)
deffile ..\winsfolder\SAMPLE_WINS.DEF
#else
deffile ..\otherfolder\SAMPLE_EABI.DEF
#endif
if you have both EXPORTUNFROZEN and .DEF files then import library will be created as a side-effect of linking rather than from the frozen .DEF file, and this import library will be created whether the project is frozen or not.
If you have EXPORTUNFROZEN in your .mmp file, then Import Library ( .lib / .dso ) are generated as a part of build process.
Build your dll, If you do not have EXPORTUNFROZEN statement in your mmp file then it wont generate .lib (.dso ) file straight away, first you have to freeze using abld freeze command, it which will generate .Def files and then regenerate makefile (i.e. bldmake bldfiles) then it will create the Import Library from the frozen .DEF files.
No related wiki articles found