Why do we try to link third party libraries if we have source code of many of libraries available online

129 Views Asked by At

I have seen many questions on Stack Overflow like "how to include curlpp etc in Visual Studio?"

If we have the code of these libraries available online, why do people explicitly use .lib files to include to their projects when they can add the code directly to their project?

And I'm trying to achieve the above said thing for curlpp but I'm not successful, getting so many linker errors. Can someone suggest how to integrate the open source code directly which I wanted to do this even if this approach has drawbacks? Can you direct me to some blog post or steps to achieve this? And what are the drawbacks of this approach?

Edit: Compiling may not be a valid reason if I'm not dealing with large amount of code. And from users' point of view you still you have to distribute the binaries used by the project. Except the compilation factor and suppose the code is open source and there are no licensing issues, what can be the other drawbacks?

My main question is to know how to integrate such third party code directly.

Thanks for all drawbacks but I'm trying to experiment so can you guide me how to do this?

2

There are 2 best solutions below

0
On

Libraries also help in: i. Componentization ii. Decoupling API's with implementations.

You also want to think of the cost of managing a monolith code. If you were to include the source code of libraries into the project, the well defined API boundaries will begin to fade over period of time.

3
On

For a lot of reasons. From the developer side:

  • you don't want to compile a lot of stuff if you have it already compiled by someone else
  • you don't want to download sources and compile them over and over again every time they get updated by the third party developer
  • you don't want your binaries to be larger than what they need
  • GPL linking exception and other possible licensing issues

From users side:

  • you don't want the same library to be hardcoded into several different program binaries (this would be a disk and memory waste)