Need some help configuring a development environment.

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

Moderators: cheriff, TyRaNiD

Post Reply
chocoflyer
Posts: 5
Joined: Thu Mar 15, 2007 7:06 am

Need some help configuring a development environment.

Post by chocoflyer »

Hi, I'm new to the C programming language (I've spent time studying the specification) and PSP development, but I'd like to give it a shot. I tried to work with Lua, but I found C to be easier (probably because I'm used to C-style languages) so I thought to try out "real" PSP programming.

My IDE of choice is Visual C++ Express. I looked at the thread about using VC++ with the PSP toolchain, but I thought I'd make a new thread since I'm starting for scratch essentially and have very little experience with VC++ and cygwin.

I'm running on Windows XP, so I installed cygwin with just the default settings (looks like it comes with bin, bash, gawk, bzip2, and maybe a few other standard utilities; is that sufficient?). I've got VC++ Express installed as well, but that's where I'm at. I have absolutely no experience with making PRXs or EBOOTs, but if I can get "hello world" running, that would be great, and from there I think I'll be fine (to a certain extent, of course :P).

I guess what I'm asking is:
• Is using the default installation settings for cygwin fine, or did I need to install something else?
• Will Visual C++ Express work, or do I need the fancier Visual C++ 2005/Visual Studio 2005?
• After that, will the tutorial on how to configure VC++ work for me?
• If not, what is the simplest alternative? I do not require any debugging utilities; I usually just use printf statements at certain points in the code, and I hope that will suffice.

Thanks in advance.
Bytrix
Posts: 72
Joined: Wed Sep 14, 2005 7:26 pm
Location: England

Post by Bytrix »

Those tutorials didn't work for me with the latest cygwin/toolchain/Visual C++ Express. Here's how I got mine to compile though so should work for you:

Assuming cygwin is installed in C:\cygwin create the following two files:

c:\cygwin\vs-pspdev.bat

Code: Select all

@echo off
set path=%path%;c:/cygwin/usr/local/pspdev/bin
set PSPSDK=c:/cygwin/usr/local/pspdev
c:\cygwin\bin\bash -c 'export VS_PATH=`pwd`; /bin/bash --login -c "cd $VS_PATH; /vs-pspdev.sh %1 %2 %3 %4 %5"'
c:\cygwin\vs-pspdev.sh

Code: Select all

#!/bin/bash
make 2>&1 $@ | sed -e 's/\([^:]*\):\([0-9][0-9]*\)\(.*\)/\1 (\2) \3/'
Then in Visual Studio start a new Makefile Project and enter c:\cygwin\vs-pspdev.bat as your build command line and c:\cygwin\vs-pspdev.bat clean as your clean commands. Then set the Include Search Path to C:\cygwin\usr\local\pspdev\include;C:\cygwin\usr\local\pspdev\psp\include;C:\cygwin\usr\local\pspdev\psp\sdk\include

I haven't yet looked into any of the methods which can auto-generate a make file so I would copy one of the makefiles from the sdk samples and change it as you need to.

That's it for compiling.. I do all my testing and debugging using psplinkusb and I don't think it can be linked in with Visual C++.
Last edited by Bytrix on Thu Mar 15, 2007 6:16 pm, edited 1 time in total.
sturatt
Posts: 46
Joined: Thu Jul 13, 2006 4:21 pm

Post by sturatt »

Bytrix

I tried to setup my Visual c++ like you said, but when i try to build the project it says device not ready?

1>------ Build started: Project: TestProj, Configuration: Debug Win32 ------
1>Performing Makefile project actions
1>The device is not ready.
1>Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'.
1>Build log was saved at "file://c:\cygwin\home\Administrator\projects\TestProj\Debug\BuildLog.htm"
1>TestProj - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Edit:

nevermind, in your vs-pspdev.bat you had an e:\cygwin\... instead of c:\cygwin so it was trying to do my dvd drive.
Bytrix
Posts: 72
Joined: Wed Sep 14, 2005 7:26 pm
Location: England

Post by Bytrix »

Yeah sorry I have my cygwin on drive e: but I tried to change all the references to c: as that's the most common place for it.
chocoflyer
Posts: 5
Joined: Thu Mar 15, 2007 7:06 am

Post by chocoflyer »

Thank you very much for the tutorial. I just began trying to compile my first PSP program (installing the toolchain took so long!) so I copied a simple Hello World tutorial I found.

I am sure that I followed your instructions exactly, but I am not able to compile my program.

At first, the error log said:

Code: Select all

------ Build started: Project: PSP Hello World, Configuration: Debug Win32 ------
Performing Makefile project actions
/bin/bash: line 0: cd: /cygdrive/c/Documents: No such file or directory
sed: -e expression #1, char 46: unknown option to `s'
Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'.
Thinking that this was because of a space in "Documents and Settings", I added quotes to line 4 of the vs-pspdev batch file:
c:\cygwin\bin\bash -c 'export VS_PATH=`pwd`; /bin/bash --login -c "cd \"$VS_PATH\"; /vs-pspdev.sh %1 %2 %3 %4 %5"'
Now, the error log just says:

Code: Select all

------ Build started: Project: PSP Hello World, Configuration: Debug Win32 ------
Performing Makefile project actions
sed: -e expression #1, char 46: unknown option to `s'
Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'.
I have also tried deleting a newline from the end of the vs-pspdev.bat and vs-pspdev.sh files, but that only resulted in more problems, so I replaced the newline (and perhaps a linefeed; IIRC Notepad does that) if that matters.

Sorry about the problems, but I don't have any clue about what to do. >_<
Bytrix
Posts: 72
Joined: Wed Sep 14, 2005 7:26 pm
Location: England

Post by Bytrix »

Try starting a new project or moving your project to a path with no spaces and attempting to compile. Then you'll know if it's because of the space in the path. eg: c:\projects\myproject
chocoflyer
Posts: 5
Joined: Thu Mar 15, 2007 7:06 am

Post by chocoflyer »

No, that doesn't seem to be the issue unfortunately.
I am nearly sure that the problem exists with passing arguments to sed. After the regex, if I add "foo", VC++ shows an error saying that no file or folder called "foo" exists. Thus, I am guessing that the problem I am having is a result of not passing a filename argument to sed.

It looks like arguments are passed to bash when /vs-pspdev.sh is called:
c:\cygwin\bin\bash -c 'export VS_PATH=`pwd`; /bin/bash --login -c "cd \"$VS_PATH\"; /vs-pspdev.sh %1 %2 %3 %4 %5"'
but I am no master of scripts so that is only my guess.

Nevertheless, when we get to

Code: Select all

#!/bin/bash
make 2>&1 $@ | sed -e 's/\&#40;&#91;^&#58;&#93;*\&#41;&#58;\&#40;&#91;0-9&#93;&#91;0-9&#93;*\&#41;\&#40;.*\&#41;/\1 &#40;\2&#41; \3/'
I do not think that sed is getting passed any arguments since if I append anything to that last line, the script works "fine" in that it does not choke on the regex. But if I leave it as is, I think that it is looking for another argument but can't find one.

Would anyone happen to have an idea for a solution?
Thank you.
Bytrix
Posts: 72
Joined: Wed Sep 14, 2005 7:26 pm
Location: England

Post by Bytrix »

Sorry, no idea. Works perfectly for me. Is your cygwin install completely up to date? Perhaps it could be a problem with an old sed ($ sed --version, the one I have in a cygwin install from the weekend is 4.1.5).

It could maybe be a problem with your makefile, causing make to output some odd errors that sed can't parse.
chocoflyer
Posts: 5
Joined: Thu Mar 15, 2007 7:06 am

Post by chocoflyer »

Yes, I have the same sed version.

I think that my problem is with the makefile. I went into the SDK samples and copied main.c from the basic controller sample, and took the makefile as well.

The makefile looks like

Code: Select all

TARGET = controller_basic
OBJS = main.o

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

LIBDIR =
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Basic controller sample

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
I created a new project and solution in VC++, threw main.c and Makefile into the innermost directory (which contains the VC++ project configuration file), added main.c to the project, and tried to build it. I have a feeling that this is not what I should be doing with the makefile.

Where should I place the makefile and what should I do with it?
Bytrix
Posts: 72
Joined: Wed Sep 14, 2005 7:26 pm
Location: England

Post by Bytrix »

try entering the directory and running a make from cygwin/cmd. See if it compiles correctly, if it does then it's probably not a problem with the makefile. If it is the problem you should be able to see what's wrong.
chocoflyer
Posts: 5
Joined: Thu Mar 15, 2007 7:06 am

Post by chocoflyer »

I resolved the problem with compiling the code by adding the bin directories of the PSP SDK to my PATH environment variable.

To get it to work with Visual C++, I edited vs-pspdev.bat to

Code: Select all

del /F /Q *.o *.elf *.PBP *.SFO
make
and now everything is good.
Thanks for the help.
Post Reply