Compile problem with graphics.h - understanding problem

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

Moderators: cheriff, TyRaNiD

Post Reply
HolgiB
Posts: 6
Joined: Fri Jan 12, 2007 12:19 am

Compile problem with graphics.h - understanding problem

Post by HolgiB »

Hi,

this are my first steps in PSP development. I already coded some small programs in C, but this was 10 years ago. So I am a noob. Somebody already pointed me to my "text problem" to freetype. I also found "flib" and this seems to be an easy way to get the job done for me. The demo compile without any trouble. Unfortunately I have a problem compiling my own program together with it and I really dont know why. Analyzed the Makefile for an hour, tried a lot but I still get this:

Code: Select all

psp-gcc -I/include -I. -I/usr/local/pspdev/psp/sdk/include -G0 -Wall -O2 -I/usr/local/pspdev/psp/include/SDL -Dmain=SDL_main  -L. -L/usr/local/pspdev/psp/sdk/lib   sdlext.o flib.o graphics.o framebuffer.o sdlsidplay.o -lpsppower -lpspgu -lpng -lz -lm -lfreetype -lsidplay  -lstdc++  -L/usr/local/pspdev/psp/lib -lSDLmain -lSDL -lm -L/usr/local/pspdev/psp/sdk/lib -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel  -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o sdlsidplay.elf
sdlsidplay.o: In function `Intro()':
sdlsidplay.cpp:(.text+0x70): undefined reference to `initGraphics()'
sdlsidplay.cpp:(.text+0x7c): undefined reference to `load_font(char*)'
sdlsidplay.cpp:(.text+0x8c): undefined reference to `clearScreen(unsigned int)'
sdlsidplay.cpp:(.text+0x98): undefined reference to `set_font_color(unsigned int)'
sdlsidplay.cpp:(.text+0xa0): undefined reference to `set_font_size(int)'
sdlsidplay.cpp:(.text+0xb4): undefined reference to `text_to_screen(char*, int, int)'
sdlsidplay.cpp:(.text+0xc4): undefined reference to `flipScreen()'
sdlsidplay.o: In function `SDL_main':
sdlsidplay.cpp:(.text+0x85c): undefined reference to `unload_font()'
collect2: ld returned 1 exit status
make: *** [sdlsidplay.elf] Error 1
And this is my Makefile:

Code: Select all

TARGET = sdlsidplay
OBJS =  sdlext.o flib.o graphics.o framebuffer.o sdlsidplay.o

INCDIR =  $(PSPDIR)/include 
CFLAGS = -G0 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =
LIBS= -lpsppower -lpspgu -lpng -lz -lm -lfreetype

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = sdlsidplay
PSP_EBOOT_ICON = sidplay.png

PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS +=  -lsidplay  -lstdc++  $(shell $(PSPBIN)/sdl-config --libs) 

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

strip: all
	cp $(TARGET).elf sdlsid.elf
	psp-strip  sdlsid.elf
Hmm, is the order of OBJS important or not? Changed it but not success. Same error.

The includes in my main program (sdlsiplay.cpp):

Code: Select all

#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <sidplay/sidtune.h>
#include <sidplay/emucfg.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <string.h>
#include <dirent.h>
#include <pspdisplay.h>

#include "graphics.h"
#include "flib.h"
#include "sdlext.h"
And the code which are causing this problem. When I remove it, everything is fine. My program works, but I am just starting to build something like a user interface and need flib and all what I can get from graphics.h.

Code: Select all

int
Intro&#40;&#41;
&#123;
	initGraphics&#40;&#41;; 

	if&#40;!load_font&#40;"times.ttf"&#41;&#41;	// load "times new roman" font
	&#123;
		printf &#40;"Could not load font file.\n"&#41;;
		return 1;
	&#125;

	clearScreen&#40;0&#41;;

	set_font_color&#40;0xff00ffff&#41;;	// green
	set_font_size&#40;24&#41;;		// 16 point
	text_to_screen&#40;"PSP-Sidplayer", 0, 0&#41;;

	sceDisplayWaitVblankStart&#40;&#41;;
	flipScreen&#40;&#41;;
	return&#40;0&#41;;
&#125;
I really dont have an idea. I think its an understanding problem because the flib demo compiles and works without any problems. In this program, I have to use also SDL. The audio routines of the original author are using SDL. This part works perfectly.

HELP :-)

--Holger
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Wrap the graphics.h include in an extern C statement.

Code: Select all

extern "C" &#123;
#include "graphics.h"
&#125;
You may have to do this for the flib/sdlext include also.
HolgiB
Posts: 6
Joined: Fri Jan 12, 2007 12:19 am

Post by HolgiB »

Thank you very much. That was the solution of my problem.

Didnt had a clue what could be the problem. Think this solution I neverever had found on my own :-) .

--Holger
Post Reply