Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.lib and .dll during deployment of C++ code to Github

Tags:

c++

dll

I understand that .lib is static library linking and .dll is dynamic. This means that when .exe is produced, .lib does not need to be around for .exe to work. However, .dll need to be put in the correct relative path for .exe to reference and run.

My question is for .lib. When uploading the source code to Github, do I include .lib file in the project folder as well? What is the best practice in doing so?

Most of the tutorial that shows how to install library makes us link .lib file to its original folder and move .dll file into the working project folder. So should I move .lib file into my project folder as well? If I don't do that, it means the person that download my source code will have to go find the corresponding .lib file to link and compile right?

like image 238
Zanko Avatar asked Dec 05 '22 17:12

Zanko


2 Answers

My own "IMHO answer" would be: "GitHub is concerned with source code." Therefore, I would not suggest including a binary .lib file there. And, I probably also would not put a binary .dll file there, either.

To clarify the difference between the two files ...

A .lib file is a library of object-code, resulting from previous compiles, that can now be referenced by the linker. The linker will choose whatever it needs, then copy these items out of the library into whatever it may be building at the time.

A .dll is a dynamic library ... "dynamic" in the sense that applications (and, other DLLs ...) can load it and unload it at runtime. (The Windows program-launcher also automatically loads any DLLs that are directly or indirectly referenced by anything it is launching.)

.dll's are "all or nothing." You load them in their entirety, at runtime. .lib's, by contrast, are true libraries, which are used only by the linker.

=== Edit: And the next Answer, IMHO, "nailed it."

like image 115
Mike Robinson Avatar answered Dec 08 '22 06:12

Mike Robinson


Git repos are about code, and you should not have binaries in your git repos.

However, github has a feature called releases which allows you to upload binary assets alongside your tagged source releases.

You can add your compiled libraries there.

like image 29
PSkocik Avatar answered Dec 08 '22 07:12

PSkocik