Re: stupid gcc & ld problem
Originally Posted by
odradek
I am working on some small OS development project and I need to link several object files into one flat binary. But, I am using Ubuntu only for a few months, so, it's little hard to adjust.
You can include your object files, assuming they are ELF format, on the same line with your C/C++ files. For example,
Code:
gcc myProg.c sub1.c sub2.o -o myProg
I do this often when I write functions in assembly language. I first assemble them, giving their respective object files. Then I use gcc to compile the main function (which is written in C) and link it with the already assembled object files. gcc is smart enough to know whether it has to compile the function or not. Then it goes on to the ld phase, automatically linking in the required C libraries.
(I do not show various options you may wish to use in my command above.)
Intel i7-920; Nvidia GT 220, 1GB; MSI X58 Pro-E; 6GB DDR; 64-bit mode.
Bookmarks