一,准备目录
假设我们准备将整个FreePascal环境安装到D盘的fpc目录下,那么我们需要创建以下几个目录:
d:\fpc_svn\bin
d:\laz_svn
二,准备环境
1,安装SVN客户端TortoiseSVN和中文支持包,下载地址:http://tortoisesvn.net/downloads
2,使用SVN客户端CheckOut以下数据:
SVN URL:http://svn.freepascal.org/svn/fpcbuild/trunk/install/binw32
目录:d:\fpc_svn\bin\i386-win32
SVN URL:http://svn.freepascal.org/svn/fpcbuild/trunk/install/binw64
目录:d:\fpc_svn\bin\x86_64-win64
SVN URL:http://svn.freepascal.org/svn/fpc/trunk
目录:d:\fpc_svn
SVN URL:http://svn.freepascal.org/svn/lazarus/trunk
目录:d:\laz_svn
三,编译FPC
1,下载一个编译器并解压至d:\fpc_svn\bin目录,
ftp://ftp.freepascal.org/pub/fpc/dist/2.6.2/bootstrap/i386-win32-ppc386.zip
ftp://ftp.freepascal.org/pub/fpc/dist/2.6.2/bootstrap/x86_64-win64-ppcx64.zip
2,编写一个批处理,用以编译FPC:
@echo on
set myfpc=d:\fpc_svn
set mybin=d:\fpc_svn\bin
set PATH=%mybin%\i386-win32;%PATH%
cd %myfpc%
rd /s /q %myfpc%\examples
make clean all install INSTALL_PREFIX=%myfpc% PP=%mybin%\ppc386.exe DATA2INC=%myfpc%\utils\data2inc.exe
pause
//-----------------------------------------------------------------------------------------------------
@echo on
set myfpc=d:\fpc_svn
set mybin=d:\fpc_svn\bin
set PATH=%mybin%\x86_64-win64;%PATH%
cd %myfpc%
rd /s /q %myfpc%\examples
make clean all install INSTALL_PREFIX=%myfpc% PP=%mybin%\ppcx64.exe DATA2INC=%myfpc%\utils\data2inc.exe
pause
3,将上面的命令保存为一个makefpcwin32.bat文件并运行,得到FPC的编译环境。
打开cmd窗口:
cd d:\fpc_svn
makefpcwin32 //makefpcwin64
4,在命令行中运行以下命令,生成fpc.cfg文件:
cd /d d:\fpc_svn\bin\i386-win32 //cd /d d:\fpc_svn\bin\x86_64-win64
fpcmkcfg -d basepath=d:\fpc_svn -o .\fpc.cfg
四,编译Lazarus
完成第三步后已经有一个FPC的编译环境了,我们还需要编译一个IDE环境:Lazarus。
1,编写一个批处理,用以编译Lazarus
@echo on
set myfpc=d:\fpc_svn
set mybin=d:\fpc_svn\bin
set PATH=%mybin%\i386-win32;%PATH%
cd d:\laz_svn
make clean all OPT="-glw2"
pause
//--------------------------------------------------------------------------------------------------------
set myfpc=d:\fpc_svn
set mybin=d:\fpc_svn\bin
set PATH=%mybin%\x86_64-win64;%PATH%
cd d:\laz_svn
make clean all OPT="-glw2"
pause
2,将上面的命令保存为makelazwin32.bat文件并运行,得到FPC的IDE环境Lazarus。
打开cmd窗口:
cd d:\fpc_svn
makelazwin32 //makelazwin64
3,运行d:\laz_svn\lazarus.exe,即可打开IDE。
警告:The FPC source directory "D:\fpc_svn\" does not
look correct:
Found version ..1, expected 2.7.1
新建目录 d:\fpc_svn\source
复制 d:\fpc_svn\packages 到d:\fpc_svn\source
复制 d:\fpc_svn\rtl 到d:\fpc_svn\source
lazarus目录 D:\laz_svn\
编译器路径 D:\fpc_svn\bin\i386-win32\fpc.exe
FPC源代码目录 D:\fpc_svn\source
Make文件目录 $Path($(CompPath))make.exe
Gdb文件目录 $Path($(CompPath))gdb.exe
注:以上过程完成后得到32位的FPC与Lazarus环境,如果要搭建64位环境的话,将相应代码中i386-win32改为x86_64-win64即可。
win64启动时警告:win64位缺少gdb.exe,SVN未获取64位版本的gdb,暂时不用
win64编译win32时,提示:compiler "D:\fpc_svn\bin\x86_64-win64\fpc.exe
does not support target i386-win32
将编译器路径改为 D:\fpc_svn\bin\i386-win32\fpc.exe
-----------------------------------------------------------------------------------------
制造绿色版的Lazarus:
1、在安装目录里建一个新的目录,如:config ,则路径显示为: d:\laz_svn\config 。
2、将目录:C:\Documents and Settings\Administrator\Local Settings\Application Data\lazarus
下的所有东西都剪切到 d:\laz_svn\config 里。
6、在安装目录里建立一个批处理文件,如: run_lazarus.bat
D:\laz_svn\startlazarus.exe --pcp=D:\laz_svn\config
7、运行 run_lazarus.bat
转自:http://www.fpccn.com/thread-2754-1-1.html
-----------------------------------------------------------------------------------------
ubuntu:
sudo apt-get install lazarus
Fedora:
sudo yum install lazarus
安装后升级到最新的开发版,因为官方是用SVN来管理源代码,所以要安装SVN工具:
ubuntu:
sudo apt-get install subversion
Fedora:
sudo yum install subversion
下载lazarus源码:
svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus
下载fpc源码:
[pre] svn co http://svn.freepascal.org/svn/fpc/trunk fpc
然后编译,编译前还要下载一些库:
sudo apt-get install libgpmg1-dev fakeroot libncurses5-dev build-essential
cd lazarus/tools/install
./create_fpc_deb.sh fpc /home/user/fpc
编译fpc源码及生成deb包,/home/user/fpc源码的路径
完成后会生成一个fpc.tgz和fpc.deb包,如 fpc_2.5.1-101202_i386.deb fpc-2.5.1-101202.tar.gz
安装fpc:
sudo dpkg -i fpc_2.5.1-101202_i386.deb
然后cd ../..退出lazars目录下:make clean all
完成后使用./lazarus 打开
进入后到
Environment->Options
->Lazarus directory(default for all projects)
/home/user/lazarus/
->Compiler path(e.g.fpc)
/usr/bin/fpc
->FPC source directory
/home/user/fpc/
->Make path
/usr/bin/make
->Directory for building test projects
/tmp
完成后就可以用了!
以后再更新源碼就用:
svn update fpc
svn update lazarus
再重新 ./create_fpc_deb.sh fpc /home/user/fpc
sudo dpkg -i fpc_2.5.1-101202_i386.deb
make clena all
就可以了!Fedora 則要用 create_fpc_rpm.sh 了
http://www.fpccn.com/thread-886-1-1.html