Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

But I don't want that .lib or .exp file for my COM library!

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:

  • Has anyone succeeded in not generating the .lib and .exp files?
  • Does anyone know why these files are generated?
like image 405
xtofl Avatar asked Sep 16 '09 08:09

xtofl


People also ask

What do .LIB files do?

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.

What is .EXP file?

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.

What are .LIB files in Windows?

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.

What is .EXP file Visual Studio?

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.


4 Answers

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.

like image 138
garkin Avatar answered Oct 09 '22 15:10

garkin


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

like image 45
Sergey Maruda Avatar answered Oct 09 '22 17:10

Sergey Maruda


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...)

like image 2
demoncodemonkey Avatar answered Oct 09 '22 15:10

demoncodemonkey


/NOIMPLIB will prevent generation of the .lib file. I don't know how to avoid the .exp file.

like image 1
0xF Avatar answered Oct 09 '22 17:10

0xF