Creating a PSP Library

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

Moderators: cheriff, TyRaNiD

Post Reply
71M
Posts: 122
Joined: Tue Jun 21, 2005 5:28 am
Location: London

Creating a PSP Library

Post by 71M »

Hi,
I'm having problems creating a lib file for the PSP.
The library compiles and creates a .a file, but when I try and link the lib into my project I get an 'undefined reference to...' error.

www.easy-monkey.co.uk/libtest.rar

Hope somebody can help me figure this one out.

Thanks,
71M
71M
Posts: 122
Joined: Tue Jun 21, 2005 5:28 am
Location: London

Post by 71M »

Alternatively does anyone have an example of a simple library that works?
I've successfully compiled and linked in libpng and zlib, but can't see any differences between those library definitions and the ones I've created.

Cheers,
71M
rinco
Posts: 255
Joined: Fri Jan 21, 2005 2:12 pm
Location: Canberra, Australia

Post by rinco »

links fine for me... -L. -ltest
but i have to wonder why you've declared the function as external.
71M
Posts: 122
Joined: Tue Jun 21, 2005 5:28 am
Location: London

Post by 71M »

rinco wrote:links fine for me... -L. -ltest
but i have to wonder why you've declared the function as external.
I've managed to find the problem.
I bet you're linking the lib into a C project. Trying to link it into a C++ project throws up the errors.
By changing the header to this -

Code: Select all

#ifdef __cplusplus
extern "C"
{
#endif

int	TestFunction();

#ifdef __cplusplus
}
#endif
It links correctly!
I shoulda guessed this one!!!
Thanks for all your help.

Cheers,
71M
elevationsnow
Posts: 22
Joined: Sat Sep 10, 2005 6:45 am

Post by elevationsnow »

could you tell me how you succefully installed libpng im using cygwin and it just doesnt want to install
liquid8d
Posts: 66
Joined: Thu Jun 30, 2005 6:29 am

Post by liquid8d »

taken from this post:

http://forums.ps2dev.org/viewtopic.php? ... sc&start=0

----------------------
in your Cygwin Bash Shell (or whatever you use) enter the folowing lines;
svn co svn://svn.ps2dev.org/psp/trunk/zlib -- press [Enter] and wait for the prompt to show back up.
svn co svn://svn.ps2dev.org/psp/trunk/libpng -- press [Enter] and wait for the prompt to show back up.

[Edit] Those two lines up just above this look like links to websites, but they're not, so don't even bother clicking on them.

then you need to change your directory in the bash shell to your psptoolchain/zlib folder, and then type 'make' and then 'make install'
then change the directory over to your psptoolchain/libpng folder and type 'make' and 'make install' again.

You need to include png.h and you need to add the following to your makefile;

Code:
LIBS = -lpng -lz
----------------------------

LiQuiD8d
Post Reply