forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

autoconf fails linking in C++

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
paulotex



Joined: 20 Jan 2008
Posts: 19

PostPosted: Tue Sep 23, 2008 4:16 am    Post subject: autoconf fails linking in C++ Reply with quote

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
View user's profile Send private message
sedrik



Joined: 04 Sep 2008
Posts: 8

PostPosted: Tue Sep 23, 2008 5:32 pm    Post subject: Reply with quote

add

Code:
LIBS=-lstdc++


to your Makefile
Back to top
View user's profile Send private message
paulotex



Joined: 20 Jan 2008
Posts: 19

PostPosted: Tue Sep 23, 2008 6:29 pm    Post subject: Reply with quote

sedrik wrote:
add
Code:
LIBS=-lstdc++

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group