Page 1 of 1

ld refusing to link after so many files?

Posted: Mon May 09, 2005 8:31 pm
by Warrior
It's like refusing to link says "System cannot execute the specified program"

About 15 object files.

Re:ld refusing to link after so many files?

Posted: Mon May 09, 2005 11:02 pm
by AR
There is a maximum length on the command line, you can't get more than 255 characters I think it is. I think normal Windows command line programs support the normal 32766 characters but if you're using DJGPP or a batch file than it may not work.

You may want to try a makefile instead of a batch (DJGPP also supposedly has a hack around to support longer command lines in DOS if you use DJGPP make).

(I've had to make broad assumptions here, your post is not very descriptive since you could be using Linux, BSD, Mac or Windows, you also didn't give an example making it rather vague)

Re:ld refusing to link after so many files?

Posted: Mon May 09, 2005 11:03 pm
by Warrior
I'm sorry, I'm using the Windows Platform. I'll look into a makefile thanks.

Re:ld refusing to link after so many files?

Posted: Tue May 10, 2005 12:06 am
by Pype.Clicker
you may want to use cygwin shell & binutils too. Since they're native windows programs instead of DOS+DPMI, they're likely to have better support for large command line, many many open files at a time, etc.

Re:ld refusing to link after so many files?

Posted: Tue May 10, 2005 1:24 am
by Solar
It is also common practice to combine several object files into a link archive (using GNU 'ar', part of the binutils package), and linking that using ld's "-l" option.

Re:ld refusing to link after so many files?

Posted: Tue May 10, 2005 7:39 pm
by vbbrett
Well, I think you guys are making this a bit too hard. After creating all my object files(such as kmain.o, ioport.o) in the same directory, I do this:

ld -T link.ld -o bootstrap.bin boot2.bto *.o

bootstrap.bin is, of course, my bootsector.
boot2.bto is the A.out file which I use to jump to my kernel
*.o just specifies all the .o files found in the folder.

Brett

P.S. I've gotten more than 15 files on this. I think I'm currently using something like 20... maybe... can't remember...

Re:ld refusing to link after so many files?

Posted: Tue May 10, 2005 8:29 pm
by AR
I am aware of that solution (I used it myself for a while) but a makefile is a much better long term solution since it does conditional compilation where it doesn't rebuild things that don't need need rebuilding.

Re:ld refusing to link after so many files?

Posted: Tue May 10, 2005 9:02 pm
by Warrior
Wow, thanks for the wildcard linking! I'll definately look into a makefile as well.

Re:ld refusing to link after so many files?

Posted: Tue May 10, 2005 9:58 pm
by Solar
Note that, AFAIK, wildcards are expanded by the shell before being passed to the executable. You are likely to run into the next wall once you exceed the command length limit of 'ld'.

'ar' archives, as well as Makefiles, speed up your build cycle.

Re:ld refusing to link after so many files?

Posted: Wed May 11, 2005 12:41 am
by distantvoices
makefile & ar are definitely the way to go.

just recently I've converted my project from using a custom build script - which became a hell to maintain - to using Makefiles, and look, the build process is much cleaner now.

Further, for my 30+-entries runtime library, ar is the tool of choice, definitely. LD picks the object files it needs out of it. :-)

stay safe.