Ok, this is the situation: I'm trying to use some older software: works fine on Ubuntu Lucid, fails on Natty.
So, I strace
d around a bit, and it turns out that this software calls ld
, and ld
eventually fails with:
.../ld: crt1.o: No such file: No such file or directory
... yes, the old crti.o file missing error :) However, I'd like to ask the question in more general terms...
The thing is, this is 'standalone' (older) ld
here, and when I run .../ld -verbose | less
, I get:
...
SEARCH_DIR("/usr/local/lib");
SEARCH_DIR("/lib");
SEARCH_DIR("/usr/lib");
...
Now, the thing is that:
- On Lucid,
crt1.o
is in/usr/lib/crt1.o
- On Natty,
crt1.o
is in/usr/lib/i386-linux-gnu/crt1.o
... so no surprise why crt1.o
cannot be found, I guess. It seems, all I have to do, is tell ld
to look for crt1.o
in /usr/lib/i386-linux-gnu
, but how do I do that?
I thought I could use the -L
option, but man ld
says:
to link a file "hello.o":
ld -o <output> /lib/crt0.o hello.o -lc
This tells ld to produce a file called output as the result of linking
the file "/lib/crt0.o" with "hello.o" and the library "libc.a", which
will come from the standard search directories.
...
-L searchdir
--library-path=searchdir
Add path searchdir to the list of paths that ld will search for
archive libraries and ld control scripts.
... meaning, '-L
' would influence where we look for "libc.a
" (in man example) - but not for the object files.
I would actually prefer an environment variable for this, but I tried both LD_PRELOAD_PATH
and LD_LIBRARY_PATH
to no avail (I guess, those are related to "shared objects", and these .o
files aren't one of those).
Does anyone know if there is an environment variable (preferably - or if not, command line option to ld
) that would control where ld
searches for .o
object files?
As a note, I guess I could just symlink /usr/lib/i386-linux-gnu/crt1.o
in /usr/lib/
, but I'd rather use an environment variable, if it exists... If not, are there any other possible solutions to this?
Thank in advance for any answers,
Cheers!
EDIT: possibly relevant: Daniel Kegel - --with-sysroot newbie troubles: "ld: cannot open crt1.o"