Linux command
ranlib 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Generate index for archive
ranlib [libfoo.a]
Generate index using actual timestamps
ranlib -U [libfoo.a]
Generate index in deterministic mode
ranlib -D [libfoo.a]
Process multiple archives
ranlib [*.a]
说明
ranlib generates or updates the symbol table index in a static library archive (.a file), enabling the linker to quickly locate symbols without scanning every object file in the archive. Without this index, the linker must process object files in order and may fail to resolve symbols that appear in a later object file than the one referencing them. While modern versions of ar automatically create this index when building archives (equivalent to ar -s), ranlib remains useful for regenerating indexes on archives that have been modified or transferred between systems.
参数
- -c
- Don't warn when the library has to be created (for compatibility).
- -D
- Operate in deterministic mode. Use zero for UIDs, GIDs, and timestamps. Enabled by default on some systems.
- -U
- Do not operate in deterministic mode; use actual UIDs, GIDs, timestamps, and file modes.
- -t
- Update the timestamp of the symbol map of an archive.
- -v
- Verbose output.
- -V
- Print version information.
FAQ
What is the ranlib command used for?
ranlib generates or updates the symbol table index in a static library archive (.a file), enabling the linker to quickly locate symbols without scanning every object file in the archive. Without this index, the linker must process object files in order and may fail to resolve symbols that appear in a later object file than the one referencing them. While modern versions of ar automatically create this index when building archives (equivalent to ar -s), ranlib remains useful for regenerating indexes on archives that have been modified or transferred between systems.
How do I run a basic ranlib example?
Run `ranlib [libfoo.a]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c do in ranlib?
Don't warn when the library has to be created (for compatibility).