2022-06-28 07:51:38 -04:00
|
|
|
# ld
|
|
|
|
|
|
|
|
> Link object files together.
|
2025-04-23 10:24:12 +03:00
|
|
|
> More information: <https://sourceware.org/binutils/docs/ld.html>.
|
2022-06-28 07:51:38 -04:00
|
|
|
|
|
|
|
- Link a specific object file with no dependencies into an executable:
|
|
|
|
|
2025-04-20 00:21:53 +03:00
|
|
|
`ld {{path/to/file.o}} {{[-o|--output]}} {{path/to/output_executable}}`
|
2022-06-28 07:51:38 -04:00
|
|
|
|
|
|
|
- Link two object files together:
|
|
|
|
|
2025-04-20 00:21:53 +03:00
|
|
|
`ld {{path/to/file1.o}} {{path/to/file2.o}} {{[-o|--output]}} {{path/to/output_executable}}`
|
2022-06-28 07:51:38 -04:00
|
|
|
|
|
|
|
- Dynamically link an x86_64 program to glibc (file paths change depending on the system):
|
|
|
|
|
2025-04-20 00:21:53 +03:00
|
|
|
`ld {{[-o|--output]}} {{path/to/output_executable}} {{[-I|--dynamic-linker]}} /lib/ld-linux-x86-64.so.2 /lib/crt1.o /lib/crti.o -lc {{path/to/file.o}} /lib/crtn.o`
|