This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

should I be using -rpath-link? or is there a better way?


I'm cross-compiling an app I wrote using mipsel-uknown-linux-gnu-gcc.
This app calls functions from the libsmbclient.so library, which
already exsists on my target root.  It turns out that libsmbclient.so
depends on libiconv.so, but I didn't know that until I compiled my
app:

  mipsel-unknown-linux-gnu-gcc -Isamba-3.0.0/source -o app.o -c app.c
  mipsel-unknown-linux-gnu-gcc -L/path/to/root/lib -lsmbclient -o app app.o
  /path/to/targets/mipsel-unknown-linux-gnu/gcc-3.3.2-glibc-2.3.2/lib/gcc-lib/mipsel-unknown-linux-gnu/3.3.2/../../../../mipsel-unknown-linux-gnu/bin/ld: warning: libiconv.so.2, needed by /path/to/root/lib/libsmbclient.so, not found (try using -rpath or -rpath-link)
  /path/to/root/lib/libsmbclient.so: undefined reference to `libiconv_open'
  /path/to/root/lib/libsmbclient.so: undefined reference to `libiconv_close'
  /path/to/root/lib/libsmbclient.so: undefined reference to `libiconv'
  collect2: ld returned 1 exit status
  make: *** [/path/to/deschutes/applications/smbmounts/read-all-browse-lists] Error 1

OK, I don't want to use -rpath because I don't want to have to compute
the real runtime load path from my target root path --- I'd rather let
the runtime loader do it like it always does.  So I'll do -rpath-link
so that I only have to know my target root path:

  mipsel-unknown-linux-gnu-gcc -Isamba-3.0.0/source -o app.o -c app.c
  mipsel-unknown-linux-gnu-gcc -rpath-link /path/to/root/lib -L/path/to/root/lib -lsmbclient -o app app.o
  mipsel-unknown-linux-gnu-gcc: unrecognized option `-rpath-link'
  /path/to/root/lib: file not recognized: Is a directory
  collect2: ld returned 1 exit status

Oh, ok, I guess I need to use ld instead:

  mipsel-unknown-linux-gnu-gcc -Isamba-3.0.0/source -o app.o -c app.c
  mipsel-unknown-linux-gnu-ld -rpath-link /path/to/root/lib -L/path/to/root/lib -lsmbclient  -o app app.o
  mipsel-unknown-linux-gnu-ld: warning: cannot find entry symbol __start; defaulting to 0000000000400cf0

Hmmm... looks like I need to buy a clue: I don't know why ld can't
find __start.  I always thought gcc was just calling ld anyway.  Is
there a way to get the __start from gcc while still utilizing the
-rpath-link argument?

Please don't tell me to just put "-liconv" in my LDFLAGS.  I already
know that will work, but I don't like doing it:

  mipsel-unknown-linux-gnu-gcc -Isamba-3.0.0/source -o app.o -c app.c
  mipsel-unknown-linux-gnu-gcc -L/path/to/root/lib -lsmbclient -liconv -o app app.o

My app.c file NEVER calls ANY functions in -liconv, so it seems stupid
to me that I should have to tell my compiler go and link libiconv.so.
That step should have been done when libsmbclient.so was built.  The
only thing my compiler should have to check is whether all the
functions that app.c calls are in libsmbclient.so, and it should go no
further.  Is there a way to compile my app so that I can defer this
checking to runtime?

Thanks,
Dave


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]