-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Hi, doctor:
I'm not sure if you're still following this repo, but I sincerely want to give you some response.
in Part-28, you mentioned that:
One annoyance is that I'm still calling the external C compiler cc to do the linking.
...
I assume that it should be possible to do a similar command on current Linux, but so far my Google-fu isn't enough to work this out. If you read this and know the answer, let me know!
Now I know how to link without using gcc:
Assuming we have a obj file named out.o
, we can execute the following command to generate an executable file:
$ ld -o out out.o /lib/x86_64-linux-gnu/crt1.o -lc -dynamic-linker /lib64/ld-linux-x86-64.so.2
crt1.o
is a starter which calls main-lc
linklibc
or other libs if we needld-linux-x86-64.so.2
helps to load dynamic libs
If
ld-linux-x86-64.so.2
orcrt1.o
is not found, you may find them bylocate
or any other command.
I don't know if additional parameters will be needed in the future, but they do work for now.
If you see this message, please tell me it works.
Thanks :)