A Python tool to merge all object files (.o) from a static library (.a) into a single object file. Supports custom paths for ar and ld commands.
- Extracts object files from static libraries using
arcommand - Merges extracted object files into one using
ld -r - Supports custom paths for
arandldcommands - Option to keep temporary files for debugging
- Verbose output mode
- Python 3.6+
arandldcommands available in PATH (or specify custom paths)
No installation required. Just ensure Python 3 is installed and the script has execute permissions:
chmod +x merge_lib.pyBasic syntax:
./merge_lib.py input_library.a [-o output.o] [options]| Option | Description |
|---|---|
input_library.a |
Input static library file (required) |
-o, --output |
Output object filename (default: same as library name with .o extension) |
--ar |
Custom path to ar command (default: ar) |
--ld |
Custom path to ld command (default: ld) |
--keep-temp |
Keep temporary directory for debugging |
--verbose |
Show verbose output |
-h, --help |
Show help message |
- Basic usage:
./merge_lib.py libexample.aOutputs: libexample.o
- Custom output filename:
./merge_lib.py libexample.a -o combined.o- With custom tool paths:
./merge_lib.py libexample.a --ar /custom/path/to/ar --ld /custom/path/to/ld- Keep temporary files and show verbose output:
./merge_lib.py libexample.a --keep-temp --verbose- The tool creates a temporary directory during operation (cleaned up unless
--keep-tempis specified) - Requires both
arandldcommands to be available (either in PATH or specified) - Tested on Linux systems, may require adjustments for other platforms