Linker errors after adding new library

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

Moderators: cheriff, TyRaNiD

Post Reply
ColdPie
Posts: 2
Joined: Sat Dec 31, 2005 12:30 pm

Linker errors after adding new library

Post by ColdPie »

Hello.

I'm trying to add audio to my PSP game. I grabbed the MP3 codec header & source files from the PSP Media Center project (suggested by the FileAssistant++ crew) and molded it to fit my sources. Since the MP3 codec files make use of the MAD (mpeg audio decoder) libraries, I grabbed and installed those to my PSPSDK directories, too. I also added the library to my makefile. Everything compiles fine, but when it tries to link mp3player.o with the MAD libraries, I get the following error:

Code: Select all

undefined reference to '<function>'
for every MAD function that the mp3player uses.

Because the linker doesn't give any "file not found" errors, I'm pretty sure MADlib is installed correctly. It seems like it just skips the -lmad line. I've tried a lot of things, including recompiling MAD with a few different ./configure options, but nothing seems to work.

Any suggestions or ideas are welcome!
Thanks.
sandberg
Posts: 90
Joined: Wed Oct 05, 2005 1:25 am
Location: Denmark

Post by sandberg »

Remember that the order of the -l arguments in your makefile matters. So you need to have the -lmad directive in the right place.

So

Code: Select all

-lmad -lsomemp3library
is not the same as

Code: Select all

-lsomemp3library -lmad
Br, Sandberg
ColdPie
Posts: 2
Joined: Sat Dec 31, 2005 12:30 pm

Post by ColdPie »

sandberg wrote:Remember that the order of the -l arguments in your makefile matters. So you need to have the -lmad directive in the right place.
Yes, I've tried that. I'm still stuck after a few days of messing with various makefile options. mad.h is included fine, the whole program compiles fine, but it can't link to libmad. Does anyone else have any suggestions? I'll be happy to provide more info, just let me know what you need. If you want to email me, feel free ([email protected])
sandberg
Posts: 90
Joined: Wed Oct 05, 2005 1:25 am
Location: Denmark

Post by sandberg »

ColdPie wrote:
sandberg wrote:Remember that the order of the -l arguments in your makefile matters. So you need to have the -lmad directive in the right place.
Yes, I've tried that. I'm still stuck after a few days of messing with various makefile options. mad.h is included fine, the whole program compiles fine, but it can't link to libmad. Does anyone else have any suggestions? I'll be happy to provide more info, just let me know what you need. If you want to email me, feel free ([email protected])
You can try to take a look at the makefile for PSPRadio. We use the mad library for MP3 as well. You can find the sources for PSPRadio from the link below.

http://svn.berlios.de/svnroot/repos/pspradio/trunk/PSP/

The makefile can be found in PSPRadio/Makefile
Br, Sandberg
Martyburns
Posts: 1
Joined: Tue Feb 21, 2006 5:57 pm

Post by Martyburns »

Hey,

I am having this same issue. No complaint about finding the library but cannot reference functions in it.

Did you get anywhere with this?

I have ensured that my makefile is similar to the PSPRadio one, and cannot see anything else that should be causing this.

I am guessing there is a problem with the build/insatllation of the mad lib,
but it also appears OK as it built and installed libmad.a file to C:\cygwin\usr\local\pspdev\psp\lib\ as expected.

I am stuck and any help would be appreciated.
Gan Quan
Posts: 5
Joined: Mon Sep 18, 2006 6:42 pm

Post by Gan Quan »

I've just donwloaded libmad from the svn repository, installed it, and tried to build a test program, the same problem poped up.
The code is compiled just fine, but the linker throws out "undefined reference to function" errors for each function of libmad.
It's been a long time since ColdPie posted this problem, I'm wondering if there is a solution? Any input would be appreciated.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Make sure you're linking in this order:

LIBS = -lmad -lpspaudiolib -lpspaudio
Gan Quan
Posts: 5
Joined: Mon Sep 18, 2006 6:42 pm

Post by Gan Quan »

Insert_witty_name wrote:Make sure you're linking in this order:

LIBS = -lmad -lpspaudiolib -lpspaudio
Thanks!! it works now!!

For people who encountered this problem (and, new to unix c programming, having no clue about writing Makefiles, like me), I just added "LIBS = -lmad -lpspaudiolib -lpapaudio" in my Makefile.
Post Reply