1

I have been statically compiling a library I downloaded from github to use it for my own project.

In order to simplify my workflow, I thought of copying function definitions from the library into my code instead of linking it to my object files. This would remove the necessity of having to use header files and also significantly reduces the size of my final executable and compile time. Is there a disadvantage to this approach?

3
  • 1
    Sometimes porting external code leads to a domino effect so that you need to port another function, and another, and another... if you don't have this issue, and you are sure there are no further dependancies (eg it compiles, but in order to work another function initializing a specific struct is needed) I don't see disadvantages. May 6, 2020 at 4:39
  • 3
    Are you sure it reduces the size of your executable? If it does, there is room to argue that the library is not well designed. The main disadvantage of what you propose is that when the library has a bug fixed, you have to find where the fixed code is in your program, and apply the fix there. Also, you'd often end up with several of your source files using a given library function, and in that case, you'd still need to create a header to declare the function correctly. Roughly speaking — DON'T DO IT!!! May 6, 2020 at 4:39
  • Ps: I don't know if there are consequences related to licensing. Wait another comment for that. May 6, 2020 at 4:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.