Undeclared functions when compiling...

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Josh1billion
Posts: 32
Joined: Tue Jul 12, 2005 8:45 am
Location: Wisconsin, USA
Contact:

Undeclared functions when compiling...

Post by Josh1billion »

Up until today, I've been using the PS2Dev win32 environment, but now I'm trying to switch to the PSP toolchain.

I have compiled the Hello World and sample SDK sources just fine up to this point, using the PSPDev sdk and the pre-compiled PSP toolchain.

Now I'm trying to compile a Breakout game I've been working on, which I've based off the source code of a BlackJack game (which is also intended for the PS2Dev win32 environment).

I've fixed some errors already when trying to make the switch, but here are some errors I haven't been able to fix yet. I think I need to include some additional PSPSDK include files to fix these errors, so please let me know which ones if I'm right about that.

Image
Josh1billion - PHP, C++, PSP programmer.
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Post by Agoln »

for the errors about the __encrypt table and module_info, you need to make sure you have the PSP_MODULE_INFO("something", 0, 1, 1);

For the SceCtrl* errors, make sure you include <pspctrl.h>

And for the allegrex, it sounds like someone compiled something with -marc=r4000 instead of allegrex
Lego of my Ago!
User avatar
Josh1billion
Posts: 32
Joined: Tue Jul 12, 2005 8:45 am
Location: Wisconsin, USA
Contact:

Post by Josh1billion »

Wow, it sounds like you really know your stuff. :) Thanks much. I will try fixing it with the solutions you suggested soon. First though,

what does "PSP_MODULE_INFO("something", 0, 1, 1); " do (and do I just have it at the start of my main() function, I'm assuming)? And what does the first parameter represent?
Josh1billion - PHP, C++, PSP programmer.
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Post by Agoln »

Josh1billion wrote:what does "PSP_MODULE_INFO("something", 0, 1, 1); " do (and do I just have it at the start of my main() function, I'm assuming)? And what does the first parameter represent?
You should put it at the beginning of your program, after your #include's and #define's. It is pretty much just a #define itself that tells the startup files what to do. The "something" is a description of your program, usually it's name. the 2nd varible is what type of mode it should be put in. There is THREAD_ATTR_USER and THREAD_ATTR_VFPU, and 0 is kernel mode. the 3rd varible is major version of your program and the 4th varible is minor version.
Lego of my Ago!
User avatar
Josh1billion
Posts: 32
Joined: Tue Jul 12, 2005 8:45 am
Location: Wisconsin, USA
Contact:

Post by Josh1billion »

Alright, I have added the module macro and I have included pspctrl.h.

However, I'm still getting some undefined sce functions here, as you can see:

Image

I took a look at my pspctrl.h file, and it seems rather empty (it only had a few function prototypes total, if I remember correctly, and the functions that the compiler is complaining about were nowhere to be found).
Josh1billion - PHP, C++, PSP programmer.
User avatar
cwbowron
Posts: 76
Joined: Fri May 06, 2005 4:22 am
Location: East Lansing, MI
Contact:

Post by cwbowron »

Some function names have been changed because I believe they were not the real function names

sceCtrlRead => sceCtrlPeekBufferPositive
sceCtrlSetAnalogMode => sceCtrlSetSamplingMode
sceCtrlInit => sceCtrlSetSamplingCycle

you are probably also going to have to use -lpspctrl when linking.
User avatar
Josh1billion
Posts: 32
Joined: Tue Jul 12, 2005 8:45 am
Location: Wisconsin, USA
Contact:

Post by Josh1billion »

Thanks man! :) It's working perfectly now (note: I didn't need to add -lpspctrl to the linker parameters either, just so you know).

Now another question, I might as well ask here rather than start a new topic, can I use standard C include files like Math.h in my PSP game now? Reason being I need to use cos(), sin(), and maybe some others, in my Breakout game.
Josh1billion - PHP, C++, PSP programmer.
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Post by Agoln »

make sure in your make file you have -lm for an additional library.
Lego of my Ago!
User avatar
Josh1billion
Posts: 32
Joined: Tue Jul 12, 2005 8:45 am
Location: Wisconsin, USA
Contact:

Post by Josh1billion »

Having trouble getting cos(), sin() and sqrt() usable.
Agoln wrote:make sure in your make file you have -lm for an additional library.
What library do I use for cos(), sin(), and sqrt()? Also which include file do I use for those functions? MSDN says Math.h, but is it different for the PSPSDK? Because I've included Math.h and I'm getting undeclared errors for each of those three functions.
Josh1billion - PHP, C++, PSP programmer.
laichung
Posts: 123
Joined: Fri May 06, 2005 2:02 pm

Post by laichung »

including Math.h , header file is not enough. You need to link it library when you compile your program.

Please note that , PSPSDK / toolchain will compile your program without link to library first (that mean it make .c to object .o) , and then link all object and library together to make elf.

So, when any "undeclared errors" come out , the first thing you must do is , check msg from the make process, the makefile and build.mak (from SDK) , make sure you have include the right library.

The other matter is , you cant mix C and CPP file together in your development (this only my experience), because they use different compiler (psp-gcc and psp-g++). I also found that you cant link the CPP object and those CPP library (example , list) by psp-gcc , may be this is because I dont know the command. Since I use CPP for most of the time , so I change the build.mak , make psp-gcc to psp-g++.

finally , if you found any undeclared errors about libc.a and somethings like _read not declare, although mrbrown (say thank you to him) said that is due to usage of outdate toolchain , but I cant solve this error with updating my toolchain. But I know those functions is useless (since they are something like OPEN , READ, which is useless function in psp development). So the way I solve this problem is , declare the undeclared varible in the main program. (example add int _read)

Hope this can help everyone.

p.s. MSDN? You better learn more about GCC and command when you go into PSP development. MSDN is only for MS VS only.

Josh1billion wrote:Having trouble getting cos(), sin() and sqrt() usable.
Agoln wrote:make sure in your make file you have -lm for an additional library.
What library do I use for cos(), sin(), and sqrt()? Also which include file do I use for those functions? MSDN says Math.h, but is it different for the PSPSDK? Because I've included Math.h and I'm getting undeclared errors for each of those three functions.
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Post by Agoln »

Josh1billion wrote:\What library do I use for cos(), sin(), and sqrt()?
You use the math library! It is linked by adding a -lm. Open your make file and make sure under libs you have included the -lm in it.
Lego of my Ago!
User avatar
Josh1billion
Posts: 32
Joined: Tue Jul 12, 2005 8:45 am
Location: Wisconsin, USA
Contact:

Post by Josh1billion »

Agoln wrote:
Josh1billion wrote:\What library do I use for cos(), sin(), and sqrt()?
You use the math library! It is linked by adding a -lm. Open your make file and make sure under libs you have included the -lm in it.
I have added "LIBS: -lm" to my make file. Now I'm getting this error.. is it due to an outdated toolchain or what?

Image
Josh1billion - PHP, C++, PSP programmer.
User avatar
Josh1billion
Posts: 32
Joined: Tue Jul 12, 2005 8:45 am
Location: Wisconsin, USA
Contact:

Post by Josh1billion »

Here's my Makefile of my project if it helps:

Code: Select all

TARGET = breakout
OBJS = SOLID.o Controller.o Graphics.o

INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR = 
LDFLAGS =
LIBS = -lm

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Breakout v0.01

include $&#40;PSPSDK&#41;/lib/build.mak
Josh1billion - PHP, C++, PSP programmer.
User avatar
Josh1billion
Posts: 32
Joined: Tue Jul 12, 2005 8:45 am
Location: Wisconsin, USA
Contact:

Post by Josh1billion »

Sorry for the triple post, but aha! Fixed! Thanks much to the phpbb Search function.. lol

Here's the solution, as Jim explained here: http://forums.ps2dev.org/viewtopic.php? ... ight=errno
Jim wrote:Until the sdk is fixed for __errno just add

Code: Select all

int __errno = 0;
to your main C file.
Josh1billion - PHP, C++, PSP programmer.
Post Reply