Create a static Library from your .c source file

Reading Time: 1 minute

 I am preparing the code I have to use for the Global Game Jam 2013 which will occur next week end, 25-27 of January 2013.

The idea is to use my 3D Engine, PATRIA for the development of the game but I would like to avoid to share the last 2 years efforts with everyone in the world. This considering as well that PATRIA3D is not only the results of my efforts but the result of the efforts of all the team members of the Team Novasoft.


Considering that PATRIA is a modular system where each component of the engine has its own .c and .h, the best solution is to compile the .c files of the core engine which most probably won’t be altered during the JAM is static libraries.

In this way I will use just the .a (static library) and the header file .h

In order to do this operation, the following steps are required:


1. Compile the .c file you want to create the library

2. Once the file is compiled, you have the .o, the object file compiled by the GNU C Compiler.


3. Now, to create the static library, you need to use the ar command. Remember that a static library must start with the prefix lib and must end as ".a"


4. At this point you have your library. The best choice in my humble opinion is to copy it into the OS /usr/lib so that it will be usable at system level. Copy it over there.


5. Include the library into the Eclipse project



N.B. remember to remove in the eclipse library reference the lib and the extenstion!


Now you can build your project with your libraries and the code is safe!




Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.