When generating a COM dll with VisualStudio, all I really need is the DllCanUnloadNow
symbol (and three related ones) to be exported from the dll itself. Nobody is going to link against my library, so I'm not (at all) interested in a .lib file, nor in an .exp file.
However, I don't manage to inhibit creation of these files. (note: I do know how it's possible to remove them in a post-build step)
These are my linker arguments:
/OUT:"u:/cada-nt/bin/PData.dll"
/INCREMENTAL:NO
/NOLOGO
/DLL
/MANIFEST:NO
/DEF:"PData.def"
/DEBUG
/PDB:"u:/cada-nt/pdb/PData.pdb"
/ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib
The question:
lib file contains all the code and data for the library. The linker then identifies the bits it needs and puts them in the final executable. For a dynamic library, the . lib file contains a list of the exported functions and data elements from the library, and information about which DLL they came from.
An EXP file is a symbols export file, produced by an integrated development environment (IDE) or compiler. It contains binary information about exported data and functions. EXP files are used to link the program they were created from with another program.
LIB (lib.exe) creates standard libraries, import libraries, and export files you can use with LINK when building a program. LIB runs from a command prompt. You can use LIB in the following modes: Building or modifying a COFF library.
exp extension primarily stands for the Symbols Export File (. exp) file type used in Microsoft Windows programming, namely within Microsoft Visual Studio, a powerful commercial IDE by Microsoft. The purpose of a symbols export file (. exp) is to provide reference to library functions, 'exporting' them for the linker.
Visual Studio's linker has an /IMPLIB
option that allows you to specify the output location for your .lib
and .exp
files.
You can modify this option in a project's properties:
Configuration Properties > Linker > Advanced > Import Library
You might set it to the following, for example:
$(Configuration)\$(TargetName).lib
The linker will create the .exp
file using the same name as the .lib
.
There some functions inside COM library declared with as __declspec(dllexport). It means that they are exported (may be used by GetProcAdress function) and linker thinks that there is a need to link with this dynamic library (no matter it is exe or dll - in general the structure is the same) and creates *.lib and *.exp file.
to avoid creation of these files you need to remove all __declspec(dllexport) from functions declarations
Not sure how to turn them off, but you can make a post-build step to remove them, like this:
del $(OutDir)\$(ProjectName).lib
del $(OutDir)\$(ProjectName).exp
(on VS2008 it's [Project]->[Properties], then Configuration Properties->Build Events->Post-Build Events)
(note I realise you know how to do this, but this answer may help the next googler...)
/NOIMPLIB
will prevent generation of the .lib
file.
I don't know how to avoid the .exp
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With