Linker issues with autoconf w/ solution

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Linker issues with autoconf w/ solution

Post by mrbrown »

While porting google-perftools to PSP, I noticed that configure wasn't picking up the sbrk() function in libc. The problem linker command was:

Code: Select all

psp-gcc -o conftest -g -O2  -L/usr/local/pspdev/psp/sdk/lib -lc -lpspuser conftest.c
which meant that conftest.o appeared on the linker command line before "-lc -lpspuser". With this command, sbrk() wasn't being detected, but if I moved -lc to the end of the line, it would link as it was supposed to.

One solution is to pass the LIBS environment variable to configure, so that required libraries appear at the end of the linker command line, which is how the GNU linker prefers it. So the usual configure command line becomes:

Code: Select all

LDFLAGS="-L`psp-config --pspsdk-path`/lib" LIBS="-lc -lpspuser" \
  ./configure --host psp --prefix=`psp-config --psp-prefix`
which produces:

Code: Select all

psp-gcc -o conftest -g -O2  -L/usr/local/pspdev/psp/sdk/lib conftest.c -lc -lpspuser
I'm guessing that this change needs to be made across all of the autoconf'd programs and libraries we have in SVN, if anything to show the right way to do it. An easy way to tell if the change would make any difference is to do a diff of config.h before and after this change. If configure picked up any functions that it hadn't seen before, then the change is definitely needed.
Post Reply