![]() ![]() What we will build is a shared library in Linux that will be integrated by a program. ![]() What the example aim to do is to create a library that implements internal basic math operations ( sum, subtraction, multiplication, division) exposing only a single functionality (called compute) that will be externalized in order to let the actual program to use them. private : contains the real implementation of the logic that will be hidden (not linkable), accessible only through public APIs.public : contains APIs definition that will be publicly accessible through.That’s the reason why I’ve designed the example with public and private structure: Libraries might also be designed with the goal of splitting what will be exposed to the external world with the inner logic that will actually implement the logic. Libraries are a way to isolate common pieces of software (let’s say functions), making them available to other programs, offering integration points (usually called APIs) that the applications will use in order to leverage the algorithms implemented through them. ![]() Generally speaking, it’s a good (required!) practice to write software following a modular design in order to make it easy to evolve/maintain/understand. This is not a guide on C language, not even a guide on what a C library is, this is more like a collection of findings needed in order to achieve this purpose. I couldn’t find a clear and simple example on how to do such a basic and quite common thing like creating a C library using CMake as building tool. The purpose of this post is to give an example on how to create a C Shared library using CMake as building tool in a Linux box. ![]()
0 Comments
Leave a Reply. |