Hi, I have written a C++ library as a beginner project. I have created a Makefile with the instructions to compile the code as a static library (make static) and as a dynamic library (make dynamic).
I don't see any file named CliWidget in your repo. You don't #include a library, you add it to the project, also a library shouldn't contain a function called main().
Sorry, the main you see in the src folder is only for test purpose with the classes of the library. So the Makefile has 4 functions:
- make: builds a program with the main to test the code.
- make static: builds the static library (without main).
- make dynamic: builds the dynamic library (without main) .
- make clean: erase all .o files, library files and output.
In a separate folder outside the repository I have two files:
- main.cpp: the main script you see in the first comment.
- libCliWidget.a: the static library compiled using the command make static
In this folder, using g++ is where I try to compile the main.c with the library using g++ -static main.cpp -lCliWidgets -o test_program
Okay I found the problem. I had never built a static library with C++. I didn't know that I needed the header files within the .a file. Now, in the test project I have added the headers and it works now. Obviusly I have changed the #include <CliWidget> for the project headers.