On 21 December 2012 09:38, Mark Galeck (CW) wrote: > Hello, > > I had posted the question below 5 days ago but there were no replys. At that time, it was a mere curiosity. But now, what appeared to work then, actually does not work... So now I am in trouble and I have more symptoms. > > What is going on, and how do I get g++ linker to work here?? > > ------------------------ > > Previous message: > > (...) > when using g++ to link about 2300 .o files into a single library, total size about 29MB, and -mlongcall does not help. > (...) > This doesn't work (24-bit relocation error) > >>g++ -fPIC `<command to list object files>` > > > However, this works correctly (!!!???) > >>echo `<the same command to list object files>` | xargs g++ -fPIC > > --------------------- > > > Now: > Actually, the second version also does not work. It does not give an error message, and there appears a big library. BUT: Some symbols are defined in some object files, but then become undefined in the resulting library!!! > > If I decrease the number of object files to about 1200, the symbols in question vanish completely from the library!!! > > Finally, if I decrease the number of object files further to about 800, the symbols in question are present in the library again, and this time defined as they should. > > > > > Please anybody knows what could be happening??? I don't know what the relocation error is about, but it's not surprising that using xargs doesn't help. See the man page for xargs: The command line for command is built up until it reaches a system-defined limit (unless the -n and -L options are used). The specified command will be invoked as many times as neces‐ sary to use up the list of input items. So xargs is splitting up your command into: g++ -fPIC <some of the object files> g++ -fPIC <some more of the object files> g++ -fPIC <the rest of the object files> Each of these commands will produce an output file containing some of the objects, then the next command will overwrite that file with a new output file containing different objects. Have you thought about adding the objects to an archive instead of trying to link 2300 objects in a single command? You can add new objects to an archive, so it wouldn't have to be done in a single command.