I did not find any proper information if and why I need ranlib / ar -s for static linking.
Assume I have an application that consists of multiple modules. Each module has its code files in its own folder, and the object files are created in their own folder: module1/%.c → bin/module1/%.o. For each module I create an .a file: ar -rc bin/module1.a bin/module1/….o. The whole program gets compiled with gcc bin/module1.a … moduleN.a -o bin/app.
In this scenario what does creating an index for the .a file do? The compilation and program works just fine even if I don't add indexes to the .a files. But every example that I found called ranlib after the last object file was added to the archive.
The question is not Linux / Mac / Windows specific.