Compile Error

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

Moderators: cheriff, TyRaNiD

Post Reply
JoRDozZzz
Posts: 9
Joined: Thu Apr 05, 2007 6:23 am
Contact:

Compile Error

Post by JoRDozZzz »

Hello everybody,

I'm a beginner with coding in c/c++ and i'm doing a lot of tutorials and try to load music and images in an homebrew. I've made this but i get an error when i compile it. Someone else tried to help me, but it doesn't helped me. please can someone here help me, i'd really like to load an image AND a music(on the background without controls). TY in advance.




Error:
graphics.o: In function `loadImage':
graphics.c:(.text+0x128): undefined reference to `png_create_read_struct'
graphics.c:(.text+0x148): undefined reference to `png_set_error_fn'
graphics.c:(.text+0x150): undefined reference to `png_create_info_struct'
graphics.c:(.text+0x164): undefined reference to `png_init_io'
graphics.c:(.text+0x170): undefined reference to `png_set_sig_bytes'
graphics.c:(.text+0x17c): undefined reference to `png_read_info'
graphics.c:(.text+0x1a4): undefined reference to `png_get_IHDR'
graphics.c:(.text+0x1e0): undefined reference to `png_destroy_read_struct'
graphics.c:(.text+0x20c): undefined reference to `png_set_strip_16'
graphics.c:(.text+0x214): undefined reference to `png_set_packing'
graphics.c:(.text+0x248): undefined reference to `png_get_valid'
graphics.c:(.text+0x260): undefined reference to `png_set_filler'
graphics.c:(.text+0x2b8): undefined reference to `png_read_end'
graphics.c:(.text+0x2c8): undefined reference to `png_destroy_read_struct'
graphics.c:(.text+0x2e0): undefined reference to `png_set_tRNS_to_alpha'
graphics.c:(.text+0x2f8): undefined reference to `png_read_row'
graphics.c:(.text+0x360): undefined reference to `png_set_palette_to_rgb'
graphics.c:(.text+0x370): undefined reference to `png_set_gray_1_2_4_to_8'
graphics.o: In function `saveImage':
graphics.c:(.text+0xb08): undefined reference to `png_create_write_struct'
graphics.c:(.text+0xb18): undefined reference to `png_create_info_struct'
graphics.c:(.text+0xb2c): undefined reference to `png_init_io'
graphics.c:(.text+0xb5c): undefined reference to `png_set_IHDR'
graphics.c:(.text+0xb68): undefined reference to `png_write_info'
graphics.c:(.text+0xc1c): undefined reference to `png_write_row'
graphics.c:(.text+0xc38): undefined reference to `png_write_end'
graphics.c:(.text+0xc44): undefined reference to `png_destroy_write_struct'
graphics.c:(.text+0xc88): undefined reference to `png_destroy_write_struct'
graphics.o: In function `flipScreen':
graphics.c:(.text+0xce0): undefined reference to `sceGuSwapBuffers'
graphics.o: In function `guStart':
graphics.c:(.text+0xe6c): undefined reference to `sceGuStart'
graphics.o: In function `initGraphics':
graphics.c:(.text+0xe80): undefined reference to `sceGuInit'
graphics.c:(.text+0xe9c): undefined reference to `sceGuDrawBuffer'
graphics.c:(.text+0xeb0): undefined reference to `sceGuDispBuffer'
graphics.c:(.text+0xeb8): undefined reference to `sceGuClear'
graphics.c:(.text+0xec4): undefined reference to `sceGuDepthBuffer'
graphics.c:(.text+0xed0): undefined reference to `sceGuOffset'
graphics.c:(.text+0xee4): undefined reference to `sceGuViewport'
graphics.c:(.text+0xef0): undefined reference to `sceGuDepthRange'
graphics.c:(.text+0xf04): undefined reference to `sceGuScissor'
graphics.c:(.text+0xf0c): undefined reference to `sceGuEnable'
graphics.c:(.text+0xf1c): undefined reference to `sceGuAlphaFunc'
graphics.c:(.text+0xf24): undefined reference to `sceGuEnable'
graphics.c:(.text+0xf2c): undefined reference to `sceGuDepthFunc'
graphics.c:(.text+0xf34): undefined reference to `sceGuEnable'
graphics.c:(.text+0xf3c): undefined reference to `sceGuFrontFace'
graphics.c:(.text+0xf44): undefined reference to `sceGuShadeModel'
graphics.c:(.text+0xf4c): undefined reference to `sceGuEnable'
graphics.c:(.text+0xf54): undefined reference to `sceGuEnable'
graphics.c:(.text+0xf5c): undefined reference to `sceGuEnable'
graphics.c:(.text+0xf70): undefined reference to `sceGuTexMode'
graphics.c:(.text+0xf7c): undefined reference to `sceGuTexFunc'
graphics.c:(.text+0xf88): undefined reference to `sceGuTexFilter'
graphics.c:(.text+0xf90): undefined reference to `sceGuAmbientColor'
graphics.c:(.text+0xf98): undefined reference to `sceGuEnable'
graphics.c:(.text+0xfb0): undefined reference to `sceGuBlendFunc'
graphics.c:(.text+0xfb8): undefined reference to `sceGuFinish'
graphics.c:(.text+0xfc4): undefined reference to `sceGuSync'
graphics.c:(.text+0xfd4): undefined reference to `sceGuDisplay'
graphics.o: In function `clearScreen':
graphics.c:(.text+0x101c): undefined reference to `sceGuClearDepth'
graphics.c:(.text+0x1024): undefined reference to `sceGuClear'
graphics.c:(.text+0x102c): undefined reference to `sceGuFinish'
graphics.c:(.text+0x1040): undefined reference to `sceGuSync'
graphics.o: In function `blitAlphaImageToScreen':
graphics.c:(.text+0x10ec): undefined reference to `sceGuTexImage'
graphics.c:(.text+0x1110): undefined reference to `sceGuTexScale'
graphics.c:(.text+0x1120): undefined reference to `sceGuFinish'
graphics.c:(.text+0x1158): undefined reference to `sceGuSync'
graphics.c:(.text+0x118c): undefined reference to `sceGuGetMemory'
graphics.c:(.text+0x120c): undefined reference to `sceGuDrawArray'
graphics.c:(.text+0x1220): undefined reference to `sceGuFinish'
graphics.c:(.text+0x1258): undefined reference to `sceGuSync'
graphics.o: In function `blitImageToScreen':
graphics.c:(.text+0x1320): undefined reference to `sceGuCopyImage'
graphics.c:(.text+0x1328): undefined reference to `sceGuFinish'
graphics.c:(.text+0x135c): undefined reference to `sceGuSync'
collect2: ld returned 1 exit status
make: *** [mp3foto.elf] Error 1



Source:

Code: Select all

#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include <pspaudio.h>
#include <pspaudiolib.h>
#include <psppower.h>
#include "graphics.h"
#include "mp3player.h"

#define printf pspDebugScreenPrintf
#define MAX&#40;X, Y&#41; &#40;&#40;X&#41; > &#40;Y&#41; ? &#40;X&#41; &#58; &#40;Y&#41;&#41;

PSP_MODULE_INFO&#40;"Foto mp3 ding", 0, 1, 1&#41;;


// TWILIGHT ZONE! <do doo do doo>
/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
    sceKernelExitGame&#40;&#41;;
    return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
    int cbid;

    cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
    sceKernelRegisterExitCallback&#40;cbid&#41;;

    sceKernelSleepThreadCB&#40;&#41;;

    return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
    int thid = 0;

    thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
    if&#40;thid >= 0&#41;
    &#123;
        sceKernelStartThread&#40;thid, 0, 0&#41;;
    &#125;

    return thid;
&#125;
// END OF TWILIGHT ZONE! <do doo do do>
//


int main&#40;&#41;
&#123;
    scePowerSetClockFrequency&#40;333, 333, 166&#41;;
    pspDebugScreenInit&#40;&#41;;
    SetupCallbacks&#40;&#41;;
    pspAudioInit&#40;&#41;;
    SceCtrlData pad;
    int i;
    char buffer&#91;200&#93;;
    Image* ourImage;
    initGraphics&#40;&#41;;
    sprintf&#40;buffer, "psp.PNG"&#41;;
    ourImage = loadImage&#40;buffer&#41;;

    MP3_Init&#40;1&#41;;
    MP3_Load&#40;"intro.mp3"&#41;;
    MP3_Play&#40;&#41;;

    while&#40;1&#41;
    &#123;
        sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
        if&#40;pad.Buttons & PSP_CTRL_CROSS&#41;
        &#123;
            break;
        &#125;
        else if&#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;
        &#123;
            MP3_Pause&#40;&#41;;
            for&#40;i=0; i<10; i++&#41;
            &#123;
                sceDisplayWaitVblankStart&#40;&#41;;
            &#125;
        &#125;

        if &#40;MP3_EndOfStream&#40;&#41; == 1&#41;
        &#123;
            MP3_Stop&#40;&#41;;
        &#125;
    &#125;


    if &#40;!ourImage&#41;
    &#123;
        //Image load failed
        printf&#40;"Image load failed!\n"&#41;;
    &#125;
    else
    &#123;
        /* If the loadImage function */

        int x = 0;
        int y = 0;
        sceDisplayWaitVblankStart&#40;&#41;;

        while &#40;x < 480&#41;
        &#123;
            while &#40;y < 272&#41;
            &#123;

                blitAlphaImageToScreen&#40;0 ,0 ,480 , 272, ourImage, x, y&#41;;
                y += 272;
            &#125;

            x += 480;
            y = 0;
        &#125;

        flipScreen&#40;&#41;;
    &#125;

    MP3_Stop&#40;&#41;;
    MP3_FreeTune&#40;&#41;;
    sceKernelSleepThread&#40;&#41;;
    return 0;
&#125;
C/C++ Noob/Beginner
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

I didn't look at your code, but to fix the compiling errors add -lpng -lz and -lpspgu to the LIBS line in your Makefile.
JoRDozZzz
Posts: 9
Joined: Thu Apr 05, 2007 6:23 am
Contact:

Post by JoRDozZzz »

OK Thanks for your comment.
I've done that and now it's like this:

TARGET = mp3foto
OBJS = mp3player.o main.o graphics.o framebuffer.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =

LIBS = -lmad -lpspaudiolib -lpspaudio -lpsppower -lpng -lz -lpspgu
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = MP3 Player by Pspuser

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

// Greetzzzz
C/C++ Noob/Beginner
JoRDozZzz
Posts: 9
Joined: Thu Apr 05, 2007 6:23 am
Contact:

Post by JoRDozZzz »

Thanks, now i don't have ALL those errors. But i still have some errors. This is my error right now:

Code: Select all

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=
150  -L. -L/usr/local/pspdev/psp/sdk/lib   mp3player.o main.o graphics.o framebu
ffer.o -lmad -lpspaudiolib -lpspaudio -lpsppower -lpng -lz -lpspgu  -lpspdebug -
lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl
 -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o mp3foto.elf
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a&#40;pngrtran.o&#41;&#58; In
 function `png_build_gamma_table'&#58;
pngrtran.c&#58;&#40;.text+0x1258&#41;&#58; undefined reference to `pow'
pngrtran.c&#58;&#40;.text+0x1470&#41;&#58; undefined reference to `pow'
pngrtran.c&#58;&#40;.text+0x1518&#41;&#58; undefined reference to `pow'
pngrtran.c&#58;&#40;.text+0x1630&#41;&#58; undefined reference to `pow'
pngrtran.c&#58;&#40;.text+0x170c&#41;&#58; undefined reference to `pow'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a&#40;pngrtran.o&#41;&#58;png
rtran.c&#58;&#40;.text+0x17f8&#41;&#58; more undefined references to `pow' follow
collect2&#58; ld returned 1 exit status
make&#58; *** &#91;mp3foto.elf&#93; Error 1
Can you help me, my source is in the first post :)
Thank you very very very much for help. If there are other things for PSP then coding i'll help you all too :) but in coding i'm a beginner/noob ..

Grtzzzz
C/C++ Noob/Beginner
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Add -lm to the end of the LIBS line.
JoRDozZzz
Posts: 9
Joined: Thu Apr 05, 2007 6:23 am
Contact:

Post by JoRDozZzz »

Insert_witty_name your the best of the world. compiling is done. i've started the homebrew, but displaying the image and listening to music didn't work, so there is something wrong in de main.c source. But i'm going to ask friends to help me with the source, but compiling is now available to say so ;)

thanks you very very much for help. PS2Dev.org Forums are the best forums to ask things about coding and developing i see. on other forums i still have no reactions :(

when my homebrew is completed i'll post it here with thanks to Insert_witty_name.

// greetzzzz
C/C++ Noob/Beginner
JoRDozZzz
Posts: 9
Joined: Thu Apr 05, 2007 6:23 am
Contact:

Post by JoRDozZzz »

It's done, sorry for all those double posts in this topic :( but i've to say that i ve a musicsong AND an image in my homebrew. Thats what i want :D Thanks again :)

Greetzz
C/C++ Noob/Beginner
Post Reply