

The first two commands create a build_static temporary directory which is used by cmake. The simplest solution is to use cmake and to run the following commands at the root of the Yoctopuce library.
#INSTALL CMAKE UNIX HOW TO#
Installing the static library under LinuxĪfter this lengthy introduction, here is how to install the Yoctopuce library on your Linux system.
#INSTALL CMAKE UNIX CODE#
The counterpart is that the code works only on machines which have this library installed. Theoretically, this enables you to spare space of the hard disk if several programs use the same library, because all the programs don't need to include the code of the library anymore. The advantage of installing the dynamic version of our C++ library is almost non-existent. It's especially useful with docker and cross compilation tools. You don't need anymore to specify in you project where the files of our library are located. When it is globally installed, all the tools, compilers, linkers, and so on have access to the library. The advantage of installing the static version of our library is to simplify the build script. Otherwise, the application crashes with a "cannot open shared object file: No such file or directory" message. If it is the case, it adds them dynamically and the execution of the program can go on. When executing, the operating system checks that the dynamic libraries referenced by the executable file are available in the /lib or /usr/lib directories. Under Linux, the (dynamic or static) libraries are usually stored in the /lib and /usr/lib directories, but there is an option for the linker to look for libraries in other directories. The executable file is smaller, but when the program is running the library must be installed on the machine. With dynamic edition, the executable file includes only a reference to the library. The generated program is therefore larger, but it contains all the code necessary for its execution. With static edition, the libraries are included into the executable file. It can integrate it into the executable file (static edition) or it can store a reference to the library (dynamic edition). The linker has two ways to use an external library. Finally, it generates the executable file. During this step, the linker checks that all the parts are compatible with one another and each referenced function or object is available. o files and the external libraries to form the executable file. The second step is linking, consisting in taking all the. Under Linux, headers are usually stored in the /usr/include and /usr/local/include directories, but there is an option for the compiler to add other directories to this list. cpp file, but it also needs to have access to all the. During this phase, the compiler needs the. o object files containing the binary code that the machine is able to run. The first step consists in compiling the source files, the. This installation is very simple thanks to cmake.įirst of all, let's have a short reminder of C++ and of the different steps of the life of a program written in C++. This week, we are going to show you how to compile our C++ programming library under Linux and to install it as a system library.
