Undeclared functions when compiling...
- Josh1billion
- Posts: 32
- Joined: Tue Jul 12, 2005 8:45 am
- Location: Wisconsin, USA
- Contact:
Undeclared functions when compiling...
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.
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.
Josh1billion - PHP, C++, PSP programmer.
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
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!
- Josh1billion
- Posts: 32
- Joined: Tue Jul 12, 2005 8:45 am
- Location: Wisconsin, USA
- Contact:
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?
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.
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.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?
Lego of my Ago!
- Josh1billion
- Posts: 32
- Joined: Tue Jul 12, 2005 8:45 am
- Location: Wisconsin, USA
- Contact:
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:
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).
However, I'm still getting some undefined sce functions here, as you can see:
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.
- Josh1billion
- Posts: 32
- Joined: Tue Jul 12, 2005 8:45 am
- Location: Wisconsin, USA
- Contact:
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.
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.
- Josh1billion
- Posts: 32
- Joined: Tue Jul 12, 2005 8:45 am
- Location: Wisconsin, USA
- Contact:
Having trouble getting cos(), sin() and sqrt() usable.
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.Agoln wrote:make sure in your make file you have -lm for an additional library.
Josh1billion - PHP, C++, PSP programmer.
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.
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.
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.Agoln wrote:make sure in your make file you have -lm for an additional library.
- Josh1billion
- Posts: 32
- Joined: Tue Jul 12, 2005 8:45 am
- Location: Wisconsin, USA
- Contact:
I have added "LIBS: -lm" to my make file. Now I'm getting this error.. is it due to an outdated toolchain or what?Agoln wrote: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.Josh1billion wrote:\What library do I use for cos(), sin(), and sqrt()?
Josh1billion - PHP, C++, PSP programmer.
- Josh1billion
- Posts: 32
- Joined: Tue Jul 12, 2005 8:45 am
- Location: Wisconsin, USA
- Contact:
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 = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
LIBS = -lm
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Breakout v0.01
include $(PSPSDK)/lib/build.mak
Josh1billion - PHP, C++, PSP programmer.
- Josh1billion
- Posts: 32
- Joined: Tue Jul 12, 2005 8:45 am
- Location: Wisconsin, USA
- Contact:
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
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 addto your main C file.Code: Select all
int __errno = 0;
Josh1billion - PHP, C++, PSP programmer.