Skip to main content

Posts

Showing posts from August, 2017

Build system comparison for C shared library: Manual vs. Makefile vs. Bazel

Here is a simple code for shared library (.so) and an executable that uses it: Library Source files (libhello.c and libhello.h): Source for the executable that uses the above library (main.c): There are many ways to build and execute these sources. Lets look at three of them. The first one is a collection of manual commands that you need to execute in a particular order. The other two uses some form of build system. Before you proceed, make sure to have the C compiler installed on your Ubuntu PC. To do this, execute the following at the command prompt: sudo apt-get install build-essential git Manual build: (Reference: http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html ) Place the three source files in the same directory. Open the command prompt, switch to the same directory and execute the following commands to compile, execute and clean: Compilation Compiling the library sources into object files with Position Independent Code: gcc -c -Wal...