Then after search in this forum and the internet I found that the name of linking file must have the prefix lib. So I added and then after successfully compile the output of library2 project is library2.so file.
Have you looked at the actual name of the binary file? i think codeblocks adds lib infront automatically if you create a library. You can change the output file name in Project->Properties->Build targets->output filename
My question is, there is a way to automatically generate both the liblibrary1.so and the library1.so file when compiling
There are multiple ways to do this.
Way 1 (personally my preferred way):
Use one project for all libraries and the executable. Use a target for each library and one for the final binary. Then create a virtual target that builds all targets in order. If nothing changed codeblocks will jump over this target..
Way 2:
Use multiple project and add dependencies to each other:
1) All projects have to be in the same workspace
2) Project->Properties->Project settings->Projects dependencies->Select your project from the drop down (should be default) -> Tick all projects this project depends on
3) Set up a external dependency to the library binary file: Project->Properties->Build targets->Dependencies->External dependency->Add the library file
Step 2) will check if the other project is up to date
Step 3) will check the explicit binary output file from the other project.
[Edit:] Workspace does only mean, they have to be open in the codeblocks editor, not in the same folder as for example in eclipse....
hope this helps...
greetings