Lesson 01 Setting up the Development Environment
第一课 安装开发环境
How to get the tool chain and PSP SDK up and running with CYGWIN on a windows machine. The complete newbie's guide.
如何得到工具链和PSP SDK开运发包并且在window环境上运行。一个完整的新手手册
This is the first installment in a series of tutorials focussed on getting a novice programmer well
on his way to developing his own home brew applications for the Sony Playstation Portable (PSP).
这是对于那些想要自己开发PSP程序的一系列教程的第一步。
If you are reading this, congratulations, you have hurdled one of the biggest obstacles for a programmer.
如果你正在读这篇文章,那么祝贺你,对于一个程序员你已经翻过了一个最大的障碍。
Likely the most difficult thing about programming is getting started. Well, by starting to read this tutorial, you are well on your way.
可能写程序的更困难的事情正在开始。好,在开始读这篇教程的开始,你正在走你自己的路。
The first step to creating your own program is getting your environment set up.
创建你自己的程序的第一步是安装你的开发环境。
This environment is how you will convert the source code you write into a
compiled file formatted for execution on you PSP.
这个开发环境是能够将你写的源代码转成一个编译过的文件供PSP运行。
We will be setting up two important tools on our system.
我们将在你的系统上安装两个重要的工具。
The first of these tools is called CYGWIN. It is basically a Linux emulator for windows.
第一个工具是‘CYGWIN’。他基本上是一个windows上的linux虚拟机。
It will create a simulated Linux environment on your computer so that you can run native Linux applications.
他将在你的电脑里建立一个虚拟Linux环境,来让你能够运行Linux程序。
This may sound intimidating, but don't worry, it's very simple to use.
这听起来很悬,但是没关系,他用起来很容易。
The second thing you'll need is the toolchain. This is the key to programming for the PSP.
第二件事我们需要工具链。这是开发PSP程序的关键。
It will set up everything you need, from header files, to libraries, to the compiler itself, to the sample programs.
他将安装你需要的所有东西,从头文件,到库文件,到编译器,到简单的程序。
Once you have this installed, you will be nearly ready to create your first program.
但你安装了这个,你就离准备创建第一个程序不远了。
Now for the part we've all been waiting for: the installation.
这一部分我们就等着安装了。
The first step is to install CYGWIN. You can download the install file from the CYGWIN website here.
第一步是安装CYGWIN。你可以从CYGWIN网站下在这个安装文件。
After it has finished downloading, open up the executable.
完成下载后,打开可执行文件。
You will see a splash screen; click next. Now you will be asked what you want to do.
你将会看见一个弹出窗口;点下一步。现在你将会被询问“你想做什么”。
Select the default option of "Install from Internet," and hit the next button.
选择默认选项“INSTALL FROM INTERNET”,并按“下一步”按钮。
Now you will be prompted where you want to install CYGWIN.
现在你将被提示你想在哪安装这个软件。
Change the install directory to "C:/cygwin" if it is not set as such already (where C: is your local hard drive).
把安装目录改为 "C:/cygwin" ,如果他默认的不是这个目录。
Leave the other options set to their defaults and hit next.
剩下的选项都用它默认的设置并按Next按钮。
Now you will be asked where you want to save the installation files.
现在你将会被问你想把安装文件存在哪。
What you select here doesn't really matter, but I suggest putting them someplacewhere you will be able to find them and delete them after the installation is complete.
你选择什么都是无所谓的。但是我建议你把他们放在你安装后也能很方便找到和删除的地方。
Once you have selected a suitable location, click next.
当你选择好合适的地方时,按next键。
The next screen will ask about your network settings, if you don't use a proxy (or don't know what a proxy is), just click next on this screen.
下一个界面将会让你设置网络设置,如果你不用代理,只要按next键就行了。
If it doesn't work, go back and try letting it use Internet Explorer's settings.
如果不行,那就返回网络设置哪一步,并试试用IE的设置来设置。
Now you should be presented with a list of servers to download the installation files from.
现在你将看到一个可以当安装文件的服务器的列表。
Any one of these will do, so select one, and then click on next.
他们中的任何一个都是可以下的,所以选择一个并按next键。
Now it will download the package list, this could take a few minutes, depending on your connection speed.
现在他将会下在这个包裹表,这个需要花费几分钟,时间的长短是要依你的网速定的。
Once it is done, scroll down to "devel" and click on where it says "default" so that it becomes "install."
在他完成后会有一个安装列表,在列表中找到"devel"并点击"default"单词使他变成"install"。
Then scroll down to "web," click the "+" next to it, scroll down and set "wget" to "install."
下卷列表找到"web"项,点击"+"项展开,下卷找到"wget"项,并设置为"install"。
When you are finished, click next. CYGWIN will now download and install the selected packages.
当我们完成时按next。CYGWIN将下载并安装选择的包裹。
This will quite possibly take a while, so go watch a TV show or do some web surfing while you wait.
这将会花一段时间,所以去看看电视上上网吧。
After the install has finished, you are ready to install the toolchain.
安装完成后,你要准备安装toolchain。
Now, we are going to install the toolchain into our CYGWIN environment.
现在我们来安装toolchain到我们的CYGWIN环境。
To set up our environment, we will need to run CYGWIN first.
安装我们的环境,我们首先需要运行CYGWIN。
So, either from the start menu, or from "C:/cygwin," run a CYGWIN bash shell (cygwin.bat).This will open up a command line.
所以运行CYGWIN程序。这将会打开一个命令行。
Once you see "yourusername@yourcomputername ~" you may close the window; your environment has successfully set up.
当你看见"yourusername@yourcomputername ~"时你可以关闭WINDOWS;你的环境已经安装成功。
To download the latest toolchain, go here.
下载最后的toolchain,找到他。
It should be at the very bottom of the page.
他很可能在页面的最低下。
At the time of writing, the latest toolchain file is dated 20051202. Download this file.
最后一个toolchain文件是20051202写的,下载这个文件。
When it is finished, use Winrar to extract the file contents to "C:/cygwin/home/user," where "user" is your username.
完成时,用winrar去加压这个文件内容到"C:/cygwin/home/user,","user" 是你的用户名。
Now it's time to actually install, so open up your CYGWIN bash shell again.
现在该真正开始安装了,所以再次打开CYGWIN程序。
Now it's time to introduce you to the Linux command line.
现在开始介绍Linux命令行。
You should see a "$" at the beginning of the line.
你应该在行首看到"$"字符。
This means that you are running the shell in user mode, as opposed to root (or admin) mode.
这表示你正在用户模式下运行,刚好和root模式相反。
This is of little importance in CYGWIN, but if you ever use an actual Linux command line, this is an important thing to notice.
这看起来好像并不是很重要,但是如果你以前用过真正的Linux命令行,这便是一件很值得注意的事了。
We now need to change directories to where we extracted the toolchain.
我们现在需要改变解压toolchain后的目录。
Type "ls" in the bash shell; this stands for list.
在命令窗口里输入"ls";这会列出列表。
It will give us an output of all of the files in our current directory (this is similar to "dir" in a Windows commandline).
他将列出当前目录下的所有文件。这很像在windows窗口下执行"dir"。
Now you should see a folder named "psptoolchain," this is where we want to go.
现在我们会看到一个"psptoolchain"文件夹,这就是我们要找的。
So type "cd psptoolchain" and hit enter.
输入"cd psptoolchain"并按回车。
CD stands for change directory, and it will (obviously) switch the current operating directory).
这个命令将会让你切换到另外一个指定的目录。
Now do a quick "ls" again, and you will see the files in this folder.
现在再做一次"ls"操作,你会看到这个文件夹中的内容。
The one that we want is "toolchain.sh" To execute this file, type "./toolchain.sh" and hit enter.
我们来执行"toolchain.sh"这个程序。
In Linux, "." means the current directory, and ".." means the parent directory, so this command means to execute "toolchain.sh" which is in the current directory.
在Linux中"."表示当前文件夹,".."表示父目录,所以这条指令表示执行当前文件夹中的"toolchain.sh"
The toolchain.sh script will do the rest, for you. This can take up to several hours, depending on the specifications of your machine.
toolchain.sh脚本的执行对于你来讲是一种休息,这将花费几个小时的时间。
For a frame of reference, my 3.0GHz Pentium 4 took about three hours to run the entire script, so be patient.
理论上讲,我的Pentium4 3.0G的处理器花了3个小时,所以清耐心
Some people have reported it taking over 24 hours, but this is a little overkill.
有些人曾经说他花了超过24小时,但是这是很极端的情况。
Go take a break and come back in a few hours.
休息一下,几小时后再回来。
Or better yet,let it go while you sleep and when you wake up in the morning you should be ready for the next step.
或者让他在你睡觉的时候执行,当你早上醒来时,你已经可以做下一步了。
Now for the last step. We have to tell CYGWIN where it can find the PSPSDK (which the toolchain just installed) and the toolchain.
现在到最后一步了。我们比告诉CYGWIN他可以到哪里PSPSDK和toolchain。
To do this, we need to change "C:/cygwin/cygwin.bat" to include the paths.
要做这件事,我们需要改变"C:/cygwin/cygwin.bat"的包含路径。
So, close CYGWIN, and navigate Explorer to "C:/cygwin" and right click on cygwin.bat.
所以关闭CYGWIN,并进入"C:/cygwin"文件夹,在cygwin.bat文件上点击右键。
Select "Edit" and a Notepad window should appear with the following:
选择"Edit",这时Notepad将会显示如下:
@echo off
C:
chdir C:/cygwin/bin
bash --login -i
Change this to:
@echo off
C:
chdir C:/cygwin/bin
set path=%path%;C:/cygwin/usr/local/pspdev/bin
set PSPSDK=C:/cygwin/usr/local/pspdev
bash --login -i
Now you're ready to go! If you have source code that you want to compile, go into that directory with "cd" and type "make" and it should give you an eboot.