I want to take all of the C++ object files in a directory and ball them up into one object file.
I tried "g++ -r -o out.o in_1.o in_2.o ...", but I get the error message "/usr/bin/ld: cannot find -lgcc_s". What's up with that?
Printable View
I want to take all of the C++ object files in a directory and ball them up into one object file.
I tried "g++ -r -o out.o in_1.o in_2.o ...", but I get the error message "/usr/bin/ld: cannot find -lgcc_s". What's up with that?
Do you want ar?
Ah, that works much better. Thanks! I used to use ar, but I decided I wanted to simplify my build procedure by having each subdirectory make one object file, and then combine those at the top level. Before, I had a directory full of libraries that had to be listed in exactly the right order to the loader.
The problem with using merged objects instead of libraries is that during library linking, ONLY the .o files (within the libraries) which contain functions that are ACTUALLY REFERENCED are linked. If you merge a bunch of .o files into a monolithic object, this ENTIRE object must either be linked, or not linked.
So if you want to use only one or two functions from such a "library," the linker is going to pull in EVERYTHING, including a bunch of dead code.
Not to mention that you might get name conflicts with internal-only functions. Or does the linker rename them on merging?
Yes, to a masochist. To us normal people it would just be a nightmare.