Why does Visual Studio generate these additional files? - c++

In the output directory where Visual Studio places the compiled executable, there are three additional files of the types *.exp, *.lib, .pdb. I do not need those files and I would like to prevent the compiler from creating them.
This is how my build output directory looks like. I only need the *.exe file.
What are these additional files for? How can I disable that they are generated? If they are needed for the build process, is there a way to automatically remove them after the executable is created?
I am using Visual Studio 2012. If you need additional details, please comment.

EXP and LIB files But I don't want that .lib or .exp file for my COM library! . You could probably set the location of these files in the "Intermediate Output" setting and not have them in your release folder

I'm assuming you are looking to have only the dll and exe files in your final release directory and the *.exp, *.lib, .pdb files left in your intermediate directory as to not clutter the directory you are working in.
Visual Studio 2017
Open properties (Right click on the project in the solution explorer):
change settings as shown:
Import Library will define where the .lib and .exp files are created.
Generate Program Database File defines where the .pdb file is created.
Debug information format -- None will prevent pdb file from being created. Select this option for Release builds.

There some functions inside declared with as __declspec(dllexport).
It means that they are exported 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

Related

How to compile/build/link - the XLNT library?

I downloaded the xlnt library for working with Excel - https://github.com/tfussell/xlnt. Can you please tell me what to do with it further? Honestly, I still can’t understand how among all the files there are in the downloaded archive, and there are 100 of them .hpp and .cpp files, what should I do with them?
1)As far as I understand, they need to be processed by the Cmake program and it seems that the output should appear .lib file, but I absolutely can’t understand how to do it or maybe something else
2)Or how can they be directly processed by Visual Studio 2017?
PS:When I launch Smack, I select the Source folder, the Cmake generates many incomprehensible files, but among them there is not one file with the .lib extension.
Help me please.
With CMake you can obtain the visual studio 2017 project files
and then compile the xlnt library.
Unzip the archive file
Within the xlnt folder, create a new directory and call it build
Launche CMake (GUI)
Browse for the source code folder
Browse for the build folder xlnt/build
With the Configure button select the tool (IDE/compiler) that you want to use
Pressing the Generate button, CMake will generate (inside the build folder)
the visual studio 2017 project files you need to compile the xlnt library
Building the solution, VS 2017 produces the xlnt.lib, xlnt.exp and xlnt.dll files.
The source path you see in the CMake screenshot is incorrect. You must specify the path that contains the "top level" CMakeLists.txt file.
The correct directory is: C:/Users/Zver/source/repos/XLNT Library/xlnt-master.
The CMakeLists.txt file in the above directory tells CMake all necessary subdirectories.
At this point you will see the static compilation option of the library appear.
If you use the MinGW/GCC compiler you must prevent the path from containing empty spaces.
Then you need to rename the directory from "XLNT Library" to "XLNTLibrary". At this point the path would become:
C:/Users/Zver/source/repos/XLNTLibrary/xlnt-master.

C++, Visual Studio 2012, LIBs, DLLs, Includes, Source and Linker

I'm trying to understand what exactly all of these are and how they relate to each other (and most importantly, how to install them).
From what I've read, LIBs are libraries linked during the compilation of my project and DLLs are libraries linked during the runtime of my project.
So for me to use a LIB, I have to have the actual .LIB file somewhere in my computer, go to Project -> Properties -> VC++ Directories and add the path to the file in the Library Directories, and after this I have to go to Linker -> Input -> Additional Dependencies add the .lib name in there, and finally I need to type #include in my code, right?
So, some questions:
When I finish and build the release of my program, will the .exe only run if the target platform has the .lib installed in their PC as well? If yes, what steps do I need to do to make sure the .lib goes with the .exe?
When I get the source of a open source project, if I add them (using Add Existing Item...) to my project, can I use them just by using #include as if the files were mine and it would be the same as having the .lib installed? Or do I need to install the .lib file and still use these source files?
I have a project using OpenGL and I linked to glew32.lib, but I don't have the lib or any new directory added in the VC++ Directories, so I think this means I must've installed the .lib in the system folder or somewhere where the Visual Studio won't ask for another directory, should I worry about this when releasing a project?
How the above questions relate to DLLs and is there any reason why should I use DLLs over LIBs or the other way around?
I'm starting to use more and more libraries and I noticed I just dragged, copied and included it everywhere so I could use them but never really understood how they "fit" in the project. Especially those open source libraries where they provide so many files and I don't really know what to do with them...
You don't need to have LIB files along with your EXE file for running in another computer, LIB files are static files and DLL files are dynamic. So when you compile all static codes will be included in your EXE file, but DLL files will be loaded and used dynamically in runtime, so you just need to have your DLL files with your EXE file. This way, your code will work and run properly in other computers.
Just adding another project is not enough, you need to compile them and generate LIB files out of them. Then you add the generated LIB file to your final project and include external projects in your final binary. If you are compiling multiple projects together in a solution, you'll need to set project build order in solution properties in VS.
No, that's OK. It seems you've put LIB files in right folder and you don't need to have LIB file with your EXE file to run it in other computers.
DLLs are dynamic libraries, so you need to have them with your application. Installers usually install EXE files with DLL files in the same folder, so your app will run properly, but no need to include LIB files at all.
Also you can include LIB files like this:
#pragma comment(lib, "glew32.lib")
So you don't need to do it in project settings, but assuming you have your LIB file in "Library Directories" path.
Using DLL files can be done in two ways:
One is linking your application to DLL file and having DLL file's function entry in your EXE file's import table:
like using
#include <windows.h>
then
GetWindowsDirectory(windir, MAX_PATH);
So you'll have GetWindowsDirectory API entry in your EXE file's Import Table.
Also you can do it dynamically:
hinstDLL = LoadLibrary("kernel32.dll");
if (hinstDLL != NULL)
{
func_GetWindir = (DLLPROC) GetProcAddress(hinstDLL, "GetWindowsDirectoryA");
...
There is not much difference, only difference is:
In first method, as it's in your EXE file's Import Table, if there was no kernel32.dll or there was no GetWindowsDirectory entry in kernel32.dll, your EXE will not run at all, it will show a critical error and will not run. But in dynamic way (second way), your app will run, but as soon as your code try to use GetWindowsDirectoryA API, it will fail. You will have 0x00 in func_GetWindir. If you attempt to call it, then program will crash.

After building wxWidgets with VS2012, which files can I delete in the lib folder?

I've built wxWidgets with VisualStudio Express 2012 (nmake) and I don't know which files I can delete in the lib folder. The following file types are in the lib folder: .exp .manifest .ilk .pdb .lib .dll
I know I need the .lib and .dll, but what are the rest for? In another build, I also have these file types: .obj .tlog .log
What of these types are files that I can safely delete?
Maybe it helps to know what the files are for
exp: definition which function to export by the linker 1
obj: output of the compilation, which normaly gets used by the linker to generate the binary 2
ilk: used by vc to speed up the generation (on multiple times) 3
pdb: contains info for use by the debugger and linker 4
tlog: used by vc to speedup compilation time 5
You should definitely keep the .pdb files to be able to debug. The rest of them (not counting .lib and .dll, obviously) could be deleted but IMHO it's not worth it. If you're after space saving, you should delete the entire build/msw/vc_mswu[d][dll] (or build/msw/vc11_mswu[d][dll] if you use per-version build directories) directory as this is what really takes a lot of place.

How can I force to load / create pdb files for a dll

I have downloaded the latest version of SFML (a library) which includes source files, dlls, headers, and .lib files.
I have no problem using the library and it's linked dynamically.
I'd like to be able to step through the library code in the debugger (I used to be able to which earlier version), but now I can only see the assembly.
What is the usual way to generate pdb files to so?
thanks
Generally Visual Studio 2010 should automatically generate .pdb files for you (if you build in debug mode). Take a look in your Debug output folder. You can see where and what .pdb is being generated from your project settings;
Sterren

Problem creating static/dynamic c++ libraries in visual studio

When I try to build my c++ library (in both static and dynamic mode) using visual studio 2008, in the debug folder, instead of .lib or .dll file, some .obj files are created along with an .idb and an .pdb file.
how can I make visual studio build the library file?
You're either looking in the wrong place or there's a problem in your build.
Open the BuildLog.htm file that VS creates when it does a build (there should be a link you can click in the Build Output window). It'll tell you where it's putting the file. Look for the line containing an "/OUT:" option.