| View previous topic :: View next topic |
| Author |
Message |
paulotex
Joined: 20 Jan 2008 Posts: 19
|
Posted: Tue Sep 23, 2008 4:16 am Post subject: autoconf fails linking in C++ |
|
|
This is silly, but I don't know where to look further to solve it:
I'm trying to compile an autotools project in C++ (djvulibre) and lots of tests are failing because linking fails. For example, looking for -lm:
| Code: | $ CXXFLAGS="-I`psp-config -p`/include -I`psp-config -P`/include -G0 -fno-rtti" LDFLAGS="-L`psp-config -P`/lib -L`psp-config -p`/lib -lc -lpspuser" ./configure --host=psp --prefix=`psp-config -P` --disable-shared --enable-static --without-x --without-qt
...
checking for sqrt in -lm... no
...
|
In config.log:
| Code: |
configure:22109: checking for sqrt in -lm
configure:22144: psp-g++ -o conftest -I/Users/paulo/pspdev/psp/sdk/include -I/Users/paulo/pspdev/psp/include -G0 -fno-rtti -L/Users/paulo/pspdev/psp/lib -L/Users/paulo/pspdev/psp/sdk/lib -lc -lpspuser conftest.cpp -lm -lc -lpspuser >&5
/Users/paulo/pspdev/psp/lib/libc.a(_write.o): In function `_write':
libcglue.c:(.text+0x84): undefined reference to `sceIoWrite'
...
|
The code that fails (conftest.cpp) is:
| Code: | /* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sqrt ();
int
main ()
{
return sqrt ();
;
return 0;
}
|
But this code compiles fine in C:
| Code: |
$ cp conftest.cpp conftest.c
$ psp-gcc -o conftest -I/Users/paulo/pspdev/psp/sdk/include -I/Users/paulo/pspdev/psp/include -G0 -fno-rtti -L/Users/paulo/pspdev/psp/lib -L/Users/paulo/pspdev/psp/sdk/lib -lc -lpspuser conftest.c -lm -lc -lpspuser
cc1: warning: command line option "-fno-rtti" is valid for C++/ObjC++ but not for C
conftest.c:4: warning: conflicting types for built-in function ‘sqrt’
|
All tests that use the 'extern "C" ' are failing the same way.
I'm probably doing something wrong here, but I don't know what... I've tried changing the linking order of the libs, adding more libs, all to no avail. Any suggestions?
Thanks. |
|
| Back to top |
|
 |
sedrik
Joined: 04 Sep 2008 Posts: 8
|
Posted: Tue Sep 23, 2008 5:32 pm Post subject: |
|
|
add
to your Makefile |
|
| Back to top |
|
 |
paulotex
Joined: 20 Jan 2008 Posts: 19
|
Posted: Tue Sep 23, 2008 6:29 pm Post subject: |
|
|
| sedrik wrote: | add
to your Makefile |
That was the solution, thanks! I did try it before, but not in the correct order. It should go before -lc, and I didn't try it. I knew it had to be something silly. Thanks again! |
|
| Back to top |
|
 |
|