I have been asked to provide a C-library of my code (which I have written in a high-level language). I will hire a programmer to implement my code in C. I would like a short introduction to what a “C-library” means before I start this process.
- Is it correct that I can provide a C-library and that the people who use it will not be able to see the actual source code?
- I understand that the library will inlude .h-files which determine how the people that I give the code to will interact with the library. Can I have just one of these files so that the internal structure is hidden?
- In this situation, I assume that the library should be dynamically linked. Why is that?
4
- Yes
- Yes
- It doesn’t have to be dynamically linked.
In detail: When creating a library (doesn’t have to be in C, but I assume this means it needs to expose its functionality in the form of exported C functions) then the source code is turned into the equivalent machine instructions. While a skilled hacker could turn this machine code back into a higher level language, its really awkward and the resulting decompilation is really difficult for a human to understand. So you’re pretty much safe from anyone stealing your algorithms, unless they’re really worth the effort.
In order to use a library like this, you need a way to tell programs that link with the lib what is inside it, this is typically done with a header file. A single header containing only those exported functions is fine. The only reason people use multiple headers is because they don’t want the trouble of maintaining duplicates and so simply ship the headers used in development.
The choice of dynamic or static is up to you. A dynamic library can be replaced with a newer version easily. This is the most common reason to ship in this format.
3