https://wiki.freepascal.org/api.php?action=feedcontributions&user=Fititnt&feedformat=atomLazarus wiki - User contributions [en]2024-03-29T07:39:03ZUser contributionsMediaWiki 1.35.6https://wiki.freepascal.org/index.php?title=User_talk:Fititnt&diff=10447User talk:Fititnt2006-07-16T05:51:15Z<p>Fititnt: </p>
<hr />
<div>( vide alguns sites: [[http://lazaruspascal.codigolivre.org.br/portal.php]]e [[http://www.webdesign.eng.br]], por fititnt)<br />
<br />
--<br />
<br />
Ola Fititnt. Será que voce poderia mudar o nome das páginas que criou de <página>/ptbr para <página>/pt ? É só clicar em "move", perto do botão "edit"<br />
<br />
É que foi decidido que mudariamos de "Português Brasileiro" para apenas "Português". Além de ocupar menos espaço é razoavel não restringirmos para apenas uma vertente do portugues.<br />
<br />
obrigado pela atenção.<br />
<br />
--[[User:Sekelsenmat|Sekelsenmat]] 03:29, 21 Nov 2005 (CET)</div>Fititnthttps://wiki.freepascal.org/index.php?title=User_talk:Fititnt&diff=10446User talk:Fititnt2006-07-16T05:50:06Z<p>Fititnt: </p>
<hr />
<div>( vide alguns sites: [[http://lazaruspascal.codigolivre.org.br/portal.php]]e [[http://www.webdesign.eng.br]]<br />
<br />
Ola Fititnt. Será que voce poderia mudar o nome das páginas que criou de <página>/ptbr para <página>/pt ? É só clicar em "move", perto do botão "edit"<br />
<br />
É que foi decidido que mudariamos de "Português Brasileiro" para apenas "Português". Além de ocupar menos espaço é razoavel não restringirmos para apenas uma vertente do portugues.<br />
<br />
obrigado pela atenção.<br />
<br />
--[[User:Sekelsenmat|Sekelsenmat]] 03:29, 21 Nov 2005 (CET)</div>Fititnthttps://wiki.freepascal.org/index.php?title=Developing_with_Graphics/pt&diff=4144Developing with Graphics/pt2005-11-27T21:13:35Z<p>Fititnt: </p>
<hr />
<div>{{Developing with Graphics}}<br />
<br />
==Visão Geral==<br />
<br />
Esta página foi iniciada para tutoriais com respeito para manipulação de Bitmaps e outros graficos no seu programa. Como eu não sou um programador gráfico, eu convido todos os outros que são, para participar desta especialidade. Nesse momento adicione um link para a próxima seção, adicione uma página e crie seu próprio artigo Wiki.<br />
Nesta página alguma informação geral será dada.<br />
<br />
==Outros Tutoriais Gráficos==<br />
* [[#Working with TBitmap|Criando]] um Bitmap fade.<br />
* [[TAChart]] - Componentes Charting para Lazarus<br />
<br />
==Trabalhando com TBitmap==<br />
A primeira idéia para lembrar é que Lazarus tem em vista ser para plataforma independente, deste modo alguns métodos usando a API do windows estão fora de questão. Deste modo um método como ScanLine não é suportado por Lazarus porque ele é planejado para Dispositivo de Bitmap Independente e usa uma função da [biblioteca] GDI32.dll<br />
Isso já da uma boa pergunta ao FAQ: Porque não há ScanLine no Lazarus?<br />
<br />
===Um definhado/fading exemplo===<br />
Fala do que você precisa para criar uma "Fading Picture". No Delphi você pode fazer algo como:<br />
<code><br />
type<br />
PRGBTripleArray = ^TRGBTripleArray;<br />
TRGBTripleArray = array[0..32767] of TRGBTriple;<br />
<br />
procedure TForm1.FadeIn(aBitMap: TBitMap);<br />
var<br />
Bitmap, BaseBitmap: TBitmap;<br />
Row, BaseRow: PRGBTripleArray;<br />
x, y, step: integer;<br />
begin<br />
Bitmap := TBitmap.Create;<br />
try<br />
Bitmap.PixelFormat := pf32bit; // ou pf24bit<br />
Bitmap.Assign(aBitMap);<br />
BaseBitmap := TBitmap.Create;<br />
try<br />
BaseBitmap.PixelFormat := pf32bit;<br />
BaseBitmap.Assign(Bitmap);<br />
for step := 0 to 32 do begin<br />
for y := 0 to (Bitmap.Height - 1) do begin<br />
BaseRow := BaseBitmap.Scanline[y];<br />
Row := Bitmap.Scanline[y];<br />
for x := 0 to (Bitmap.Width - 1) do begin<br />
Row[x].rgbtRed := (step * BaseRow[x].rgbtRed) shr 5;<br />
Row[x].rgbtGreen := (step * BaseRow[x].rgbtGreen) shr 5; // Fading<br />
Row[x].rgbtBlue := (step * BaseRow[x].rgbtBlue) shr 5;<br />
end;<br />
end;<br />
Form1.Canvas.Draw(0, 0, Bitmap);<br />
InvalidateRect(Form1.Handle, nil, False);<br />
RedrawWindow(Form1.Handle, nil, 0, RDW_UPDATENOW);<br />
end;<br />
finally<br />
BaseBitmap.Free;<br />
end;<br />
finally<br />
Bitmap.Free;<br />
end;<br />
end;<br />
</code><br />
Esta função no Lazarus pode ser implementada como:<br />
<code><br />
procedure TForm1.FadeIn(ABitMap: TBitMap);<br />
var<br />
SrcIntfImg, TempIntfImg: TLazIntfImage;<br />
ImgHandle,ImgMaskHandle: HBitmap;<br />
FadeStep: Integer;<br />
px, py: Integer;<br />
CurColor: TFPColor;<br />
TempBitmap: TBitmap;<br />
begin<br />
SrcIntfImg:=TLazIntfImage.Create(0,0);<br />
SrcIntfImg.LoadFromBitmap(ABitmap.Handle,ABitmap.MaskHandle);<br />
TempIntfImg:=TLazIntfImage.Create(0,0);<br />
TempIntfImg.LoadFromBitmap(ABitmap.Handle,ABitmap.MaskHandle);<br />
TempBitmap:=TBitmap.Create;<br />
for FadeStep:=1 to 32 do begin<br />
for py:=0 to SrcIntfImg.Height-1 do begin<br />
for px:=0 to SrcIntfImg.Width-1 do begin<br />
CurColor:=SrcIntfImg.Colors[px,py];<br />
CurColor.Red:=(CurColor.Red*FadeStep) shr 5;<br />
CurColor.Green:=(CurColor.Green*FadeStep) shr 5;<br />
CurColor.Blue:=(CurColor.Blue*FadeStep) shr 5;<br />
TempIntfImg.Colors[px,py]:=CurColor;<br />
end;<br />
end;<br />
TempIntfImg.CreateBitmap(ImgHandle,ImgMaskHandle,false);<br />
TempBitmap.Handle:=ImgHandle;<br />
TempBitmap.MaskHandle:=ImgMaskHandle;<br />
Canvas.Draw(0,0,TempBitmap);<br />
end;<br />
SrcIntfImg.Free;<br />
TempIntfImg.Free;<br />
TempBitmap.Free;<br />
end;<br />
</code><br />
O código Lazarus desta página foi pego do projeto $LazarusPath/examples/lazintfimage/fadein1.lpi. Deste modo se você quiser começar bem com programação gráfica veja este exemplo.<br />
<br />
<br />
==Gráficos em movimento - Como evitar a tremulação==<br />
Há várias opções para mudar rapidamente gráficos 2D. Para começar, você precisa escolher se vai usar alguma aceleração de hardware, como OpenGL, ou se prefere usar configuração de vídeo padrão. OpenGL tem a melhor velocidade em computadores novos, especialmente com boas placas de vídeo, mas terá uma perda significativa de velocidade em computadores mais antigos. Este tutorial focalizará como usar a configuração de vídeo padrão de tela. Se você deseja ajuda com OpenGL, dê uma olhada no exemplo que acompanha o Lazarus. Você também pode usar o A.J. Venter's gamepack, que provê um armazenamento temporário duplo da tela e um componente "sprite" .<br />
<br />
Agora nós examinaremos as opções que temos para desenhar a tela:<br />
* [[#Draw to a TImage|Draw to a TImage]]<br />
* [[#Draw on the OnPaint event|Draw on the OnPaint event of the form, a TPaintBox or another control]]<br />
* [[#Create a custom control which draws itself|Create a custom control which draws itself]]<br />
* [[#Using A.J. Venter's gamepack|Using A.J. Venter's gamepack]]<br />
<br />
===Desenhar com o TImage===<br />
Nunca use o evento OnPaint para desenhar na TImage. O TImage é armazenado temporariamente , e assim tudo que você precisa fazer é desenhar em qualquer lugar e e a mudança será para sempre. Todavia, se você está constantemente redesenhando, a imagem tremulará. Neste caso pode tentar outras opções. Desenhar com o TImage é considerado lento comparado a outras aproximações.<br />
<br />
<code><br />
procedure TForm1.BitBtn1Click(Sender: TObject);<br />
var<br />
x, y: Integer;<br />
begin<br />
// Draws the backgroung<br />
Image.Canvas.Pen.Color := clWhite;<br />
Image.Canvas.Rectangle(0, 0, Image.Width, Image.Height);<br />
<br />
// Draws squares<br />
Bitmap.Canvas.Pen.Color := clBlack;<br />
for x := 1 to 8 do<br />
for y := 1 to 8 do<br />
Image.Canvas.Rectangle(Round((x - 1) * Image.Width / 8), Round((y - 1) * Image.Height / 8),<br />
Round(x * Image.Width / 8), Round(y * Image.Height / 8));<br />
end;<br />
</code><br />
<br />
===Desenhar com o evento OnPaint===<br />
Neste caso todo o desenho tem que ser feito no evento OnPaint. Não permanece no armazenamento temporário, como no evento TImage.</div>Fititnthttps://wiki.freepascal.org/index.php?title=How_To_Help_Developing_Lazarus/pt&diff=3916How To Help Developing Lazarus/pt2005-11-27T02:03:55Z<p>Fititnt: </p>
<hr />
<div>== Então você quer ajudar o Lazarus se tornar uma classe de IDE mundial. Bem, você veio ao lugar certo.==<br />
<br />
Este é um trabalho em progresso. Se você tem alguma informação útil, ou vê algum engano, sinta-se livre para arrumar ou adicionar a esta página.<br />
<br />
== Requisitos para desenvolver o Lazarus ==<br />
# Lazarus não irá mais compilar com a com o FPC versão 1.0.10. Você deverá ter a última versão atualizada do FreePascal (atualmente 2.0.0, ou uma recente versão SNV é recomendada).<br />
# Você DEVE ter uma versão bem atualizada do lazarus a partir do SNV. [[Getting_Lazarus#Via_SVN|Getting Lazarus Via SVN]]<br />
<br />
== Por onde começar?==<br />
Então, você agora tem uma versão recentíssima do lazarus e quer começar a melhorá-lo, mas " por onde eu começo?"<br />
<br />
Bem, isso depende. Se você não sabe sobre o Lazarus mas apenas quer ajudar, eu deveria recomendar que olhe na lista de bugs [http://www.lazarus.freepascal.org/mantis/main_page.php Bug Tracker], e ache um bug que você acha que pode arrumar, e comece a hackear. O Lazarus team tem prioridade para arrumar os bugs que estão na [[Road To 1.0]].<br />
<br />
O Lazarus precisa de mais documentação! Se você não quer consertar um bug, pode ajudar escrevendo mais documentação. Olhe em [[Lazarus Documentation Editor]] e [[LCL Documentation Roadmap]] para alguma ajuda sobre como e ter a lista de units a serem documentadas.<br />
<br />
Também veja estes links: [[Extending the IDE]], [[Lazarus IDE ToDo List]]<br />
<br />
Se você tem alguma questão, pode perguntá-la na Lista de E-mail do Lazarus (veja [http://www.lazarus.freepascal.org/modules.php?op=modload&name=StaticPage&file=index&sURL=maill Mailing list]) ou no canal #lazarus-ide no irc.freenode.net<br />
<br />
<br />
<br />
== Agora, eu arrumei um bug e adicionei documentação. Como eu submeto minhas mudanças? ==<br />
Você precisa fazer um "patch" ([[Creating A Patch]]) ae mandá-lo para a lista de e-mail (tamanho máximo de 40kb) ou mande em anexo em um e-mail para [mailto:patch@lazarus.dommelstein.net patch@lazarus.dommelstein.net].<br />
<br />
Se você precisa de alguma ajuda com essas coisas, você sempre pode perguntá-las na Lista de E-mail do Lazarus ou no #lazarus-ide em irc.freenode.net.</div>Fititnthttps://wiki.freepascal.org/index.php?title=How_To_Help_Developing_Lazarus/pt&diff=3910How To Help Developing Lazarus/pt2005-11-27T01:43:45Z<p>Fititnt: </p>
<hr />
<div>== Então você quer ajudar o Lazarus se tornar uma classe de IDE mundial. Bem, você veio ao lugar certo.==<br />
<br />
Este é um trabalho em progresso. Se você tem alguma informação útil, ou vê algum engano, sinta-se livre para arrumar ou adicionar a esta página.<br />
<br />
== Requisitos para desenvolver o Lazarus ==<br />
# Lazarus não irá mais compilar com a com o FPC versão 1.0.10. Você deverá ter a última versão atualizada do FreePascal (atualmente 2.0.0, ou uma recente versão SNV é recomendada).<br />
# Você DEVE ter uma versão bem atualizada do lazarus a partir do SNV. [[Getting_Lazarus#Via_SVN|Getting Lazarus Via SVN]]<br />
<br />
== Por onde começar?==<br />
Então, você agora tem uma versão recentícima do lazarus e quer começar a melhorá-lo, mas " por onde eu começo?"<br />
<br />
Bem, isso depende. Se você não sabe sobre o Lazarus mas apenas quer ajudar, eu deveria recomendar que olhe na lista de bugs [http://www.lazarus.freepascal.org/mantis/main_page.php Bug Tracker], e ache um bug que você acha que pode arrumar, e comece a hackear. O Lazarus team tem prioridade para arrumar os bugs que estão na [[Road To 1.0]].<br />
<br />
If you don't have any particular woes about Lazarus but just want to help, then I would recommend looking at the bug list [http://www.lazarus.freepascal.org/mantis/main_page.php Bug Tracker] find a bug that you think you can fix, and start hacking. The lazarus team has prioritized the open bugs in the [[Road To 1.0]].<br />
<br />
Lazarus needs more documentation! If you don't want to fix a bug you can help by writing documentation. Look at [[Lazarus Documentation Editor]] and [[LCL Documentation Roadmap]] for some help on how to and a list of units to be documented.<br />
<br />
Also see these links: [[Extending the IDE]], [[Lazarus IDE ToDo List]]<br />
<br />
If you have any question you can ask them on the Lazarus Mailing list (see [http://www.lazarus.freepascal.org/modules.php?op=modload&name=StaticPage&file=index&sURL=maill Mailing list]) or on the #lazarus-ide IRC channel on irc.freenode.net.<br />
<br />
== Now I've fixed lazarus or added documentation. How do I submit my changes? ==<br />
You will need to make a "patch" ([[Creating A Patch]]) and send it to the mailing list (maximum size 40kB) or the mailbox for patches [mailto:patch@lazarus.dommelstein.net patch@lazarus.dommelstein.net].<br />
<br />
If you need help doing any of these things, you can always ask on the Lazarus mailing list or ask in #lazarus-ide on irc.freenode.net.</div>Fititnthttps://wiki.freepascal.org/index.php?title=DesignGuidelines/pt&diff=3914DesignGuidelines/pt2005-11-27T01:02:19Z<p>Fititnt: /* Linhas Gerais de Desenho */</p>
<hr />
<div>== Linhas Gerais de Desenho ==<br />
<br />
'''Isto é para desenvolvedores lazarus:'''<br />
<br />
* Veja [http://svn.freepascal.org/svn/lazarus/trunk/docs/DesignGuidelines.txt docs/DesignGuidelines.txt]<br />
<br />
<br />
;Coding style:<br />
* Considerando um estilo que é mais fácil ler, Lazarus segue a linhas de guia de estilo da Borland Coding. Claro que, quase qualquer um achará alguns pontos lá que são discutíveis menos legível que outros estilos. Ok, tente seguir 90% dele pelo menos.<br />
* Tente evitar units em forma de círculo. Insto a faz mais fácil de navegar quando unidade está crescendo permite dividí-la.<br />
* Minimize o número de chamadas da interface para LCL ao executar uma ação pedida pelo LCL. As interfaces só notificam o LCL, nunca force algo. O LCL decide.<br />
* Convenção de nomes, veja [[Nomenclature]]<br />
* ll code must work with all checks (range, io, overflow, stack) on. Além isso isto ajuda depuração, alguns usuários puseram estes checks em seus fpc.cfg, assim eles são aplicados ao lazarus inteiro. Inclusive pacotes e exemplos.<br />
<br />
<br />
;Novos arquivos:<br />
* Todo arquivo deve começar com um cabeçalho que contém a licença e alguns linhas que descrevem o conteúdo.<br />
* Os nomes de arquivos em Pascal tem de ser escritos em letra minúscula (.pas, .pp, .inc, .lfm, .lrs)<br />
<br />
<br />
;Incluir arquivos:<br />
* Deveria começar com a diretiva {%MainUnit }<br />
<br />
<br />
;Packages:<br />
* Deveria ter uma entrada packager/globallinks/ no .lpl<br />
<br />
<br />
;Caixas de dialogos (modal forms): <br />
* Fechar ao se pressionar Esc (se essa tecla não for usada para outra função) <br />
* Defina botão padrão e o de retorno ativos (if key not used) <br />
* As médias e complexas caixas de diálogos deveriam ser redimensionáveis e o tamanho ser guardado<br />
<br />
<br />
;Itens no Main Menu :<br />
* Deveriam ter suas teclas em keymapping.pp<br />
<br />
<br />
-----<br />
''Authoritive version pode ser achada em [http://svn.freepascal.org/svn/lazarus/trunk/docs/DesignGuidelines.txt svn].Propostas para melhorias podem ser adicionadas na página de discussão''.</div>Fititnthttps://wiki.freepascal.org/index.php?title=DesignGuidelines/pt&diff=3909DesignGuidelines/pt2005-11-27T00:49:54Z<p>Fititnt: </p>
<hr />
<div>== Linhas Gerais de Desenho ==<br />
<br />
'''This is for lazarus developers:'''<br />
<br />
* Veja [http://svn.freepascal.org/svn/lazarus/trunk/docs/DesignGuidelines.txt docs/DesignGuidelines.txt]<br />
<br />
<br />
;Coding style:<br />
* Considerando um estilo que é mais fácil ler, Lazarus segue a linhas de guia de estilo da Borland Coding. Claro que, quase qualquer um achará alguns pontos lá que são discutíveis menos legível que outros estilos. Ok, tente seguir 90% dele pelo menos.<br />
* Tente evitar units em forma de círculo. Insto a faz mais fácil de navegar quando unidade está crescendo permite dividí-la.<br />
* Minimize o número de chamadas da interface para LCL ao executar uma ação pedida pelo LCL. As interfaces só notificam o LCL, nunca force algo. O LCL decide.<br />
* Convenção de nomes, veja [[Nomenclature]]<br />
* ll code must work with all checks (range, io, overflow, stack) on. Além isso isto ajuda depuração, alguns usuários puseram estes checks em seus fpc.cfg, assim eles são aplicados ao lazarus inteiro. Inclusive pacotes e exemplos.<br />
<br />
<br />
;Novos arquivos:<br />
* Todo arquivo deve começar com um cabeçalho que contém a licença e alguns linhas que descrevem o conteúdo.<br />
* Os nomes de arquivos em Pascal tem de ser escritos em letra minúscula (.pas, .pp, .inc, .lfm, .lrs)<br />
<br />
<br />
;Incluir arquivos:<br />
* Deveria começar com a diretiva {%MainUnit }<br />
<br />
<br />
;Packages:<br />
* Deveria ter uma entrada packager/globallinks/ no .lpl<br />
<br />
<br />
;Caixas de dialogos (modal forms): <br />
* Fechar ao se pressionar Esc (se essa tecla não for usada para outra função) <br />
* Defina botão padrão e o de retorno ativos (if key not used) <br />
* As médias e complexas caixas de diálogos deveriam ser redimensionáveis e o tamanho ser guardado<br />
<br />
<br />
;Itens no Main Menu :<br />
* Deveriam ter suas teclas em keymapping.pp<br />
<br />
<br />
-----<br />
''Authoritive version pode ser achada em [http://svn.freepascal.org/svn/lazarus/trunk/docs/DesignGuidelines.txt svn].Propostas para melhorias podem ser adicionadas na página de discussão''.</div>Fititnthttps://wiki.freepascal.org/index.php?title=DesignGuidelines/pt&diff=3908DesignGuidelines/pt2005-11-27T00:48:58Z<p>Fititnt: </p>
<hr />
<div>== Linhas Gerais de Desenho ==<br />
<br />
'''This is for lazarus developers:'''<br />
<br />
* Veja [http://svn.freepascal.org/svn/lazarus/trunk/docs/DesignGuidelines.txt docs/DesignGuidelines.txt]<br />
<br />
<br />
;Coding style:<br />
* Considerando um estilo que é mais fácil ler, Lazarus segue a linhas de guia de estilo da Borland Coding. Claro que, quase qualquer um achará alguns pontos lá que são discutíveis menos legível que outros estilos. Ok, tente seguir 90% dele pelo menos.<br />
* Tente evitar units em forma de círculo. Insto a faz mais fácil de navegar quando unidade está crescendo permite dividí-la.<br />
* Minimize o número de chamadas da interface para LCL ao executar uma ação pedida pelo LCL. As interfaces só notificam o LCL, nunca force algo. O LCL decide.<br />
* Convenção de nomes, veja [[Nomenclature]]<br />
* ll code must work with all checks (range, io, overflow, stack) on. Além isso isto ajuda depuração, alguns usuários puseram estes checks em seus fpc.cfg, assim eles são aplicados ao lazarus inteiro. Inclusive pacotes e exemplos.<br />
<br />
<br />
;Novos arquivos:<br />
* Todo arquivo deve começar com um cabeçalho que contém a licença e alguns linhas que descrevem o conteúdo.<br />
* Os nomes de arquivos em Pascal tem de ser escritos em letra minúscula (.pas, .pp, .inc, .lfm, .lrs)<br />
<br />
<br />
;Incluir arquivos:<br />
* Deveria começar com a diretiva {%MainUnit }<br />
<br />
<br />
;Packages:<br />
* Deveria ter uma entrada packager/globallinks/ no .lpl<br />
<br />
;Caixas de dialogos (modal forms): <br />
* Fechar ao se pressionar Esc (se essa tecla não for usada para outra função) <br />
* Defina botão padrão e o de retorno ativos (if key not used) <br />
* As médias e complexas caixas de diálogos deveriam ser redimensionáveis e o tamanho ser guardado<br />
<br />
<br />
;Itens no Main Menu :<br />
* Deveriam ter suas teclas em keymapping.pp<br />
<br />
<br />
-----<br />
''Authoritive version pode ser achada em [http://svn.freepascal.org/svn/lazarus/trunk/docs/DesignGuidelines.txt svn].Propostas para melhorias podem ser adicionadas na página de discussão''.</div>Fititnthttps://wiki.freepascal.org/index.php?title=Installing_Lazarus/pt&diff=5082Installing Lazarus/pt2005-11-27T00:02:47Z<p>Fititnt: /* FPC Sources for Windows */</p>
<hr />
<div>{{Installing Lazarus}}<br />
<br />
==Visão Geral==<br />
Para pessoas que simplesmente querem instalar Lazarus e começar a usá-lo para programar, a maneira mais fácil é instalar uma versão recente, razoavelmente estável, de um binário (como um pacote linux ". rpm" ou um Windows ". exe"). Você pode ler as seções abaixo de linux ou Windows intitulado "binários de fpc" ou os primeiros parágrafos nas seções em instalar Lazarus em linux ou Windows; a maioria da informação restantes podem ser ignoradas seguramente. <br />
<br />
Para os que querem participar no desenvolvimento do compilador ou da IDE, ou para quem quer ter as ferramentas com atualizações em dia, uma instalação de arquivos de fonte é necessária, e muito do resto desta informação é pertinente. <br />
Lazarus provê duas partes principais: <br />
<br />
<br />
Lazarus provê duas partes principais: <br />
* LCL - Biblioteca de Componentes do Lazarus ( Lazarus Component Library ) <br />
* IDE - ferramenta de RAD <br />
<br />
Estes são em troca dependentes de <br />
* FPC - o compilador de freePascal ( freePascal compiler ) <br />
* FCL - a Biblioteca de Componentes FreePascal Componente biblioteca (FreePascal Component Library ), contendo a maioria dos componentes de não-gráficos usado pelo Lazarus.<br />
<br />
===Requisitos de Sistema do Lazarus===<br />
<br />
# Compilador de FreePascal, pacotes (packages), e fontes ( sources). (*important*: of the same version/date)<br />
# Uma Widget tool-kit de suporte<br />
#:;Win32: : API nativas do Win32 podem ser usadas<br />
#:;Linux/xxxBSD: GTK+ 1.2.x : A maioria distribuições de Linux e * BSDs já instalam bibliotecas GTK+ 1.2.x. Você também pode achar em http://www.gtk.org. <br> Você também desejará ter gdk-pixbuf, 0.13 ou mais novo ( preferencialmente 0.18 ou mais recente), que também é achado na maioria das recentes distribuições dos últimos 2 anos. A fonte está disponível em ftp://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/<br />
#:;Mac OS X: GTK+ 1.2.x : Você precisa das ferramentas de desenvolvedor da apple, X11 e GTK1.2. Veja abaixo como instalar o Lazarus no Mac OS X.<br />
#:;GTK+ 2.x: ADVERTÊNCIA : A interface interativa GTK2 não está totalmente implementada é só deve ser usada para testes. <br> É encontrada na maioria das distribuições recentes. Peque a fonte em http://www.gtk.org.<br />
<br />
<br />
A FAQ - As perguntas frequentemente perguntadas podem ser encontradas em http://www.lazarus.freepascal.org . Algumas respostas podem ser encontradas no arquivo local 'FAQ'.<br />
<br />
<br />
As seções seguintes descreverão como adquirir FreePascal e como instalar lazarus corretamente.<br />
<br />
==Installing The Free Pascal Compiler==<br />
<br />
There is an extensive discussion of how to install and build Free Pascal compilers available here http://www.stack.nl/~marcov/buildfaq.pdf - it may be a little too detailed for some users, but is very comprehensive.<br />
<br />
Lazarus requires fpc (FreePascal) version 1.9.x and it requires both the compiled fpc libs (binaries) and the fpc sources and of the same version. fpc 1.0.6 is too buggy and fpc 1.0.10 has problems opening forms created with fpc 1.9.x. FreePascal version 2.0.0 has now been released, and is the preferred compiler (fpc-2.0.0).<br />
<br />
===Installing Free Pascal under Linux===<br />
<br />
====FPC Binaries====<br />
<br />
The latest release of FreePascal, version 2.0.1, can be obtained from the FreePascal website (http://www.freepascal.org/download.html, then choose a mirror) or from sourceforge (http://sourceforge.net/projects/lazarus). <br />
<br />
At the lazarus downloads section (http://www.lazarus.freepascal.org ) you can get the RPM of the Free Pascal compiler (compiler / linux) and its packages. If you don't have an RPM-based distribution, you can download and install the tarballs from http://www.freepascal.org. If you want to compile the binaries for yourself, see the BSD section.<br />
<br />
Instructions: <br />
<br />
Download lastest files from http://sourceforge.net/project/showfiles.php?group_id=89339.<br />
As example:<br />
:* fpc-2.0.1-050923.i386.rpm<br />
:* fpcsrc-2.0.1-050923.i386.rpm<br />
:* lazarus-0.9.10-0.i386.rpm<br><br />
and install them with:<br />
:* rpm -Uvh fpc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh fpcsrc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh lazarus-0.9.10-0.i386.rpm<br><br />
<br />
Daily snapshot Debian packages can be downloaded from http://cYcnus.de/deb/. At present this contains only the compiled fpc components, but not the sources, which would be needed for most Lazarus programming.<br />
<br />
====FPC Sources====<br />
<br />
Together with the release of version 2.0, FPC no longer uses CVS, but has migrated to Subversion (SVN). For now, there is no CVS mirror yet, so you have to use SVN to get the FPC sources.<br />
<br />
===== Download Daily Source Snapshot of Development Tree (version 2.1.x) =====<br />
You can download today's development (v 2.1.x) sources in the form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.1.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v21/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
===== Download Daily Source Snapshot of Release Tree (version 2.0.x) =====<br />
You can download today's development (v 2.0.x) sources that will lead to the next stable release in form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.0.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v20/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
<br />
===== Connect to Source Repository with SVN (replaces section on connection to CVS) =====<br />
As an alternative to the daily zip files of the SVN sources, the SVN repository has been made accessible for everyone, with read-only access. This means that you can directly access the code, and you will have really the last-minute sources available. It is also a method which requires less bandwidth once you have done the first download (checkout in SVN lingo).<br />
===== Development snapshots =====<br />
How to do this? <br />
(You need to have SVN installed, of course. Look [http://subversion.tigris.org/ here] for instructions on how to do that.)<br />
<br />
Change Directory (cd) to the parent directory of your development area, eg <br />
<br />
[]$ cd /home/username/FreePascal<br />
<br />
To retrieve the full source repository, all publicly available modules, type<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc<br />
<br />
Normally, you should perform this step just once.<br />
<br />
To update the sources which were downloaded (checkout) above<br />
<br />
[]$svn update fpc<br />
<br />
<br />
===== Fixes to 2.0.x =====<br />
<br />
The fixes need a separate directory, create a separate directory 'fixes', enter it, and repeat the above checkout command with the URL http://svn.freepascal.org/svn/fpc/branches/fixes_2_0:<br />
<br />
[]$ cd mysvn/fixes<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_0 fpc<br />
<br />
and to update:<br />
<br />
[]$ svn update fpc<br />
<br />
The sources of docs are in a separate repository called fpcdocs, so the command to get them is<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs<br />
<br />
If you want to learn more about subversion, read this excellent [http://svnbook.red-bean.com/ Subversion book] which is also available online in different formats for free.<br />
<br />
For the curious: You have only read-only access, so don't try to commit anything :-)<br />
<br />
For more information, see the [http://www.freepascal.org/develop.html FreePascal] website<br />
<br />
===Instalando o Lazarus no Windows===<br />
<br />
====Binários FPC do Windows====<br />
<br />
Sem dúvida o modo mais fácil para adquirir uma instalação funcional de Free Pascal é baixar a última liberação dos binários do Lazarus para o Windows no SourceForge - a liberação contém as versões atuais do compilador do FreePascal e as bibliotecas de FreePascal como também o lazarus IDE. Se você quer instalar direto das fontes, vá em frente e siga lendo!<br />
<br />
Você pode adquirir o instalador zipado para o fpc 2.0.0 na seção Free Pascal em http://www.freepascal.org/download.html, e então escolha um mirror).<br />
Instalando direto das fontes - -veja a próxima seção para saber os adquirir-- não é para novatos, desde que você precisa de um compilador é um bom começo<br />
<br />
====Fontes de FPC para Windows==== <br />
<<<< Veja a seção sob [[#FPC Sources|FPC Sources]] para Linux onde o uso de SVN é descrito >>>> <br />
<br />
O modo mais fácil para adquirir fontes Free Pascal é via CVS; veja a próxima seção para saber mais disso. Você também pode baixar como um pacote todo -- veja http://www.freepascal.org/develop.html para o visão diária da árvore de liberação 2.1.x. <br />
<br />
<br />
Fontes Windows FPC por CVS () <br />
<br />
Você precisará ter um cliente de CVS como TortoiseCVS ou WinCVS instalado para executar os passos abaixo. Os comandos exatos variam entre clientes de CVS; the ones given below are to be used under CVS home's client, which is available for download here.<br />
<br />
First create a directory in which you'd like to put the sources. Any normal user can do this. Create a directory for fpc (e.g. C:\Source), then do the following at the command prompt:<br />
C:\Source> set CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
C:\Source> cvs login // o password é 'cvs' sem as aspas<br />
C:\source> cvs -z3 co fpc // Isto criará um fpc de diretório que pode ser usado depois no IDE.<br />
Hint: Para baixar/atualizar as mais recentes mudanças que você simplesmente pode fazer<br />
C:\> cd Source\FPC<br />
C:\Source\FPC> cvs -z3 update -dP<br />
''Como: Escreva-me.''<br />
<br />
See: http://www.freepascal.org/down-win32.html . Você pode achar uma lista de mirrors em http://www.freepascal.org/sdown.html. Baixe o FPC como um grande arquivo, descompacte e execute o install.exe. <br />
<br />
Estendendo sua variável de PATH ao diretório de fpc:<br />
<br />
* Win98: Edite autoexec.bat e adicione a linha: PATH=%PATH%;C:\pp\bin\bin\win32<br />
* WinXP/2k: Meu computador (clique direito) -> Propriedades -> Advanced (Page) -> Enviroment Variables -> System Variables -> Edit "PATH", Add "C:\pp\bin\bin\win32" aqui.<br />
<br />
Reinicie o windows.<br />
<br />
''Como: Explicar como baixar as fontes fpc e contruir o compilador''<br />
<br />
===Installing Free Pascal under BSD/manually===<br />
<br />
Effectively, you need<br />
<br />
A file with all sources, or two (fpc and lazarus)<br />
<br />
1. e.g. for fpc ftp://ftp.freepascal.org/fpc/dist/Linux/separate/sources.tar preferably an export (no CVS/ dirs). The above file misses this.<br />
2. Lazarus source snapshot.<br />
* _any_ starting compiler from the 1.9 branch) You can do a check by parsing the output of ppc386 -i if it is 1.9.3 .. 2.0.x it is ok.<br />
* - dependant packages. (for FreeBSD that is gtk12, glib12 and gdk_pixbuf and GNU make, iconv and gettext)<br />
<br />
FPC build:<br />
<br />
1. (fetch) necessary files (FPC source, starting compiler)<br />
2. (extract) Then de-tgz in work directory,<br />
3. (build) enter work/fpc/ and run<br />
<br />
$MAKE all OPT='-gl -O3p3' PP=/path/to/startingcompiler-name-ppc386<br />
(/path/to/ can be omitted when ppc386 is in the path)<br />
($MAKE is make on linux and gmake on BSD)<br />
<br />
4. (install) then, again in work/fpc, run<br />
<br />
$MAKE install PP=compiler/ppc386 PREFIX=$THEPREFIX<br />
(THEPREFIX= usually is /usr/lcoal, but e.g. on NetBSD it is /usr/pkg for ports)<br />
Create a symlink:<br />
ln -s $THEPREFIX/lib/fpc/2.0.1/ppc386 $THEPREFIX/bin/ppc386<br />
install sourceinstall PREFIX=$THEPREFIX<br />
<br />
5. (configure) run compiler/utils/samplecfg $THEPREFIX/lib/fpc/2.0.1 $ETCDIR<br />
6. (optional, test), see if ppc386 -i gives output, else give a warning that user need to add $PREFIX/bin to his current path. Try to compiler a program with -viwn, and see if that gives errors.<br />
Notes:<br />
<br />
* If you need fpcmake package lists, you need to generate or supply them yourself, (in the port, or in an extra archive) either way, do a dummy install to /tmp/pack and determine the files installed with find . >ll<br />
<br />
* $THEPREFIX and $ETCDIR should be user configurable. Otherwise local installs aren't possible.<br />
<br />
* BSDHIER=1 on all make commands forces BSD hierarchy conventions.<br />
<br />
===Installing Free Pascal under Mac OS X===<br />
<br />
You need the Apple Developer-tools, X11, gtk1.2:<br />
<br />
Downloading packages and installing them properly can be a time consuming task. Therefore there are various package managers. One of them is fink:<br />
: Download fink from http://fink.sourceforge.net/download/index.php?phpLang=en; follow the install instructions.<br />
<br />
Developer-tools: Are included on the original OSX installation-CDs, or download at ADC (free registration required)<br />
: http://developer.apple.com/.<br />
<br />
Apple X11: On a fresh system: choose "Customize" in the install-dialogue, check "X11".<br />
<br />
On an already installed system: download at<br />
: http://www.apple.com/downloads/macosx/apple/x11formacosx.html<br />
<br />
In the Terminal, run<br />
sudo fink install gdk-pixbuf gtk+ gtk+-data gtk+-shlibs gtk-doc gtkglarea gtk-engines<br />
The X11-Application is in /Applications/Utilities/X11.<br />
<br />
Hint: Most X11 programs, including lazarus expect to receive focus, when the users clicks on a window. Under MacOSX this is deactivated. You can activate it for all X11 applications by typing in the terminal:<br />
defaults write com.apple.x11 wm_click_through -bool true<br />
<br />
;Free Pascal Compiler:<br />
Then download and install the Free Pascal Compiler (at least 1.9.5 from 16th August 2004) from<br />
: https://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
When compiling gtk-related software, you need to add two lines to the fpc.cfg file, to enable use of libraries<br />
-Fl/sw/lib<br />
-Fl/usr/X11R6/lib<br />
<br />
<br />
For lazarus you need the fpc sources as well (obsolete: use svn):<br />
Create a directory, where you would like to put the sources. You don't need to be root to do this. Any normal user can do this. <br />
First create a directory for fpc <br />
: (e.g. /Users/username/freepascal) <br />
then open a terminal and do the following:<br />
[]$ bash<br />
[]$ export CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
[]$ cvs login<br />
password is 'cvs' without the 'quotes'<br />
[]$ cvs -z3 co fpc<br />
This will create a directory called 'fpc', which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
[]$ cd /Users/username/freepascal/fpc<br />
[]$ cvs -z3 update -dP<br />
<br />
==Installing Lazarus==<br />
<br />
===Installing Lazarus under Linux===<br />
====Installing using rpms====<br />
The easiest way to get a current working installation of Lazarus is to download the RPMs for FreePascal and Lazarus from the SourceForge repository.<br />
<br />
You need to download the selected version of<br />
* the compiler (eg fpc-1.9.5-041207.i386.rpm)<br />
* the pascal source library (eg fpcsrc-1.9.5-041207.i386.rpm)<br />
* the Lazarus package (eg lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm).<br />
<br />
You then issue the following commands (you need to have root privileges - use su or sudo)<br />
rpm -Uvh fpc-1.9.5-041207.i386.rpm<br />
rpm -Uvh fpcsrc-1.9.5-041207.i386.rpm<br />
rpm -Uvh lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm<br />
<br />
====Installing from source====<br />
If you prefer to install from source and compile the files yourself, follow these instructions. Because the whole lazarus stuff is installed into one directory, uninstall is very easy and you don't need to be root to install lazarus. You can get tgz files for fpc, fpcsrc and lazarus from the downloads section or you can download it directly via svn.<br />
<br />
=====Downloading Lazarus SVN=====<br />
<br />
The lazarus repository has moved from cvs to svn (Subversion). SVN provides an easy way to update your sources by only downloading the changes. This is the recommended way and saves you a lot of time. A connection to the internet is needed for this: you don't need to be root. Lazarus does not need any special permissions, neither during installation nor at runtime.<br />
<br />
With the move we also changed the directory layout of the lazarus sources. The main difference<br />
is that all ide sources are moved from the root to a separate ide subdir. As anybody might understand, this has an impact on the Makefiles, the searchpaths etc. We are in progress of fixing things, so if something doesn't work, please let us know.<br />
<br />
;Now the most important thing.... getting the sources:<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk/ lazarus<br />
(or any other dir where you want to place your sources)<br />
<br />
On subsequent occasions, to update simply type<br />
<br />
[]$ svn update lazarus<br />
<br />
For more information on Subversion, see:<br />
http://subversion.tigris.org/<br />
<br />
Note: the CVS is still accessable, but it frozen. This means<br />
that no new updates are comitted.<br />
<br />
=====Compiling and running=====<br />
Whether you checkout from cvs or svn, the next step is: <br />
<br />
;compile lazarus:<br />
[]$ cd lazarus<br />
[]$ make (gmake on BSD)<br />
<br />
<br />
If fpc is installed correctly, the compilation should work without problems. If not, see FAQ.<br />
<br />
;Start lazarus<br />
[]$ ./lazarus<br />
<br />
The IDE should start. If you started lazarus in a terminal, you can see some notes about missing settings. This is normal at first start. The IDE automatically tries to find out where the freepascal compiler and its sources are installed by searching in the most common directories.<br />
<br />
;Check the paths:<br />
: Use the IDE menu to go to<br />
:: Environment -> Environment Options -> Files<br />
<br />
The 'FPC Source directory' should point to your fpc source directory. This directory normally ends with /fpc/ or /fpcsrc/ (e.g. /usr/src/fpcsrc or /home/username/freepascal/fpc) and contains directories like 'compiler', 'docs', 'fcl', 'rtl' and 'packages'.<br />
<br />
''ToDo: explain the other paths''<br />
<br />
;Hint:<br />
To update lazarus you can use<br />
[]$ svn update lazarus<br />
then for either update pathway:<br />
[]$ make clean all (gmake on BSD)<br />
This will rebuild lazarus and create an IDE without lazarus packages. To link your installed packages do '''after''' the above:<br />
[]$ make idepkg<br />
<br />
====Installing Lazarus under Debian GNU/Linux====<br />
<br />
There are preliminary Debian packages for lazarus available for download. Make sure you read /usr/share/doc/lazarus/README.Debian carefully before you start using it. Feedback is needed and appreciated; please send your comments to Carlos Laviola <claviola@debian.org>.<br />
<br />
====Another (?easier) way to install Lazarus under Debian====<br />
Added by [[User:Kirkpatc]].<br />
<br />
;Simple Lazarus Installation in Debian<br />
(assume new Debian installation, without development libraries loaded)<br />
<br />
From sourceforge repository, download latest fpc, fpclib and lazarus releases; follow links from http://lazarus.freepascal.org, click the "downloads" button on the left, then click on "binaries" then "linux" then "Current Lazarus RPM". This will bring you to <br />
: http://sourceforge.net/project/showfiles.php?group_id=89339<br />
then download the following files (or more recent, if available)<br />
* fpc-2.0.0-0.i586.rpm<br />
* fpcsrc-2.0.0-0.i386.rpm<br />
* lazarus-0.9.8-fpc_2.0.0_0.i386.rpm<br />
cd to the directory where these files are stored, then become root (su) and type:<br />
<br />
alien fpc* //this will convert both the fpc and fpcsrc files to debian format<br />
alien laz*<br />
then install the generated Debian (.deb) packages by (as root):<br />
<br />
dpkg -i fpc*.deb laz*.deb<br />
or use kpackage or a similar utility to install the generated fpc, fpcsrc and lazarus .deb files.<br />
<br />
Note, if you do not have alien type:<br />
<br />
apt-get install alien<br />
<br />
You need to produce a configuration file, which will reside in /etc/fpc.cfg. Still as root, cd to the main fpc directory /usr/lib/fpc/2.0.0 and then type<br />
sh ./samplecfg /usr/lib/fpc/2.0.0 /etc<br />
Check the contents of your new configuration file (cat /etc/fpc.cfg) and make any changes you want using vi or another text editor. Also make sure that there are no old configuration files in for example your home directory (~/.fpc.cfg).<br />
<br />
You need to install the development packages of the GTK and pixbuf libraries, so<br />
apt-get install libgtk2.0-dev<br />
apt-get install libgdk-pixbuf-dev<br />
Then you should be ready to start programming!<br />
<br />
===Installing Lazarus under Mac OS X===<br />
<br />
Works pretty much the same as under Linux. But you need to install first the apple developer tools and X11.<br />
<br />
Snapshots are available at http://www.de.freepascal.org/lazarus/.<br />
<br />
If you want to experiment and develop the carbon widgetset interface, look at [[Installing Carbon on OSX]].<br />
<br />
===Installing Lazarus under Windows===<br />
<br />
The current releases of the Windows Lazarus binary packages install very easily, and should work 'out-of-the-box'. <br />
<br />
It is even possible to install the whole Lazarus/FPC package on a portable USB drive (capacity at least 256 MB), for use in environments where you are not allowed to install software on your Windows workstation or where you haven't got administrator privileges. You do have to be a little careful about adjusting the paths in the compiler and environment options and the fpc.cfg file. It may also be necessary to keep the directory for test compilation on your portable drive. << DOES ANYONE KNOW HOW TO SET UP RELATIVE PATHS IN THESE TAGS AND FILES, SO THAT THE ADDRESSING WORKS WHEN YOU MOVE THE USB DEVICE TO ANOTHER MACHINE WHERE IT HAS A DIFFERENT DRIVE LETTER? >><br />
<br />
The binary package is available for Linux and Windows from<br />
<br />
http://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
Download the latest release (currently Lazarus-0.9.6-20050225-win32.exe) and launch the application. You will be taken through a typical Windows installation, in which the FPC compiler and source libraries are installed within the same directory structure as Lazarus, and the IDE should launch and operate without significant problems, provided you have uninstalled any previous version of Lazarus and/or FPC (often found in the C:\pp directory).<br />
<br />
You can also get a Lazarus Snapshot for Windows at: http://www.de.freepascal.org/lazarus/<br />
<br />
====Installing from source====<br />
If you prefer to install from sources, then follow these instructions (Thanks to Joe for the initial Step-by-step description)<br />
<br />
You have to download the lazarus source:<br />
: http://www.de.freepascal.org/lazarus/<br />
<br />
Then unzip it to c:\lazarus for example. You have to install at least fpc-2.0.0, but a fpc-2.0.1 or fpc 2.1.1 snapshot is also possible. It compiles for me, and lazarus.exe works. The path to my fpc is: c:\pp\bin\win32. In this directory you can find a lot of exe (make, grep, ppc386, and so on).<br />
<br />
Open a command line. Start->Run...>command or choose MS-DOS icon.<br />
<br />
Type:<br />
cd c:\lazarus<br />
set path=c:\pp\bin\win32;c:\lazarus //of course change the first to<br />
//the path of yours<br />
windres -i lazarus.rc -o lazarus.res<br />
make<br />
<br />
If you are lucky then you can type: lazarus.exe. The source editor, dialogs and the property editor work, but not perfectly... Look and you will see.<br />
<br />
You can compile examples also:<br />
<br />
cd examples<br />
make<br />
<br />
If you extracted lazarus to another drive, eg.: d:\lazarus. It can happen that you need the gnu utility to make it. If you have it, you can take its path to set path=...;<gmakepath> but it is simpler not to choose drive d:\<br />
<br />
That's all.<br />
<br />
=== Additional experiences and advice on installing FPC and Lazarus ===<br />
On linux, getting Lazarus to work can be complicated. If you have already installed earlier versions of FPC and/or Lazarus, you have to take great care that the PATHS are adjusted so that only your new versions are called.<br />
<br />
Pitfalls that I have experienced in various attempts with SuSE linux include:<br />
<br />
The rpm versions often install FPC in /bin or /usr/bin, with the libraries in /lib or /usr/lib.<br />
<br />
If you perform a make install on a source version or use a .tar.gz, the compiler is usually installed in /usr/local/bin with the libraries in /usr/local/lib.<br />
<br />
So if earlier versions have been installed from rpm, make sure all links are changed to reflect the directory structure of your new compiler. The place to make the changes is in /etc/fpc.cfg ; make sure there are no remnant configuration files in your home directory or in your FPC download directory. Typically they are found in ~/.fpc.cfg<br />
<br />
Make sure the links in /etc/fpc.cfg point to the correct versions of the libraries (particularly if you have older versions still lurking around).<br />
<br />
In /usr/local/bin or /usr/bin there is a file called fpc ; this is the executable that is called when you invoke the compiler. One of the first things it does is to open ppc386 in the same directory. This has to be the same version as the fpc file, or can be a link pointing to the true ppc386 in some other directory (such as a library directory, or the fpc directory in your own development space); be sure to update your link if you install a newer version of the compiler.<br />
<br />
Try running the compiler from the command line using one of the simple example programs or one which you wrote yourself.<br />
<br />
Turning to Lazarus:<br />
<br />
If you use a downloaded snapshot (.tar.gz) or get the source from CVS, enter your lazarus directory and type<br />
<br />
make<br />
./lazarus <br />
<br />
and hopefully the IDE should load. There may be a message saying it can't find the sources; if so, go to the menu at the top and select Environment -> Environment options and insert the name of the directory where you expect to find your lazarus files (eg ~/FreePascal/lazarus), your compiler (eg /usr/local/bin/ppc386), the FreePascal source directory (eg /usr/local/lib/fpc/$version/fpc or a directory in your own space eg ~/FreePascal/fpc). Then close the dialog and start programming.<br />
<br />
You may find further problems when you start programming or compiling; most of these will be related to PATH selection.<br />
<br />
Many of the difficulties are dealt with in the Lazarus FAQ, found either on this WiKi site, or a more complete list on the main Lazarus site<br />
<br />
http://www.lazarus.freepascal.org/modules.php?op=modload&name=FAQ&file=index<br />
<br />
From the top menu select Run -> Compiler Options (or Project -> Compiler Options in more recent releases of Lazarus) and select the Paths tab on the resulting dialog. There are several boxes for entry of paths for Unit files, Include files, Other source files, Libraries etc. For each of these, it is worth pressing the ... (ellipsis) button on the right, and you will be given a blank window for inserting path information, and a lower window giving some suggestions. Select as many as you like (or ALL!) and press the ADD button to transfer the selections to the upper window. When your selection is complete, press OK and move on to the next box. If you know of other paths which need to be followed, press the Browse button associated with each box, and insert the additional paths.<br />
<br />
When you think you have got your paths right, try to compile your application. If there are further path-related errors ('can't find unit .......') then go back and check your paths, both in /etc/fpc.cfg and in your Run -> Compiler Options dialog (or Project -> Compiler Options depending on your version).<br />
<br />
Once you have got the environment and PATHS correct, it is worth saving the settings to a file, otherwise you will have to go through this process for each new project. In the Run -> Compiler options dialog there is a Load/Save button; select this and then save the setings to the filename of your choice: mine is ~/FreePascal/default.cfg. Then each time I start a new project, I can go to the Run -> Compiler Options dialog (or Project -> Compiler Options), select Load/Save, and load my default.cfg file to the new project. You can, of course, modify the options for each new project if you so desire.<br />
<br />
===Installing Lazarus under BSD===<br />
<br />
Please write me!<br />
<br />
==Contribuições Originais e Mudanças==<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=InstallingLazarus version].<br />
* Iniciada a tradução para o português [[User:fititnt | fititnt]] 20/11/2005<br />
* Initially imported and formatted. [[User:Tom | VlxAdmin]] 9/22/2003<br />
* Changed Joe's part for Windows to require fpc 1.0.10. [[User:Vincent | Vincent]] 9/25/2003<br />
* Updated "What is required for lazarus". AndrewJohnson 10/1/2003<br />
* Finished formatted the InstallingLazarus page [[User:Tom | VlxAdmin]] 2/22/2004<br />
* Posted some notes about Installing FPC and Lazarus: mostly reflecting experiences in trying to get the PATHS right in Linux. 3/11/2004 [[User:Kirkpatc]]<br />
* Copied the contents of my note into the main InstallingLazarus section, edited it slightly. I don't know how to remove the original note. 3/12/2004 [[User:Kirkpatc]]<br />
* Removed the original note. Tidied the wiki and formatting a bit. [[User:Tom | VlxAdmin]]<br />
* Corrected a couple of typos - 3/12/2004 [[User:Kirkpatc]]<br />
* Added link for daily snapshot deb packages - 3/27/2004 [[User:Vincent | Vincent]]<br />
* Fixed links in GettingLazarus (downloading binaries) and several other pages. 22 July 2004 [[User:Kirkpatc]]<br />
* Added link for lazarus deb packages - 19 August 2004 VincentSnijders<br />
* Added a short note on installing in Debian - 23 Nov 2004 [[User:Kirkpatc]]<br />
* Considerable re-write and re-organization of installation section - 11 Dec 2004 [[User:Kirkpatc]]<br />
* Fixed broken link - 9 Oct 2005 [[User:Avantman42]]</div>Fititnthttps://wiki.freepascal.org/index.php?title=Code_Conversion_Guide/pt&diff=6337Code Conversion Guide/pt2005-11-21T00:11:38Z<p>Fititnt: /* Where to find code to convert */</p>
<hr />
<div>Guia de conversão do Delphi para o Lazarus <br />
<br />
== Sobre ==<br />
<br />
Esta página é sobre como converter um código para poder usá-lo no compilador [[Free Pascal]] e a IDE do Lazarus. O Lazarus e o Free Pascal tem aspectos em comum com o Delphi e Kylix, porém, não são clones. há várias diferenças nos códigos e convenções... e em algumas áreas, o FPC pode exigir uma sintaxe mais correta. Por favor veja o [[Lazarus For Delphi Users]] guia para uma descrição de algumas das diferenças funcionais. <br />
<br />
O propósito deste guia é documentar algumas das diferenças específicas que freqüentemente são encontradas durante o processo de conversão de código ao traduzir código existente de Delphi para Lazarus. <br />
<br />
Este documento foi colocado na área de conhecimento-base de wiki para que assim pudesse ser estendido facilmente por qualquer um que tenha encontrado um problema sem igual e gostaria de postar isto para outros estarem atentos<br />
<br />
== Selecting a component or library for conversion ==<br />
<br />
=== Onde achar conteúdo para converter ===<br />
<br />
Há MUITOS códigos possíveis na internet de serem convertidos para serem usados com o FPC e o Lazarus. Aqui tem uma [[Page Of Code Sites]] por onde você pode começar. Por favor adicione outro link se encontrar algum outro local. TurboPower Software recentemente seus produtos comerciais sob a MPL. Uma lista de packages disponíveis pode ser encontrado em [http://sourceforge.net/users/tpsfadmin/ aqui]<br />
<br />
<br />
Para evitar retrabalho, packages que foram convertitas estão listadas em [[Components and Code examples]] Se voce converteu uma packageou está convertendo, por favor adicione uma nota na pagina [[Current conversion projects]]<br />
<br />
=== Licensing ===<br />
<br />
Licenses for existing code range from freeware/public domain to restrictive versions that prohibit modification, re-distribution and commercial use. Before converting any package, it's a good idea to examine its licensing and make sure it's going to be compatible with Lazarus and the Free Pascal Compiler. License selection is especially important with components since dropping one on a form can impose an unwanted or incompatible license on an entire application.<br />
<br />
When converting components, please respect the wishes of the original author and retain all copyright and licensing headers along with email addresses and url's. It's courteous and often useful to inform the author that their component is being converted... especially if the component is under a restrictive license. New interest in an old or forgotten component can sometimes inspire authors to revise their original and overly restrictive licensing.<br />
<br />
In general, Public Domain (freeware), and the LGPL/MPL are the the most flexible for distributing components. For more information, the [http://www.opensource.org/docs/definition.php Open Source Definition] is a good place to start. There are also several comparisons available to help clarify how the various types of licenses work and what impact they'll have on code they're linked to. Search for "open source license comparison"<br />
<br />
=== Dependencies ===<br />
<br />
Another step before starting to work on a conversion is to verify that the code doesn't have deep dependancies on other packages that might not be available or represent a considerable conversion challenge. Some freeware offerings are bound to or extend proprietary packages that are frequently no longer available or come with inappropriate licenses.<br />
<br />
=== Compiler Issues ===<br />
<br />
Currently the stable 1.0.x version of the [[Free Pascal]] Compiler doesn't support interfaces, threads or Variant records. If the code you're converting needs these constructs, you'll have to use the 1.1 development branch of the compiler... which isn't always guaranteed to work with Lazarus.<br />
<br />
See also:<br />
* [http://www.freepascal.org/probs.html Known problems]<br />
* [http://www.freepascal.org/bugs/db.php3?statusfield=Unfixed Unfixed bugs]<br />
<br />
=== SO e problemas de plataforma ===<br />
<br />
Lazarus e o compilador Free Pascal são cross-platform e ferramentas de desenvolvimento para serem usadas também em vários sistemas operacionais. Em contraste, a maioria dos códigos escritos em Delphi são especificamente escritos para rodar em um processador Intel sob Win32. Se o seu canditado a componente possui muito código específico da plataforma Win32, seria sábio procurar uma alternativa independente da plataforma. Mas não desista... é verdadeiramente incrível o suporte LCL.<br />
<br />
== Fazendo a conversão ==<br />
<br />
=== Montando o ambiente de Lazarus para um projeto de conversão ===<br />
<br />
====Crie um projeto teste====<br />
* Coloque o código a ser convertido em um subdiretório (ie: convertdir) <br />
* Abra-o com o Lazarus <br />
* File->Save All para o subdiretório de convertdir. Meaningful names for the Project and default unit are optional. <br />
* Open the "main" unit to be converted in convertdir * Add it to the project: Project->Add Active Unit to Project * Run Tools->Quick Syntax Check or Run Build All to get started. <br />
* Run Tools->Quick Syntax Check or Run Build All to get started.<br />
====Termos iniciais para se cuidar====<br />
* Nomes de arquivos são sensíveis ao letras maiúsculas e minúsculas nos compiladores da série 1.0.x Se você estiver trabalhando com uma versão como essa, faça com que todos os seus arquivos sejam escritos em minúsculas, pois do contrário, você terá como frase de erro "File not found" - arquivo não encontrado.<br />
====Fontes Delphi VCL, Kylix CLX no Lazarus====<br />
<br />
Ao converter fontes de Delphi/Kylix, é freqüentemente útil fazer uma declaração sobre o que uma função específica está fazendo. A IDE Lazarus pode analisar as fontes de Delphi/Kylix. Para isto, é necessário indicar o local dos arquivos para o compilador. Pode-se conseguir isso através do menu Environment->CodeTools Defines Editor->Insert Template<br />
<br />
=== Problemas de conversão e soluções ===<br />
<br />
==== Arquivos Delphi / Kylix equivalentes no Lazarus ====<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi / Kylix || class="header" | Lazarus || class="header" | Descrição<br />
|- class="code"<br />
| class="code" |.pas<br />
.dfm / .xfm<br />
.dcu / .dpu<br />
.dpr<br />
.res<br />
.dof / .kof<br />
---<br />
---<br />
---<br />
| class="code" |.pas, .pp<br />
.lfm<br />
.o<br />
.lpr<br />
---<br />
---<br />
.lrs<br />
.lpi<br />
.ppu<br />
| class="code" |Arquivo unit de Pascal<br />
Arquivos de dados do form<br />
Arquivo da unit compilada<br />
Arquivo do Projeto<br />
Arquivo de recursos<br />
Arquivo de opções do projeto<br />
Arquivo de recursos do Lazarus<br />
Arquivo de informações do projeto<br />
Arquivo de descrição de unit FPC<br />
|}<br />
<br />
==== Contentendo projetos/forms/units Delphi para Lazarus ====<br />
<br />
Renomeie ou copie o arquivo .dpr para um arquivo .lpr. Comente ou remova a diretiva <div class="dir">{$R *.res}</div> e adicione <div class="dir">{$mode delphi}{$H+}</div> ou <div class="dir">{$mode objfpc}{$H+}</div> no arquivo .lpr. A IDE do Lazarus pode através do menu Tools no item "Convert Delphi Project to Lazarus Project". Ele solicita um arquivo .dpr (Delphi Project) e o converte para um .lpr; mais tarde, também cria um .lpi.<br />
<br />
Existe várias maneiras de converter forms do Delphi através da IDE do Lazarus que realiza o trabalho da conversão do .dfm para o .lfm. Isso pode ser encontrado como item do menu Tools com o sob o nome "Convert DFM file to LFM". Clique nele, e na caixa de dialogo escolha seu arquivo .dmf e o conversor fará o resto.<br />
<br />
Se você precisa converter a unit inteira (com ou sem uma form), o Lazarus também inclui a opção de converter uma unit Delphi para uma Unit Lazarus, através do item "Convert Delphi unit to Lazarus unit" que fará o seguinte:<br />
<br />
# renomeia os arquivos .pas and .dfm para minúsculas.<br />
# converte .dfm para .lfm file (atualmente sem a verificação da validade do conteúdo; somente o formato)<br />
# cria um arquivo .lrs vazio (o conteúdo será adicionado mais tarde)<br />
# adiciona a diretiva <div class="dir">{$mode delphi}</div><br />
# substitui as unidades Windows por LCLIntf<br />
# adiociona units LResources se necessário (i.e., se o unit.lrs for usado; <div class="dir">o uso de LResources </div> pode ser implementado a parte)<br />
# remove variáveis da unit<br />
# remove a diretiva <div class="dir">{$R *.dfm}</div><br />
# adiciona a seção de inicialização e a diretiva <div class="dir">{$i unit.lrs}</div><br />
<br />
<br />
Isto permite rapidamente e conversão fácil da maioria das unidades de Delphi ao formato do Lazarus. Não checa a validade, ou muda a sintaxe automática, assim qualquer mudança na sintaxe que você precisa fazer, mudanças adicionais nos nomes das unit/unit , or dfm/pas changes for control/component differences you must still do manually, though in time some wizards to help facilitate some of this, especially the repairing of converted forms(lfm), may become available.<br />
<br />
==== Selecting the right compiler mode ====<br />
<br />
The [[Free Pascal]] Compiler supports 5 different pascal modes. For example TP for turbo pascal, lets you compile turbo pascal units. There is also a DELPHI compatibility mode that can be set to make existing code easier to convert. Lazarus prefers the OBJFPC mode, which almost equals the DELPHI mode, but is less ambigious than the Delphi syntax. Here are the important points:<br />
<br />
The mode can be selected at command line or at the start of the source. Using the command line has the advantage, that you don't need to change the source, but the disadvantage, that others must be told.<br />
<br />
Most Delphi units can be compiled by the [[Free Pascal]] compiler by adding <br />
{$IFDEF FPC}<br />
{$MODE DELPHI}<br />
{$ENDIF}<br />
right after the unit name.<br />
<br />
For more details about [[Free Pascal]] modes see the [http://www.freepascal.org/docs-html/prog/progap4.html#progse62.html Free Pascal Documentation]<br />
<br />
==== Cross-Platform considerations ====<br />
<br />
* Inline assembler is always a problem because it will bind the code to the Intel architecture. Some developers do algorithm prototypes in Pascal and ifdef the their optimized assembler. Fortunately TurboPower did this in numerous places with their code. If this is the case with the package you're converting, throw the switch back to Pascal.<br />
* Don't reference specific memory location like the BIOS data area. Find out what the code needs and try to find a cross platform alternative.<br />
* Don't do processor specific tricks (like using the Intel TSC) without enclosing your code in an ifdef for the platform the code needs... and providing an alternative for environments that don't have the hardware capability.<br />
* If you need some OS specific code, then you can use IFDEFs. See below for a list of macros.<br />
<br />
==== Useful compiler variables ====<br />
<br />
To write code, that behaves on different systems differently, you can use the <div class="dir">{$IFDEF Name}</div> directives.<br />
<br />
* <div class="dir">{$IfDef LCL}</div><br />
This variable is defined, when using the LCL package. Useful to write code, that works with the LCL and Delphi.<br />
* <div class="dir">{$IfDef FPC}</div><br />
This variable is defined, when using the FPC compiler. Useful to write code, that works with FPC and Delphi.<br />
* <div class="dir">{$IfDef Unix}</div>, <div class="dir">{$IfDef Win32}</div>, ...<br />
Defined by FPC for the current Target OS. Delphi defines "Linux", "Win32" and "MSWindows". [[Free Pascal]] runs on much more platforms and so it is recommended to use the more general items. For example "Unix" is defined for Linux, FreeBSD, NetBSD and OpenBSD, where Lazarus already runs.<br />
Use<br />
{$IfDef Linux}<br />
{$Define Unix}<br />
{$EndIf}<br />
to work around this for Kylix.<br />
<br />
For more details see the [http://www.freepascal.org/docs-html/prog/prog.html#QQ2-23-21 Free Pascal Documentation].<br />
<br />
==== Finding a missing identifier ====<br />
<br />
There are differences in how the LCL is organized when compared to the Delphi VCL. If you get a "not found" compiler error about a major class or identifier, the chances are good that it's in a different unit. A complete cross reference can be found by grep'ing lazarus/docs/xml or the lcl subdirectory.<br />
<br />
For example the commonly used tbutton typically throws an error in Delphi code because it's located in a unit named buttons.pp. The following command finds the correct unit very quickly (in the lazarus source directory):<br />
<br />
grep -in ' tbutton =' lcl/*<br />
<br />
<br />
==== Major unit differences between Lazarus and Delphi ====<br />
<br />
** Please add to this topic! **<br />
<br />
* Windows->Interfaces, LCLIntf, LCLType, LCLProc, VCLGlobals, ...)<br />
<br />
As the LCL is not windows specific, the code that is in the Delphi Windows unit for directly accessing the Win32 API is abstracted into seperate interfaces, which can be accessed from the LCLIntf unit. Keep in mind, that Lazarus does not emulate win32, so many functions are missing and some do not work as their win32 counterparts. These functions only exist for Delphi compatibility and should only be used for quick & dirty porting. LCL also breaks out many of the types, so often LCLType, and sometimes VCLGlobals are required. LCLProc also contains a few functions which can be useful for lower level handling such as "FreeThenNil" as is in Delphi 5 and higher, "DeleteAmpersands" to remove additional ampersands from a string for controls(& vs && etc). The Interfaces unit needs to be included in the .lpr file to initialize the appropriate widgetset.<br />
<br />
* Messages->LMessages<br />
<br />
TControl Messages for win32 event callbacks of the format WM_CALLBACK and the structs associated with them are often found in the Messages unit in Delphi. In the LCL these types of messages and there structs are usually found in LMessages, usually with name changes of WM to LM, so for instance WM_MOUSEENTER becomes LM_MOUSEENTER, and TWMMouse becomes TLMMouse.<br />
<br />
* Graphics, Controls->GraphTypes, GraphMath, Graphics, Controls<br />
<br />
To simplify some things and break complexity of circles between units, a few types have been abstracted into a shared unit called GraphType, which includes things, which in Delphi are located in Graphics or Controls, for instance the bvNone etc of panels. So sometimes you have to include it. Also a unit which, although incompatible with Delphi, adds other useful functionality is GraphMath, which adds a TFloatPoint for precision, misc routines for dealing with beziers, lines, and arcs, as well as some operator overloading for use with TPoints and TRect, such as for instance Point1 := Point2 + Point3, and comparing two rects like if (rect1 = rect2) then ...<br />
<br />
* Mask->MaskEdit<br />
<br />
For more intelligent naming considerations, the unit for TMaskEdit is called [MaskEdit|] instead of the slightly more nebulous Mask as in many versions of Delphi.<br />
<br />
* StdCtrls->StdCtrls,Buttons<br />
<br />
In many version of Delphi TButton is located in StdCtrls, while TSpeedButton and TBitBtn are in Buttons. For consistency and simplicity the LCL puts all button types in Buttons, which can occasionally break code conversion, so it is always a good idea to include.<br />
<br />
==== Property and method differences Delphi -> FPC/LCL ====<br />
* TBitmap contains a canvas in the LCL<br />
==== Syntax differences ====<br />
<br />
'''Please add to this topic!'''<br />
<br />
Because of the inherent strictness in FPC, some syntax changes are necessary, even though <div class="dir">{$Mode Delphi}</div> does allow more laziness like Delphi does. For this reason complying as much with the syntax rules of <div class="dir">{$Mode ObjFPC}</div> as possible is highly recommended, even when the codebase is still going to be shared between Delphi and the LCL. Some of these are simply better coding practices, and sometimes because Delphi mode is not entirely accurate, or in a few instances Delphi acceptible code does not function as expected with FPC, even though it might compile. To that end even though not all such are strictly required, the following list of changes should be considered mandatory :<br />
<br />
<br />
;When assigning an event handling entry point, prefix it with an "@"<br />
<br />
For instance, you might assign a button callback manually <br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">begin</div> <br />
<div class="key">if not</div> Assigned(MyButton.OnClick) <div class="key">then</div><br />
MyButton.OnClick:= SomeFunction; <div class="cmt">//@ not required</div><br />
<div class="cmt">//more code...</div><br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">begin</div><br />
<div class="key">if not</div> Assigned(MyButton.OnClick) <div class="key">then</div><br />
MyButton.OnClick:= @SomeFunction; <div class="cmt">//@ IS required</div><br />
<div class="cmt">//more code...</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
;When calling a procedure variable use this syntax: theprocname()<br />
<br />
In Delphi there is no difference between a function result and a variable, however there is in FPC, so to call a function, even if it has no parameters, you must append parenthesis. For Example -<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">With</div> (SomeObject) <div class="key">do begin</div> <br />
<div class="key">If</div> Assigned(OnMyCallback) <div class="key">then</div> <br />
OnMyCallback; <div class="cmt">//parenthesis not required</div> <br />
<div class="key">end</div>; <br />
| class="code" | <div class="key">With</div> (SomeObject) <div class="key">do begin</div><br />
<div class="key">If</div> Assigned(OnMyCallback) <div class="key">then</div><br />
OnMyCallback(); <div class="cmt">//parenthesis required</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
;When accessing values in a pointer to a record you must dereference first<br />
<br />
In Delphi it is not required to de-reference a pointer to a record to access values within it, it can, in fact, be treated just like the record itself, or any other object. In FPC it must be first de-referenced. As an example,<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">Function</div> GetSomeValue(ARecord: PMyRecord) <br />
<div class="symbol">:</div> Integer;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Assigned(ARecord) <div class="key">then</div><br />
Result<div class="symbol">:=</div> ARecord.SomeValue<br />
<div class="key">else</div><br />
Result:= <div class="int">0</div>;<br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">Function</div> GetSomeValue(ARecord: PMyRecord) <br />
<div class="symbol">:</div> Integer;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Assigned(ARecord) <div class="key">then</div><br />
Result<div class="symbol">:=</div> ARecord^.SomeValue<br />
<div class="key">else</div><br />
Result:= <div class="int">0</div>;<br />
<div class="key">end</div>; <br />
|}<br />
<br />
;When accessing chars of an indexed string Property of an object, it must be enclosed in parentheses<br />
<br />
With Delphi it is possible to treat a Property exactly like some other const or var, even to accessing for instance individual chars of a string directly, while this is not always possible in FPC, specifically for indexed properties. Instead it must be enclosed in parentheses, to make distinct. While this may not always hold true it is probably a good practice to consider anyway. For example<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
<div class="key">Property</div> MyString: <div class="key">String</div> <div class="key">index</div> <div class="int">3</div><br />
<div class="key">read</div> GetMyString;<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">var</div><br />
MyChar<div class="symbol">:</div> char;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Length(MyString)> <div class="int">2</div> <div class="key">then</div><br />
<div class="cmt">//no parenthesis needed</div><br />
MyChar:= MyString[<div class="int">3</div>];<br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
<div class="key">Property</div> MyString: <div class="key">String</div> <div class="key">index</div> <div class="int">3</div><br />
<div class="key">read</div> GetMyString;<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">var</div><br />
MyChar<div class="symbol">:</div> char;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Length(MyString)> <div class="int">2</div> <div class="key">then</div><br />
<div class="cmt">//parenthesis sometimes needed</div><br />
MyChar:= (MyString)[<div class="int">3</div>];<br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
<br />
;You must typecast pointers to actual type when using with var or function of that type<br />
<br />
Sometimes in Delphi you will have a null pointer variable representing an object. While it might seem a complex situation, it is oddly quite common especially in large component packs as a method of preventing too many circular includes between objects in different units. In Delphi it is then possible to send this null pointer to a function expecting that object, without bothering to typecast to actual type, in fpc you must typecast. <br />
<br />
For example -<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" |Unit 1<br />
<div class="key">Type</div> TSomeObject= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">Procedure</div> DoSomething(Value: TSomeObject);<br />
<div class="key">Function</div> GetSomeObject: TSomeObject;<br />
<div></div> <br />
<div class="symbol">Unit 2</div><br />
<div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
SomeObject: Pointer<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div><br />
<div class="symbol">Application</div><br />
<div class="key">var</div><br />
MyComponent: TSomeComponent<div class="symbol">;</div><br />
<div class="key">begin</div><br />
MyComponent.SomeObject<div class="symbol">:=</div> GetSomeObject;<br />
<div class="cmt">//More code...</div><br />
DoSomething(MyComponent.SomeObject)<div class="symbol">;</div><br />
<div class="key">end</div>;<br />
| class="code" |Unit 1<br />
<div class="key">Type</div> TSomeObject= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">Procedure</div> DoSomething(Value: TSomeObject);<br />
<div class="key">Function</div> GetSomeObject: TSomeObject;<br />
<div></div> <br />
<div class="symbol">Unit 2</div><br />
<div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
SomeObject: Pointer<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="symbol">Application</div> <br />
<div class="key">var</div><br />
MyComponent: TSomeComponent<div class="symbol">;</div><br />
<div class="key">begin</div><br />
MyComponent.SomeObject<div class="symbol">:=</div> Pointer(GetSomeObject);<br />
<div class="cmt">//More code...</div><br />
DoSomething(TSomeObject(MyComponent.SomeObject))<div class="symbol">;</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
==== Resources ====<br />
<br />
Delphi resource files are win32 specific and not compatible with Lazarus, so you'll have to recreate and compile them using the lazres. Lazres can be found in the lazarus/tools subdirectory. If you've downloaded the Lazarus sources, you'll need to compile it first.<br />
* cd lazarus/tools<br />
* make install<br />
To add a resource to your application:<br />
* lazres myresource.lrs mypix.xpm anotherpix.xpm<br />
* Add the LResources unit to your Uses clause<br />
* Include the .lrs file you created under the initialization block<br />
Example:<br />
{| class="code" <br />
|- class="code"<br />
| class="code" | <div class="key">function</div> TForm1.LoadGlyph(<div class="key">const</div> GlyphName: <div class="key">String</div>): TBitMap;<br />
<div class="key">begin</div><br />
Result:= TPixmap.Create<div class="symbol">;</div><br />
Result.LoadFromLazarusResource(GlyphName)<div class="symbol">;</div><br />
<div class="key">end</div>; <br />
<div class="cmt">//More code...</div><br />
<div class="key">begin</div><br />
Speedbutton1.glyph:= LoadGlyph('mypix')<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
<div></div> <br />
<div class="key">initialization</div><br />
<div class="dir">{$I unit1.lrs}</div><br />
<div class="dir">{$I myresource.lrs}</div><br />
<div class="key">end</div>.<br />
|}<br />
<br />
== Getting Help ==<br />
<br />
If you encounter a problem during conversion that you just can't solve, there are a wide variety of places to get help. For pure Object Pascal and FPC issues, the best place to start is the Free Pascal [http://www.freepascal.org/docs-html/ Documentation] by Michaël Van Canneyt and Florian Klämpfl. For more Lazarus oriented problems, the Lazarus Project Documentation in the Lazarus-CCR Knowledgebase [Main Page] is the next place to look. Finally you can post a question on any of the [http://www.freepascal.org/maillist.html mailing lists for the Free Pascal Compiler] or the [http://community.freepascal.org:10000/bboard/ FPC forums] where a lot of experts are subscribed.<br />
<br />
There are some outstanding search and knowledge bases online that can also be a great help for learning new techniques and solving problems. Tamarack Associates operates a fast [http://www.tamaracka.com/search.htm search] engine specifically for the Borland usenet archives. Mer Systems Inc. provides a similar search [http://www.mers.com/searchsite.html engine]. Another outstanding source of information along with a sitewide [http://www.efg2.com/Lab/search.htm search] capability is Earl F. Glynn's Computer Lab and Reference [http://www.efg2.com/ Library].<br />
<br />
== Packaging and Releasing your component ==<br />
<br />
=== Creating a Lazarus package for your component(s) ===<br />
<br />
Creating a package makes installing the code you've converted a much easier process... especially if you're providing more then one component. Mattias Gärtner has written an overview of [[Lazarus Packages]] that should be read before beginning this process.<br />
<br />
=== Documentation ===<br />
<br />
The purpose of this site and the wiki format is to make the generation of professional documentation an easy and quick process. The wiki also makes it possible to see the results of your posting immediately and make any changes you'd like in real time.<br />
<br />
Using the Lazarus-CCR wiki to create nice looking documentation is very easy. If you've never used wiki markup before, you can get familiar with it in the [[Sand Box]] practice area.<br />
<br />
=== Creating a Code Release Page ===<br />
<br />
The Code Release Page contains vital information about your component that a potential downloader will need to know, such as license, intended platform, status (alpha, beta, stable...), where to download it, who wrote it, is support available... etc.<br />
<br />
The following procedure will let you create a Code Release Page with your browser: <br />
<br />
* Edit the [[Components and Code examples]] page and add a project name wiki link entry for your component in the "Released Components" section. Save the modified page.<br />
<br />
* Go to the [[Component Release Template]], select all and copy. Hit the back button on your browser to return to the [[Components and Code examples]] page.<br />
* Click on your new wiki component name entry and paste the release template into the blank edit box.<br />
* Edit the template accordingly and hit save.<br />
* Do edit-saves until your document looks the way you want it to.<br />
<br />
=== Submitting the component ===<br />
<br />
If you're a release technician on the project, upload your component to the SourceForge File Release System and add it to the list of release packages. Otherwise send it to one of the project administrators ([[User:Tom | Tom Lisjac]] or [[User:Vincent | Vincent Snijders]]) and we'll add it to the repository. <br />
<br />
If you think you need to continue to develop on the component, we can also put it into CVS so you'll continue to have access to it.<br />
<br />
== Contributors and Changes ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=CodeConversionGuide version].<br />
* Initial version by Tom Lisjac and Mattias Gärtner - 9/22/2003 [[User:Tom | VlxAdmin]]<br />
* Moved Getting help from the main page. T. Lisjac - 9/24/2003 [[User:Tom | VlxAdmin]]<br />
* Added documentation templates, procedure and links. 9/25/2003 [[User:Tom | VlxAdmin]]<br />
* LCLLinux was renamed to LCLIntf, [[User:Jesusrmx | Jesus Reyes]], 9/27/2003<br />
* added more information on Unit changes, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* Updated Syntax differences, including some examples, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* FPC 1.0.x doesn't support interfaces, [[User:Vincent | Vincent Snijders]] 9/28/2003<br />
* Fixed some of the examples per new WikiWord definition, 9/28/2003 [[User:Tom | VlxAdmin]]<br />
* Made code more consistant to remove last accidental Pascal WikiWord definitions, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* Use tables for code examples for nice blocks, and easy side by side view of Delphi->FPC differences, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 10/17/2003<br />
* Use pascal stylesheet to make example code more readable, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 10/18/2003</div>Fititnthttps://wiki.freepascal.org/index.php?title=Code_Conversion_Guide/pt&diff=3810Code Conversion Guide/pt2005-11-20T23:17:44Z<p>Fititnt: /* Platform and OS Issues */</p>
<hr />
<div>Guia de conversão do Delphi para o Lazarus <br />
<br />
== Sobre ==<br />
<br />
Esta página é sobre como converter um código para poder usá-lo no compilador [[Free Pascal]] e a IDE do Lazarus. O Lazarus e o Free Pascal tem aspectos em comum com o Delphi e Kylix, porém, não são clones. há várias diferenças nos códigos e convenções... e em algumas áreas, o FPC pode exigir uma sintaxe mais correta. Por favor veja o [[Lazarus For Delphi Users]] guia para uma descrição de algumas das diferenças funcionais. <br />
<br />
O propósito deste guia é documentar algumas das diferenças específicas que freqüentemente são encontradas durante o processo de conversão de código ao traduzir código existente de Delphi para Lazarus. <br />
<br />
Este documento foi colocado na área de conhecimento-base de wiki para que assim pudesse ser estendido facilmente por qualquer um que tenha encontrado um problema sem igual e gostaria de postar isto para outros estarem atentos<br />
<br />
== Selecting a component or library for conversion ==<br />
<br />
=== Where to find code to convert ===<br />
<br />
There is a LOT of code available on the net that can be converted for use with FPC and Lazarus. Here is a [[Page Of Code Sites]] that is just a start. Please add to it if you know of any other good locations. TurboPower Software has recently released their entire commercial offering under the MPL. A list of available packages can be found [http://sourceforge.net/users/tpsfadmin/ here].<br />
<br />
To avoid duplicating effort, packages that have already been converted are listed on the [[Components and Code examples]] page. If you've converted a package or are working on one, please add a note on the [[Current conversion projects]] page.<br />
<br />
=== Licensing ===<br />
<br />
Licenses for existing code range from freeware/public domain to restrictive versions that prohibit modification, re-distribution and commercial use. Before converting any package, it's a good idea to examine its licensing and make sure it's going to be compatible with Lazarus and the Free Pascal Compiler. License selection is especially important with components since dropping one on a form can impose an unwanted or incompatible license on an entire application.<br />
<br />
When converting components, please respect the wishes of the original author and retain all copyright and licensing headers along with email addresses and url's. It's courteous and often useful to inform the author that their component is being converted... especially if the component is under a restrictive license. New interest in an old or forgotten component can sometimes inspire authors to revise their original and overly restrictive licensing.<br />
<br />
In general, Public Domain (freeware), and the LGPL/MPL are the the most flexible for distributing components. For more information, the [http://www.opensource.org/docs/definition.php Open Source Definition] is a good place to start. There are also several comparisons available to help clarify how the various types of licenses work and what impact they'll have on code they're linked to. Search for "open source license comparison"<br />
<br />
=== Dependencies ===<br />
<br />
Another step before starting to work on a conversion is to verify that the code doesn't have deep dependancies on other packages that might not be available or represent a considerable conversion challenge. Some freeware offerings are bound to or extend proprietary packages that are frequently no longer available or come with inappropriate licenses.<br />
<br />
=== Compiler Issues ===<br />
<br />
Currently the stable 1.0.x version of the [[Free Pascal]] Compiler doesn't support interfaces, threads or Variant records. If the code you're converting needs these constructs, you'll have to use the 1.1 development branch of the compiler... which isn't always guaranteed to work with Lazarus.<br />
<br />
See also:<br />
* [http://www.freepascal.org/probs.html Known problems]<br />
* [http://www.freepascal.org/bugs/db.php3?statusfield=Unfixed Unfixed bugs]<br />
<br />
=== SO e problemas de plataforma ===<br />
<br />
Lazarus e o compilador Free Pascal são cross-platform e ferramentas de desenvolvimento para serem usadas também em vários sistemas operacionais. Em contraste, a maioria dos códigos escritos em Delphi são especificamente escritos para rodar em um processador Intel sob Win32. Se o seu canditado a componente possui muito código específico da plataforma Win32, seria sábio procurar uma alternativa independente da plataforma. Mas não desista... é verdadeiramente incrível o suporte LCL.<br />
<br />
== Fazendo a conversão ==<br />
<br />
=== Montando o ambiente de Lazarus para um projeto de conversão ===<br />
<br />
====Crie um projeto teste====<br />
* Coloque o código a ser convertido em um subdiretório (ie: convertdir) <br />
* Abra-o com o Lazarus <br />
* File->Save All para o subdiretório de convertdir. Meaningful names for the Project and default unit are optional. <br />
* Open the "main" unit to be converted in convertdir * Add it to the project: Project->Add Active Unit to Project * Run Tools->Quick Syntax Check or Run Build All to get started. <br />
* Run Tools->Quick Syntax Check or Run Build All to get started.<br />
====Termos iniciais para se cuidar====<br />
* Nomes de arquivos são sensíveis ao letras maiúsculas e minúsculas nos compiladores da série 1.0.x Se você estiver trabalhando com uma versão como essa, faça com que todos os seus arquivos sejam escritos em minúsculas, pois do contrário, você terá como frase de erro "File not found" - arquivo não encontrado.<br />
====Fontes Delphi VCL, Kylix CLX no Lazarus====<br />
<br />
Ao converter fontes de Delphi/Kylix, é freqüentemente útil fazer uma declaração sobre o que uma função específica está fazendo. A IDE Lazarus pode analisar as fontes de Delphi/Kylix. Para isto, é necessário indicar o local dos arquivos para o compilador. Pode-se conseguir isso através do menu Environment->CodeTools Defines Editor->Insert Template<br />
<br />
=== Problemas de conversão e soluções ===<br />
<br />
==== Arquivos Delphi / Kylix equivalentes no Lazarus ====<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi / Kylix || class="header" | Lazarus || class="header" | Descrição<br />
|- class="code"<br />
| class="code" |.pas<br />
.dfm / .xfm<br />
.dcu / .dpu<br />
.dpr<br />
.res<br />
.dof / .kof<br />
---<br />
---<br />
---<br />
| class="code" |.pas, .pp<br />
.lfm<br />
.o<br />
.lpr<br />
---<br />
---<br />
.lrs<br />
.lpi<br />
.ppu<br />
| class="code" |Arquivo unit de Pascal<br />
Arquivos de dados do form<br />
Arquivo da unit compilada<br />
Arquivo do Projeto<br />
Arquivo de recursos<br />
Arquivo de opções do projeto<br />
Arquivo de recursos do Lazarus<br />
Arquivo de informações do projeto<br />
Arquivo de descrição de unit FPC<br />
|}<br />
<br />
==== Contentendo projetos/forms/units Delphi para Lazarus ====<br />
<br />
Renomeie ou copie o arquivo .dpr para um arquivo .lpr. Comente ou remova a diretiva <div class="dir">{$R *.res}</div> e adicione <div class="dir">{$mode delphi}{$H+}</div> ou <div class="dir">{$mode objfpc}{$H+}</div> no arquivo .lpr. A IDE do Lazarus pode através do menu Tools no item "Convert Delphi Project to Lazarus Project". Ele solicita um arquivo .dpr (Delphi Project) e o converte para um .lpr; mais tarde, também cria um .lpi.<br />
<br />
Existe várias maneiras de converter forms do Delphi através da IDE do Lazarus que realiza o trabalho da conversão do .dfm para o .lfm. Isso pode ser encontrado como item do menu Tools com o sob o nome "Convert DFM file to LFM". Clique nele, e na caixa de dialogo escolha seu arquivo .dmf e o conversor fará o resto.<br />
<br />
Se você precisa converter a unit inteira (com ou sem uma form), o Lazarus também inclui a opção de converter uma unit Delphi para uma Unit Lazarus, através do item "Convert Delphi unit to Lazarus unit" que fará o seguinte:<br />
<br />
# renomeia os arquivos .pas and .dfm para minúsculas.<br />
# converte .dfm para .lfm file (atualmente sem a verificação da validade do conteúdo; somente o formato)<br />
# cria um arquivo .lrs vazio (o conteúdo será adicionado mais tarde)<br />
# adiciona a diretiva <div class="dir">{$mode delphi}</div><br />
# substitui as unidades Windows por LCLIntf<br />
# adiociona units LResources se necessário (i.e., se o unit.lrs for usado; <div class="dir">o uso de LResources </div> pode ser implementado a parte)<br />
# remove variáveis da unit<br />
# remove a diretiva <div class="dir">{$R *.dfm}</div><br />
# adiciona a seção de inicialização e a diretiva <div class="dir">{$i unit.lrs}</div><br />
<br />
<br />
Isto permite rapidamente e conversão fácil da maioria das unidades de Delphi ao formato do Lazarus. Não checa a validade, ou muda a sintaxe automática, assim qualquer mudança na sintaxe que você precisa fazer, mudanças adicionais nos nomes das unit/unit , or dfm/pas changes for control/component differences you must still do manually, though in time some wizards to help facilitate some of this, especially the repairing of converted forms(lfm), may become available.<br />
<br />
==== Selecting the right compiler mode ====<br />
<br />
The [[Free Pascal]] Compiler supports 5 different pascal modes. For example TP for turbo pascal, lets you compile turbo pascal units. There is also a DELPHI compatibility mode that can be set to make existing code easier to convert. Lazarus prefers the OBJFPC mode, which almost equals the DELPHI mode, but is less ambigious than the Delphi syntax. Here are the important points:<br />
<br />
The mode can be selected at command line or at the start of the source. Using the command line has the advantage, that you don't need to change the source, but the disadvantage, that others must be told.<br />
<br />
Most Delphi units can be compiled by the [[Free Pascal]] compiler by adding <br />
{$IFDEF FPC}<br />
{$MODE DELPHI}<br />
{$ENDIF}<br />
right after the unit name.<br />
<br />
For more details about [[Free Pascal]] modes see the [http://www.freepascal.org/docs-html/prog/progap4.html#progse62.html Free Pascal Documentation]<br />
<br />
==== Cross-Platform considerations ====<br />
<br />
* Inline assembler is always a problem because it will bind the code to the Intel architecture. Some developers do algorithm prototypes in Pascal and ifdef the their optimized assembler. Fortunately TurboPower did this in numerous places with their code. If this is the case with the package you're converting, throw the switch back to Pascal.<br />
* Don't reference specific memory location like the BIOS data area. Find out what the code needs and try to find a cross platform alternative.<br />
* Don't do processor specific tricks (like using the Intel TSC) without enclosing your code in an ifdef for the platform the code needs... and providing an alternative for environments that don't have the hardware capability.<br />
* If you need some OS specific code, then you can use IFDEFs. See below for a list of macros.<br />
<br />
==== Useful compiler variables ====<br />
<br />
To write code, that behaves on different systems differently, you can use the <div class="dir">{$IFDEF Name}</div> directives.<br />
<br />
* <div class="dir">{$IfDef LCL}</div><br />
This variable is defined, when using the LCL package. Useful to write code, that works with the LCL and Delphi.<br />
* <div class="dir">{$IfDef FPC}</div><br />
This variable is defined, when using the FPC compiler. Useful to write code, that works with FPC and Delphi.<br />
* <div class="dir">{$IfDef Unix}</div>, <div class="dir">{$IfDef Win32}</div>, ...<br />
Defined by FPC for the current Target OS. Delphi defines "Linux", "Win32" and "MSWindows". [[Free Pascal]] runs on much more platforms and so it is recommended to use the more general items. For example "Unix" is defined for Linux, FreeBSD, NetBSD and OpenBSD, where Lazarus already runs.<br />
Use<br />
{$IfDef Linux}<br />
{$Define Unix}<br />
{$EndIf}<br />
to work around this for Kylix.<br />
<br />
For more details see the [http://www.freepascal.org/docs-html/prog/prog.html#QQ2-23-21 Free Pascal Documentation].<br />
<br />
==== Finding a missing identifier ====<br />
<br />
There are differences in how the LCL is organized when compared to the Delphi VCL. If you get a "not found" compiler error about a major class or identifier, the chances are good that it's in a different unit. A complete cross reference can be found by grep'ing lazarus/docs/xml or the lcl subdirectory.<br />
<br />
For example the commonly used tbutton typically throws an error in Delphi code because it's located in a unit named buttons.pp. The following command finds the correct unit very quickly (in the lazarus source directory):<br />
<br />
grep -in ' tbutton =' lcl/*<br />
<br />
<br />
==== Major unit differences between Lazarus and Delphi ====<br />
<br />
** Please add to this topic! **<br />
<br />
* Windows->Interfaces, LCLIntf, LCLType, LCLProc, VCLGlobals, ...)<br />
<br />
As the LCL is not windows specific, the code that is in the Delphi Windows unit for directly accessing the Win32 API is abstracted into seperate interfaces, which can be accessed from the LCLIntf unit. Keep in mind, that Lazarus does not emulate win32, so many functions are missing and some do not work as their win32 counterparts. These functions only exist for Delphi compatibility and should only be used for quick & dirty porting. LCL also breaks out many of the types, so often LCLType, and sometimes VCLGlobals are required. LCLProc also contains a few functions which can be useful for lower level handling such as "FreeThenNil" as is in Delphi 5 and higher, "DeleteAmpersands" to remove additional ampersands from a string for controls(& vs && etc). The Interfaces unit needs to be included in the .lpr file to initialize the appropriate widgetset.<br />
<br />
* Messages->LMessages<br />
<br />
TControl Messages for win32 event callbacks of the format WM_CALLBACK and the structs associated with them are often found in the Messages unit in Delphi. In the LCL these types of messages and there structs are usually found in LMessages, usually with name changes of WM to LM, so for instance WM_MOUSEENTER becomes LM_MOUSEENTER, and TWMMouse becomes TLMMouse.<br />
<br />
* Graphics, Controls->GraphTypes, GraphMath, Graphics, Controls<br />
<br />
To simplify some things and break complexity of circles between units, a few types have been abstracted into a shared unit called GraphType, which includes things, which in Delphi are located in Graphics or Controls, for instance the bvNone etc of panels. So sometimes you have to include it. Also a unit which, although incompatible with Delphi, adds other useful functionality is GraphMath, which adds a TFloatPoint for precision, misc routines for dealing with beziers, lines, and arcs, as well as some operator overloading for use with TPoints and TRect, such as for instance Point1 := Point2 + Point3, and comparing two rects like if (rect1 = rect2) then ...<br />
<br />
* Mask->MaskEdit<br />
<br />
For more intelligent naming considerations, the unit for TMaskEdit is called [MaskEdit|] instead of the slightly more nebulous Mask as in many versions of Delphi.<br />
<br />
* StdCtrls->StdCtrls,Buttons<br />
<br />
In many version of Delphi TButton is located in StdCtrls, while TSpeedButton and TBitBtn are in Buttons. For consistency and simplicity the LCL puts all button types in Buttons, which can occasionally break code conversion, so it is always a good idea to include.<br />
<br />
==== Property and method differences Delphi -> FPC/LCL ====<br />
* TBitmap contains a canvas in the LCL<br />
==== Syntax differences ====<br />
<br />
'''Please add to this topic!'''<br />
<br />
Because of the inherent strictness in FPC, some syntax changes are necessary, even though <div class="dir">{$Mode Delphi}</div> does allow more laziness like Delphi does. For this reason complying as much with the syntax rules of <div class="dir">{$Mode ObjFPC}</div> as possible is highly recommended, even when the codebase is still going to be shared between Delphi and the LCL. Some of these are simply better coding practices, and sometimes because Delphi mode is not entirely accurate, or in a few instances Delphi acceptible code does not function as expected with FPC, even though it might compile. To that end even though not all such are strictly required, the following list of changes should be considered mandatory :<br />
<br />
<br />
;When assigning an event handling entry point, prefix it with an "@"<br />
<br />
For instance, you might assign a button callback manually <br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">begin</div> <br />
<div class="key">if not</div> Assigned(MyButton.OnClick) <div class="key">then</div><br />
MyButton.OnClick:= SomeFunction; <div class="cmt">//@ not required</div><br />
<div class="cmt">//more code...</div><br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">begin</div><br />
<div class="key">if not</div> Assigned(MyButton.OnClick) <div class="key">then</div><br />
MyButton.OnClick:= @SomeFunction; <div class="cmt">//@ IS required</div><br />
<div class="cmt">//more code...</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
;When calling a procedure variable use this syntax: theprocname()<br />
<br />
In Delphi there is no difference between a function result and a variable, however there is in FPC, so to call a function, even if it has no parameters, you must append parenthesis. For Example -<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">With</div> (SomeObject) <div class="key">do begin</div> <br />
<div class="key">If</div> Assigned(OnMyCallback) <div class="key">then</div> <br />
OnMyCallback; <div class="cmt">//parenthesis not required</div> <br />
<div class="key">end</div>; <br />
| class="code" | <div class="key">With</div> (SomeObject) <div class="key">do begin</div><br />
<div class="key">If</div> Assigned(OnMyCallback) <div class="key">then</div><br />
OnMyCallback(); <div class="cmt">//parenthesis required</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
;When accessing values in a pointer to a record you must dereference first<br />
<br />
In Delphi it is not required to de-reference a pointer to a record to access values within it, it can, in fact, be treated just like the record itself, or any other object. In FPC it must be first de-referenced. As an example,<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">Function</div> GetSomeValue(ARecord: PMyRecord) <br />
<div class="symbol">:</div> Integer;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Assigned(ARecord) <div class="key">then</div><br />
Result<div class="symbol">:=</div> ARecord.SomeValue<br />
<div class="key">else</div><br />
Result:= <div class="int">0</div>;<br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">Function</div> GetSomeValue(ARecord: PMyRecord) <br />
<div class="symbol">:</div> Integer;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Assigned(ARecord) <div class="key">then</div><br />
Result<div class="symbol">:=</div> ARecord^.SomeValue<br />
<div class="key">else</div><br />
Result:= <div class="int">0</div>;<br />
<div class="key">end</div>; <br />
|}<br />
<br />
;When accessing chars of an indexed string Property of an object, it must be enclosed in parentheses<br />
<br />
With Delphi it is possible to treat a Property exactly like some other const or var, even to accessing for instance individual chars of a string directly, while this is not always possible in FPC, specifically for indexed properties. Instead it must be enclosed in parentheses, to make distinct. While this may not always hold true it is probably a good practice to consider anyway. For example<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
<div class="key">Property</div> MyString: <div class="key">String</div> <div class="key">index</div> <div class="int">3</div><br />
<div class="key">read</div> GetMyString;<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">var</div><br />
MyChar<div class="symbol">:</div> char;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Length(MyString)> <div class="int">2</div> <div class="key">then</div><br />
<div class="cmt">//no parenthesis needed</div><br />
MyChar:= MyString[<div class="int">3</div>];<br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
<div class="key">Property</div> MyString: <div class="key">String</div> <div class="key">index</div> <div class="int">3</div><br />
<div class="key">read</div> GetMyString;<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">var</div><br />
MyChar<div class="symbol">:</div> char;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Length(MyString)> <div class="int">2</div> <div class="key">then</div><br />
<div class="cmt">//parenthesis sometimes needed</div><br />
MyChar:= (MyString)[<div class="int">3</div>];<br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
<br />
;You must typecast pointers to actual type when using with var or function of that type<br />
<br />
Sometimes in Delphi you will have a null pointer variable representing an object. While it might seem a complex situation, it is oddly quite common especially in large component packs as a method of preventing too many circular includes between objects in different units. In Delphi it is then possible to send this null pointer to a function expecting that object, without bothering to typecast to actual type, in fpc you must typecast. <br />
<br />
For example -<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" |Unit 1<br />
<div class="key">Type</div> TSomeObject= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">Procedure</div> DoSomething(Value: TSomeObject);<br />
<div class="key">Function</div> GetSomeObject: TSomeObject;<br />
<div></div> <br />
<div class="symbol">Unit 2</div><br />
<div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
SomeObject: Pointer<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div><br />
<div class="symbol">Application</div><br />
<div class="key">var</div><br />
MyComponent: TSomeComponent<div class="symbol">;</div><br />
<div class="key">begin</div><br />
MyComponent.SomeObject<div class="symbol">:=</div> GetSomeObject;<br />
<div class="cmt">//More code...</div><br />
DoSomething(MyComponent.SomeObject)<div class="symbol">;</div><br />
<div class="key">end</div>;<br />
| class="code" |Unit 1<br />
<div class="key">Type</div> TSomeObject= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">Procedure</div> DoSomething(Value: TSomeObject);<br />
<div class="key">Function</div> GetSomeObject: TSomeObject;<br />
<div></div> <br />
<div class="symbol">Unit 2</div><br />
<div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
SomeObject: Pointer<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="symbol">Application</div> <br />
<div class="key">var</div><br />
MyComponent: TSomeComponent<div class="symbol">;</div><br />
<div class="key">begin</div><br />
MyComponent.SomeObject<div class="symbol">:=</div> Pointer(GetSomeObject);<br />
<div class="cmt">//More code...</div><br />
DoSomething(TSomeObject(MyComponent.SomeObject))<div class="symbol">;</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
==== Resources ====<br />
<br />
Delphi resource files are win32 specific and not compatible with Lazarus, so you'll have to recreate and compile them using the lazres. Lazres can be found in the lazarus/tools subdirectory. If you've downloaded the Lazarus sources, you'll need to compile it first.<br />
* cd lazarus/tools<br />
* make install<br />
To add a resource to your application:<br />
* lazres myresource.lrs mypix.xpm anotherpix.xpm<br />
* Add the LResources unit to your Uses clause<br />
* Include the .lrs file you created under the initialization block<br />
Example:<br />
{| class="code" <br />
|- class="code"<br />
| class="code" | <div class="key">function</div> TForm1.LoadGlyph(<div class="key">const</div> GlyphName: <div class="key">String</div>): TBitMap;<br />
<div class="key">begin</div><br />
Result:= TPixmap.Create<div class="symbol">;</div><br />
Result.LoadFromLazarusResource(GlyphName)<div class="symbol">;</div><br />
<div class="key">end</div>; <br />
<div class="cmt">//More code...</div><br />
<div class="key">begin</div><br />
Speedbutton1.glyph:= LoadGlyph('mypix')<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
<div></div> <br />
<div class="key">initialization</div><br />
<div class="dir">{$I unit1.lrs}</div><br />
<div class="dir">{$I myresource.lrs}</div><br />
<div class="key">end</div>.<br />
|}<br />
<br />
== Getting Help ==<br />
<br />
If you encounter a problem during conversion that you just can't solve, there are a wide variety of places to get help. For pure Object Pascal and FPC issues, the best place to start is the Free Pascal [http://www.freepascal.org/docs-html/ Documentation] by Michaël Van Canneyt and Florian Klämpfl. For more Lazarus oriented problems, the Lazarus Project Documentation in the Lazarus-CCR Knowledgebase [Main Page] is the next place to look. Finally you can post a question on any of the [http://www.freepascal.org/maillist.html mailing lists for the Free Pascal Compiler] or the [http://community.freepascal.org:10000/bboard/ FPC forums] where a lot of experts are subscribed.<br />
<br />
There are some outstanding search and knowledge bases online that can also be a great help for learning new techniques and solving problems. Tamarack Associates operates a fast [http://www.tamaracka.com/search.htm search] engine specifically for the Borland usenet archives. Mer Systems Inc. provides a similar search [http://www.mers.com/searchsite.html engine]. Another outstanding source of information along with a sitewide [http://www.efg2.com/Lab/search.htm search] capability is Earl F. Glynn's Computer Lab and Reference [http://www.efg2.com/ Library].<br />
<br />
== Packaging and Releasing your component ==<br />
<br />
=== Creating a Lazarus package for your component(s) ===<br />
<br />
Creating a package makes installing the code you've converted a much easier process... especially if you're providing more then one component. Mattias Gärtner has written an overview of [[Lazarus Packages]] that should be read before beginning this process.<br />
<br />
=== Documentation ===<br />
<br />
The purpose of this site and the wiki format is to make the generation of professional documentation an easy and quick process. The wiki also makes it possible to see the results of your posting immediately and make any changes you'd like in real time.<br />
<br />
Using the Lazarus-CCR wiki to create nice looking documentation is very easy. If you've never used wiki markup before, you can get familiar with it in the [[Sand Box]] practice area.<br />
<br />
=== Creating a Code Release Page ===<br />
<br />
The Code Release Page contains vital information about your component that a potential downloader will need to know, such as license, intended platform, status (alpha, beta, stable...), where to download it, who wrote it, is support available... etc.<br />
<br />
The following procedure will let you create a Code Release Page with your browser: <br />
<br />
* Edit the [[Components and Code examples]] page and add a project name wiki link entry for your component in the "Released Components" section. Save the modified page.<br />
<br />
* Go to the [[Component Release Template]], select all and copy. Hit the back button on your browser to return to the [[Components and Code examples]] page.<br />
* Click on your new wiki component name entry and paste the release template into the blank edit box.<br />
* Edit the template accordingly and hit save.<br />
* Do edit-saves until your document looks the way you want it to.<br />
<br />
=== Submitting the component ===<br />
<br />
If you're a release technician on the project, upload your component to the SourceForge File Release System and add it to the list of release packages. Otherwise send it to one of the project administrators ([[User:Tom | Tom Lisjac]] or [[User:Vincent | Vincent Snijders]]) and we'll add it to the repository. <br />
<br />
If you think you need to continue to develop on the component, we can also put it into CVS so you'll continue to have access to it.<br />
<br />
== Contributors and Changes ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=CodeConversionGuide version].<br />
* Initial version by Tom Lisjac and Mattias Gärtner - 9/22/2003 [[User:Tom | VlxAdmin]]<br />
* Moved Getting help from the main page. T. Lisjac - 9/24/2003 [[User:Tom | VlxAdmin]]<br />
* Added documentation templates, procedure and links. 9/25/2003 [[User:Tom | VlxAdmin]]<br />
* LCLLinux was renamed to LCLIntf, [[User:Jesusrmx | Jesus Reyes]], 9/27/2003<br />
* added more information on Unit changes, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* Updated Syntax differences, including some examples, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* FPC 1.0.x doesn't support interfaces, [[User:Vincent | Vincent Snijders]] 9/28/2003<br />
* Fixed some of the examples per new WikiWord definition, 9/28/2003 [[User:Tom | VlxAdmin]]<br />
* Made code more consistant to remove last accidental Pascal WikiWord definitions, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* Use tables for code examples for nice blocks, and easy side by side view of Delphi->FPC differences, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 10/17/2003<br />
* Use pascal stylesheet to make example code more readable, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 10/18/2003</div>Fititnthttps://wiki.freepascal.org/index.php?title=Code_Conversion_Guide/pt&diff=3809Code Conversion Guide/pt2005-11-20T22:58:25Z<p>Fititnt: /* Fazendo a conversão */</p>
<hr />
<div>Guia de conversão do Delphi para o Lazarus <br />
<br />
== Sobre ==<br />
<br />
Esta página é sobre como converter um código para poder usá-lo no compilador [[Free Pascal]] e a IDE do Lazarus. O Lazarus e o Free Pascal tem aspectos em comum com o Delphi e Kylix, porém, não são clones. há várias diferenças nos códigos e convenções... e em algumas áreas, o FPC pode exigir uma sintaxe mais correta. Por favor veja o [[Lazarus For Delphi Users]] guia para uma descrição de algumas das diferenças funcionais. <br />
<br />
O propósito deste guia é documentar algumas das diferenças específicas que freqüentemente são encontradas durante o processo de conversão de código ao traduzir código existente de Delphi para Lazarus. <br />
<br />
Este documento foi colocado na área de conhecimento-base de wiki para que assim pudesse ser estendido facilmente por qualquer um que tenha encontrado um problema sem igual e gostaria de postar isto para outros estarem atentos<br />
<br />
== Selecting a component or library for conversion ==<br />
<br />
=== Where to find code to convert ===<br />
<br />
There is a LOT of code available on the net that can be converted for use with FPC and Lazarus. Here is a [[Page Of Code Sites]] that is just a start. Please add to it if you know of any other good locations. TurboPower Software has recently released their entire commercial offering under the MPL. A list of available packages can be found [http://sourceforge.net/users/tpsfadmin/ here].<br />
<br />
To avoid duplicating effort, packages that have already been converted are listed on the [[Components and Code examples]] page. If you've converted a package or are working on one, please add a note on the [[Current conversion projects]] page.<br />
<br />
=== Licensing ===<br />
<br />
Licenses for existing code range from freeware/public domain to restrictive versions that prohibit modification, re-distribution and commercial use. Before converting any package, it's a good idea to examine its licensing and make sure it's going to be compatible with Lazarus and the Free Pascal Compiler. License selection is especially important with components since dropping one on a form can impose an unwanted or incompatible license on an entire application.<br />
<br />
When converting components, please respect the wishes of the original author and retain all copyright and licensing headers along with email addresses and url's. It's courteous and often useful to inform the author that their component is being converted... especially if the component is under a restrictive license. New interest in an old or forgotten component can sometimes inspire authors to revise their original and overly restrictive licensing.<br />
<br />
In general, Public Domain (freeware), and the LGPL/MPL are the the most flexible for distributing components. For more information, the [http://www.opensource.org/docs/definition.php Open Source Definition] is a good place to start. There are also several comparisons available to help clarify how the various types of licenses work and what impact they'll have on code they're linked to. Search for "open source license comparison"<br />
<br />
=== Dependencies ===<br />
<br />
Another step before starting to work on a conversion is to verify that the code doesn't have deep dependancies on other packages that might not be available or represent a considerable conversion challenge. Some freeware offerings are bound to or extend proprietary packages that are frequently no longer available or come with inappropriate licenses.<br />
<br />
=== Compiler Issues ===<br />
<br />
Currently the stable 1.0.x version of the [[Free Pascal]] Compiler doesn't support interfaces, threads or Variant records. If the code you're converting needs these constructs, you'll have to use the 1.1 development branch of the compiler... which isn't always guaranteed to work with Lazarus.<br />
<br />
See also:<br />
* [http://www.freepascal.org/probs.html Known problems]<br />
* [http://www.freepascal.org/bugs/db.php3?statusfield=Unfixed Unfixed bugs]<br />
<br />
=== Platform and OS Issues ===<br />
<br />
Lazarus and the Free Pascal Compiler are cross-platform and cross-architecture development tools. In contrast, most existing Delphi code was specifically designed to run on an Intel processor under Win32. If your candidate component has a lot of Win32 specific code, it might be wise to try and find a less platform dependant alternative. But don't let this stop you... it's genuinely amazing what the LCL supports!<br />
<br />
== Fazendo a conversão ==<br />
<br />
=== Montando o ambiente de Lazarus para um projeto de conversão ===<br />
<br />
====Crie um projeto teste====<br />
* Coloque o código a ser convertido em um subdiretório (ie: convertdir) <br />
* Abra-o com o Lazarus <br />
* File->Save All para o subdiretório de convertdir. Meaningful names for the Project and default unit are optional. <br />
* Open the "main" unit to be converted in convertdir * Add it to the project: Project->Add Active Unit to Project * Run Tools->Quick Syntax Check or Run Build All to get started. <br />
* Run Tools->Quick Syntax Check or Run Build All to get started.<br />
====Termos iniciais para se cuidar====<br />
* Nomes de arquivos são sensíveis ao letras maiúsculas e minúsculas nos compiladores da série 1.0.x Se você estiver trabalhando com uma versão como essa, faça com que todos os seus arquivos sejam escritos em minúsculas, pois do contrário, você terá como frase de erro "File not found" - arquivo não encontrado.<br />
====Fontes Delphi VCL, Kylix CLX no Lazarus====<br />
<br />
Ao converter fontes de Delphi/Kylix, é freqüentemente útil fazer uma declaração sobre o que uma função específica está fazendo. A IDE Lazarus pode analisar as fontes de Delphi/Kylix. Para isto, é necessário indicar o local dos arquivos para o compilador. Pode-se conseguir isso através do menu Environment->CodeTools Defines Editor->Insert Template<br />
<br />
=== Problemas de conversão e soluções ===<br />
<br />
==== Arquivos Delphi / Kylix equivalentes no Lazarus ====<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi / Kylix || class="header" | Lazarus || class="header" | Descrição<br />
|- class="code"<br />
| class="code" |.pas<br />
.dfm / .xfm<br />
.dcu / .dpu<br />
.dpr<br />
.res<br />
.dof / .kof<br />
---<br />
---<br />
---<br />
| class="code" |.pas, .pp<br />
.lfm<br />
.o<br />
.lpr<br />
---<br />
---<br />
.lrs<br />
.lpi<br />
.ppu<br />
| class="code" |Arquivo unit de Pascal<br />
Arquivos de dados do form<br />
Arquivo da unit compilada<br />
Arquivo do Projeto<br />
Arquivo de recursos<br />
Arquivo de opções do projeto<br />
Arquivo de recursos do Lazarus<br />
Arquivo de informações do projeto<br />
Arquivo de descrição de unit FPC<br />
|}<br />
<br />
==== Contentendo projetos/forms/units Delphi para Lazarus ====<br />
<br />
Renomeie ou copie o arquivo .dpr para um arquivo .lpr. Comente ou remova a diretiva <div class="dir">{$R *.res}</div> e adicione <div class="dir">{$mode delphi}{$H+}</div> ou <div class="dir">{$mode objfpc}{$H+}</div> no arquivo .lpr. A IDE do Lazarus pode através do menu Tools no item "Convert Delphi Project to Lazarus Project". Ele solicita um arquivo .dpr (Delphi Project) e o converte para um .lpr; mais tarde, também cria um .lpi.<br />
<br />
Existe várias maneiras de converter forms do Delphi através da IDE do Lazarus que realiza o trabalho da conversão do .dfm para o .lfm. Isso pode ser encontrado como item do menu Tools com o sob o nome "Convert DFM file to LFM". Clique nele, e na caixa de dialogo escolha seu arquivo .dmf e o conversor fará o resto.<br />
<br />
Se você precisa converter a unit inteira (com ou sem uma form), o Lazarus também inclui a opção de converter uma unit Delphi para uma Unit Lazarus, através do item "Convert Delphi unit to Lazarus unit" que fará o seguinte:<br />
<br />
# renomeia os arquivos .pas and .dfm para minúsculas.<br />
# converte .dfm para .lfm file (atualmente sem a verificação da validade do conteúdo; somente o formato)<br />
# cria um arquivo .lrs vazio (o conteúdo será adicionado mais tarde)<br />
# adiciona a diretiva <div class="dir">{$mode delphi}</div><br />
# substitui as unidades Windows por LCLIntf<br />
# adiociona units LResources se necessário (i.e., se o unit.lrs for usado; <div class="dir">o uso de LResources </div> pode ser implementado a parte)<br />
# remove variáveis da unit<br />
# remove a diretiva <div class="dir">{$R *.dfm}</div><br />
# adiciona a seção de inicialização e a diretiva <div class="dir">{$i unit.lrs}</div><br />
<br />
<br />
Isto permite rapidamente e conversão fácil da maioria das unidades de Delphi ao formato do Lazarus. Não checa a validade, ou muda a sintaxe automática, assim qualquer mudança na sintaxe que você precisa fazer, mudanças adicionais nos nomes das unit/unit , or dfm/pas changes for control/component differences you must still do manually, though in time some wizards to help facilitate some of this, especially the repairing of converted forms(lfm), may become available.<br />
<br />
==== Selecting the right compiler mode ====<br />
<br />
The [[Free Pascal]] Compiler supports 5 different pascal modes. For example TP for turbo pascal, lets you compile turbo pascal units. There is also a DELPHI compatibility mode that can be set to make existing code easier to convert. Lazarus prefers the OBJFPC mode, which almost equals the DELPHI mode, but is less ambigious than the Delphi syntax. Here are the important points:<br />
<br />
The mode can be selected at command line or at the start of the source. Using the command line has the advantage, that you don't need to change the source, but the disadvantage, that others must be told.<br />
<br />
Most Delphi units can be compiled by the [[Free Pascal]] compiler by adding <br />
{$IFDEF FPC}<br />
{$MODE DELPHI}<br />
{$ENDIF}<br />
right after the unit name.<br />
<br />
For more details about [[Free Pascal]] modes see the [http://www.freepascal.org/docs-html/prog/progap4.html#progse62.html Free Pascal Documentation]<br />
<br />
==== Cross-Platform considerations ====<br />
<br />
* Inline assembler is always a problem because it will bind the code to the Intel architecture. Some developers do algorithm prototypes in Pascal and ifdef the their optimized assembler. Fortunately TurboPower did this in numerous places with their code. If this is the case with the package you're converting, throw the switch back to Pascal.<br />
* Don't reference specific memory location like the BIOS data area. Find out what the code needs and try to find a cross platform alternative.<br />
* Don't do processor specific tricks (like using the Intel TSC) without enclosing your code in an ifdef for the platform the code needs... and providing an alternative for environments that don't have the hardware capability.<br />
* If you need some OS specific code, then you can use IFDEFs. See below for a list of macros.<br />
<br />
==== Useful compiler variables ====<br />
<br />
To write code, that behaves on different systems differently, you can use the <div class="dir">{$IFDEF Name}</div> directives.<br />
<br />
* <div class="dir">{$IfDef LCL}</div><br />
This variable is defined, when using the LCL package. Useful to write code, that works with the LCL and Delphi.<br />
* <div class="dir">{$IfDef FPC}</div><br />
This variable is defined, when using the FPC compiler. Useful to write code, that works with FPC and Delphi.<br />
* <div class="dir">{$IfDef Unix}</div>, <div class="dir">{$IfDef Win32}</div>, ...<br />
Defined by FPC for the current Target OS. Delphi defines "Linux", "Win32" and "MSWindows". [[Free Pascal]] runs on much more platforms and so it is recommended to use the more general items. For example "Unix" is defined for Linux, FreeBSD, NetBSD and OpenBSD, where Lazarus already runs.<br />
Use<br />
{$IfDef Linux}<br />
{$Define Unix}<br />
{$EndIf}<br />
to work around this for Kylix.<br />
<br />
For more details see the [http://www.freepascal.org/docs-html/prog/prog.html#QQ2-23-21 Free Pascal Documentation].<br />
<br />
==== Finding a missing identifier ====<br />
<br />
There are differences in how the LCL is organized when compared to the Delphi VCL. If you get a "not found" compiler error about a major class or identifier, the chances are good that it's in a different unit. A complete cross reference can be found by grep'ing lazarus/docs/xml or the lcl subdirectory.<br />
<br />
For example the commonly used tbutton typically throws an error in Delphi code because it's located in a unit named buttons.pp. The following command finds the correct unit very quickly (in the lazarus source directory):<br />
<br />
grep -in ' tbutton =' lcl/*<br />
<br />
<br />
==== Major unit differences between Lazarus and Delphi ====<br />
<br />
** Please add to this topic! **<br />
<br />
* Windows->Interfaces, LCLIntf, LCLType, LCLProc, VCLGlobals, ...)<br />
<br />
As the LCL is not windows specific, the code that is in the Delphi Windows unit for directly accessing the Win32 API is abstracted into seperate interfaces, which can be accessed from the LCLIntf unit. Keep in mind, that Lazarus does not emulate win32, so many functions are missing and some do not work as their win32 counterparts. These functions only exist for Delphi compatibility and should only be used for quick & dirty porting. LCL also breaks out many of the types, so often LCLType, and sometimes VCLGlobals are required. LCLProc also contains a few functions which can be useful for lower level handling such as "FreeThenNil" as is in Delphi 5 and higher, "DeleteAmpersands" to remove additional ampersands from a string for controls(& vs && etc). The Interfaces unit needs to be included in the .lpr file to initialize the appropriate widgetset.<br />
<br />
* Messages->LMessages<br />
<br />
TControl Messages for win32 event callbacks of the format WM_CALLBACK and the structs associated with them are often found in the Messages unit in Delphi. In the LCL these types of messages and there structs are usually found in LMessages, usually with name changes of WM to LM, so for instance WM_MOUSEENTER becomes LM_MOUSEENTER, and TWMMouse becomes TLMMouse.<br />
<br />
* Graphics, Controls->GraphTypes, GraphMath, Graphics, Controls<br />
<br />
To simplify some things and break complexity of circles between units, a few types have been abstracted into a shared unit called GraphType, which includes things, which in Delphi are located in Graphics or Controls, for instance the bvNone etc of panels. So sometimes you have to include it. Also a unit which, although incompatible with Delphi, adds other useful functionality is GraphMath, which adds a TFloatPoint for precision, misc routines for dealing with beziers, lines, and arcs, as well as some operator overloading for use with TPoints and TRect, such as for instance Point1 := Point2 + Point3, and comparing two rects like if (rect1 = rect2) then ...<br />
<br />
* Mask->MaskEdit<br />
<br />
For more intelligent naming considerations, the unit for TMaskEdit is called [MaskEdit|] instead of the slightly more nebulous Mask as in many versions of Delphi.<br />
<br />
* StdCtrls->StdCtrls,Buttons<br />
<br />
In many version of Delphi TButton is located in StdCtrls, while TSpeedButton and TBitBtn are in Buttons. For consistency and simplicity the LCL puts all button types in Buttons, which can occasionally break code conversion, so it is always a good idea to include.<br />
<br />
==== Property and method differences Delphi -> FPC/LCL ====<br />
* TBitmap contains a canvas in the LCL<br />
==== Syntax differences ====<br />
<br />
'''Please add to this topic!'''<br />
<br />
Because of the inherent strictness in FPC, some syntax changes are necessary, even though <div class="dir">{$Mode Delphi}</div> does allow more laziness like Delphi does. For this reason complying as much with the syntax rules of <div class="dir">{$Mode ObjFPC}</div> as possible is highly recommended, even when the codebase is still going to be shared between Delphi and the LCL. Some of these are simply better coding practices, and sometimes because Delphi mode is not entirely accurate, or in a few instances Delphi acceptible code does not function as expected with FPC, even though it might compile. To that end even though not all such are strictly required, the following list of changes should be considered mandatory :<br />
<br />
<br />
;When assigning an event handling entry point, prefix it with an "@"<br />
<br />
For instance, you might assign a button callback manually <br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">begin</div> <br />
<div class="key">if not</div> Assigned(MyButton.OnClick) <div class="key">then</div><br />
MyButton.OnClick:= SomeFunction; <div class="cmt">//@ not required</div><br />
<div class="cmt">//more code...</div><br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">begin</div><br />
<div class="key">if not</div> Assigned(MyButton.OnClick) <div class="key">then</div><br />
MyButton.OnClick:= @SomeFunction; <div class="cmt">//@ IS required</div><br />
<div class="cmt">//more code...</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
;When calling a procedure variable use this syntax: theprocname()<br />
<br />
In Delphi there is no difference between a function result and a variable, however there is in FPC, so to call a function, even if it has no parameters, you must append parenthesis. For Example -<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">With</div> (SomeObject) <div class="key">do begin</div> <br />
<div class="key">If</div> Assigned(OnMyCallback) <div class="key">then</div> <br />
OnMyCallback; <div class="cmt">//parenthesis not required</div> <br />
<div class="key">end</div>; <br />
| class="code" | <div class="key">With</div> (SomeObject) <div class="key">do begin</div><br />
<div class="key">If</div> Assigned(OnMyCallback) <div class="key">then</div><br />
OnMyCallback(); <div class="cmt">//parenthesis required</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
;When accessing values in a pointer to a record you must dereference first<br />
<br />
In Delphi it is not required to de-reference a pointer to a record to access values within it, it can, in fact, be treated just like the record itself, or any other object. In FPC it must be first de-referenced. As an example,<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">Function</div> GetSomeValue(ARecord: PMyRecord) <br />
<div class="symbol">:</div> Integer;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Assigned(ARecord) <div class="key">then</div><br />
Result<div class="symbol">:=</div> ARecord.SomeValue<br />
<div class="key">else</div><br />
Result:= <div class="int">0</div>;<br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">Function</div> GetSomeValue(ARecord: PMyRecord) <br />
<div class="symbol">:</div> Integer;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Assigned(ARecord) <div class="key">then</div><br />
Result<div class="symbol">:=</div> ARecord^.SomeValue<br />
<div class="key">else</div><br />
Result:= <div class="int">0</div>;<br />
<div class="key">end</div>; <br />
|}<br />
<br />
;When accessing chars of an indexed string Property of an object, it must be enclosed in parentheses<br />
<br />
With Delphi it is possible to treat a Property exactly like some other const or var, even to accessing for instance individual chars of a string directly, while this is not always possible in FPC, specifically for indexed properties. Instead it must be enclosed in parentheses, to make distinct. While this may not always hold true it is probably a good practice to consider anyway. For example<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
<div class="key">Property</div> MyString: <div class="key">String</div> <div class="key">index</div> <div class="int">3</div><br />
<div class="key">read</div> GetMyString;<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">var</div><br />
MyChar<div class="symbol">:</div> char;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Length(MyString)> <div class="int">2</div> <div class="key">then</div><br />
<div class="cmt">//no parenthesis needed</div><br />
MyChar:= MyString[<div class="int">3</div>];<br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
<div class="key">Property</div> MyString: <div class="key">String</div> <div class="key">index</div> <div class="int">3</div><br />
<div class="key">read</div> GetMyString;<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">var</div><br />
MyChar<div class="symbol">:</div> char;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Length(MyString)> <div class="int">2</div> <div class="key">then</div><br />
<div class="cmt">//parenthesis sometimes needed</div><br />
MyChar:= (MyString)[<div class="int">3</div>];<br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
<br />
;You must typecast pointers to actual type when using with var or function of that type<br />
<br />
Sometimes in Delphi you will have a null pointer variable representing an object. While it might seem a complex situation, it is oddly quite common especially in large component packs as a method of preventing too many circular includes between objects in different units. In Delphi it is then possible to send this null pointer to a function expecting that object, without bothering to typecast to actual type, in fpc you must typecast. <br />
<br />
For example -<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" |Unit 1<br />
<div class="key">Type</div> TSomeObject= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">Procedure</div> DoSomething(Value: TSomeObject);<br />
<div class="key">Function</div> GetSomeObject: TSomeObject;<br />
<div></div> <br />
<div class="symbol">Unit 2</div><br />
<div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
SomeObject: Pointer<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div><br />
<div class="symbol">Application</div><br />
<div class="key">var</div><br />
MyComponent: TSomeComponent<div class="symbol">;</div><br />
<div class="key">begin</div><br />
MyComponent.SomeObject<div class="symbol">:=</div> GetSomeObject;<br />
<div class="cmt">//More code...</div><br />
DoSomething(MyComponent.SomeObject)<div class="symbol">;</div><br />
<div class="key">end</div>;<br />
| class="code" |Unit 1<br />
<div class="key">Type</div> TSomeObject= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">Procedure</div> DoSomething(Value: TSomeObject);<br />
<div class="key">Function</div> GetSomeObject: TSomeObject;<br />
<div></div> <br />
<div class="symbol">Unit 2</div><br />
<div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
SomeObject: Pointer<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="symbol">Application</div> <br />
<div class="key">var</div><br />
MyComponent: TSomeComponent<div class="symbol">;</div><br />
<div class="key">begin</div><br />
MyComponent.SomeObject<div class="symbol">:=</div> Pointer(GetSomeObject);<br />
<div class="cmt">//More code...</div><br />
DoSomething(TSomeObject(MyComponent.SomeObject))<div class="symbol">;</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
==== Resources ====<br />
<br />
Delphi resource files are win32 specific and not compatible with Lazarus, so you'll have to recreate and compile them using the lazres. Lazres can be found in the lazarus/tools subdirectory. If you've downloaded the Lazarus sources, you'll need to compile it first.<br />
* cd lazarus/tools<br />
* make install<br />
To add a resource to your application:<br />
* lazres myresource.lrs mypix.xpm anotherpix.xpm<br />
* Add the LResources unit to your Uses clause<br />
* Include the .lrs file you created under the initialization block<br />
Example:<br />
{| class="code" <br />
|- class="code"<br />
| class="code" | <div class="key">function</div> TForm1.LoadGlyph(<div class="key">const</div> GlyphName: <div class="key">String</div>): TBitMap;<br />
<div class="key">begin</div><br />
Result:= TPixmap.Create<div class="symbol">;</div><br />
Result.LoadFromLazarusResource(GlyphName)<div class="symbol">;</div><br />
<div class="key">end</div>; <br />
<div class="cmt">//More code...</div><br />
<div class="key">begin</div><br />
Speedbutton1.glyph:= LoadGlyph('mypix')<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
<div></div> <br />
<div class="key">initialization</div><br />
<div class="dir">{$I unit1.lrs}</div><br />
<div class="dir">{$I myresource.lrs}</div><br />
<div class="key">end</div>.<br />
|}<br />
<br />
== Getting Help ==<br />
<br />
If you encounter a problem during conversion that you just can't solve, there are a wide variety of places to get help. For pure Object Pascal and FPC issues, the best place to start is the Free Pascal [http://www.freepascal.org/docs-html/ Documentation] by Michaël Van Canneyt and Florian Klämpfl. For more Lazarus oriented problems, the Lazarus Project Documentation in the Lazarus-CCR Knowledgebase [Main Page] is the next place to look. Finally you can post a question on any of the [http://www.freepascal.org/maillist.html mailing lists for the Free Pascal Compiler] or the [http://community.freepascal.org:10000/bboard/ FPC forums] where a lot of experts are subscribed.<br />
<br />
There are some outstanding search and knowledge bases online that can also be a great help for learning new techniques and solving problems. Tamarack Associates operates a fast [http://www.tamaracka.com/search.htm search] engine specifically for the Borland usenet archives. Mer Systems Inc. provides a similar search [http://www.mers.com/searchsite.html engine]. Another outstanding source of information along with a sitewide [http://www.efg2.com/Lab/search.htm search] capability is Earl F. Glynn's Computer Lab and Reference [http://www.efg2.com/ Library].<br />
<br />
== Packaging and Releasing your component ==<br />
<br />
=== Creating a Lazarus package for your component(s) ===<br />
<br />
Creating a package makes installing the code you've converted a much easier process... especially if you're providing more then one component. Mattias Gärtner has written an overview of [[Lazarus Packages]] that should be read before beginning this process.<br />
<br />
=== Documentation ===<br />
<br />
The purpose of this site and the wiki format is to make the generation of professional documentation an easy and quick process. The wiki also makes it possible to see the results of your posting immediately and make any changes you'd like in real time.<br />
<br />
Using the Lazarus-CCR wiki to create nice looking documentation is very easy. If you've never used wiki markup before, you can get familiar with it in the [[Sand Box]] practice area.<br />
<br />
=== Creating a Code Release Page ===<br />
<br />
The Code Release Page contains vital information about your component that a potential downloader will need to know, such as license, intended platform, status (alpha, beta, stable...), where to download it, who wrote it, is support available... etc.<br />
<br />
The following procedure will let you create a Code Release Page with your browser: <br />
<br />
* Edit the [[Components and Code examples]] page and add a project name wiki link entry for your component in the "Released Components" section. Save the modified page.<br />
<br />
* Go to the [[Component Release Template]], select all and copy. Hit the back button on your browser to return to the [[Components and Code examples]] page.<br />
* Click on your new wiki component name entry and paste the release template into the blank edit box.<br />
* Edit the template accordingly and hit save.<br />
* Do edit-saves until your document looks the way you want it to.<br />
<br />
=== Submitting the component ===<br />
<br />
If you're a release technician on the project, upload your component to the SourceForge File Release System and add it to the list of release packages. Otherwise send it to one of the project administrators ([[User:Tom | Tom Lisjac]] or [[User:Vincent | Vincent Snijders]]) and we'll add it to the repository. <br />
<br />
If you think you need to continue to develop on the component, we can also put it into CVS so you'll continue to have access to it.<br />
<br />
== Contributors and Changes ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=CodeConversionGuide version].<br />
* Initial version by Tom Lisjac and Mattias Gärtner - 9/22/2003 [[User:Tom | VlxAdmin]]<br />
* Moved Getting help from the main page. T. Lisjac - 9/24/2003 [[User:Tom | VlxAdmin]]<br />
* Added documentation templates, procedure and links. 9/25/2003 [[User:Tom | VlxAdmin]]<br />
* LCLLinux was renamed to LCLIntf, [[User:Jesusrmx | Jesus Reyes]], 9/27/2003<br />
* added more information on Unit changes, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* Updated Syntax differences, including some examples, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* FPC 1.0.x doesn't support interfaces, [[User:Vincent | Vincent Snijders]] 9/28/2003<br />
* Fixed some of the examples per new WikiWord definition, 9/28/2003 [[User:Tom | VlxAdmin]]<br />
* Made code more consistant to remove last accidental Pascal WikiWord definitions, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* Use tables for code examples for nice blocks, and easy side by side view of Delphi->FPC differences, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 10/17/2003<br />
* Use pascal stylesheet to make example code more readable, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 10/18/2003</div>Fititnthttps://wiki.freepascal.org/index.php?title=Code_Conversion_Guide/pt&diff=3808Code Conversion Guide/pt2005-11-20T21:22:47Z<p>Fititnt: /* Doing the conversion */</p>
<hr />
<div>Guia de conversão do Delphi para o Lazarus <br />
<br />
== Sobre ==<br />
<br />
Esta página é sobre como converter um código para poder usá-lo no compilador [[Free Pascal]] e a IDE do Lazarus. O Lazarus e o Free Pascal tem aspectos em comum com o Delphi e Kylix, porém, não são clones. há várias diferenças nos códigos e convenções... e em algumas áreas, o FPC pode exigir uma sintaxe mais correta. Por favor veja o [[Lazarus For Delphi Users]] guia para uma descrição de algumas das diferenças funcionais. <br />
<br />
O propósito deste guia é documentar algumas das diferenças específicas que freqüentemente são encontradas durante o processo de conversão de código ao traduzir código existente de Delphi para Lazarus. <br />
<br />
Este documento foi colocado na área de conhecimento-base de wiki para que assim pudesse ser estendido facilmente por qualquer um que tenha encontrado um problema sem igual e gostaria de postar isto para outros estarem atentos<br />
<br />
== Selecting a component or library for conversion ==<br />
<br />
=== Where to find code to convert ===<br />
<br />
There is a LOT of code available on the net that can be converted for use with FPC and Lazarus. Here is a [[Page Of Code Sites]] that is just a start. Please add to it if you know of any other good locations. TurboPower Software has recently released their entire commercial offering under the MPL. A list of available packages can be found [http://sourceforge.net/users/tpsfadmin/ here].<br />
<br />
To avoid duplicating effort, packages that have already been converted are listed on the [[Components and Code examples]] page. If you've converted a package or are working on one, please add a note on the [[Current conversion projects]] page.<br />
<br />
=== Licensing ===<br />
<br />
Licenses for existing code range from freeware/public domain to restrictive versions that prohibit modification, re-distribution and commercial use. Before converting any package, it's a good idea to examine its licensing and make sure it's going to be compatible with Lazarus and the Free Pascal Compiler. License selection is especially important with components since dropping one on a form can impose an unwanted or incompatible license on an entire application.<br />
<br />
When converting components, please respect the wishes of the original author and retain all copyright and licensing headers along with email addresses and url's. It's courteous and often useful to inform the author that their component is being converted... especially if the component is under a restrictive license. New interest in an old or forgotten component can sometimes inspire authors to revise their original and overly restrictive licensing.<br />
<br />
In general, Public Domain (freeware), and the LGPL/MPL are the the most flexible for distributing components. For more information, the [http://www.opensource.org/docs/definition.php Open Source Definition] is a good place to start. There are also several comparisons available to help clarify how the various types of licenses work and what impact they'll have on code they're linked to. Search for "open source license comparison"<br />
<br />
=== Dependencies ===<br />
<br />
Another step before starting to work on a conversion is to verify that the code doesn't have deep dependancies on other packages that might not be available or represent a considerable conversion challenge. Some freeware offerings are bound to or extend proprietary packages that are frequently no longer available or come with inappropriate licenses.<br />
<br />
=== Compiler Issues ===<br />
<br />
Currently the stable 1.0.x version of the [[Free Pascal]] Compiler doesn't support interfaces, threads or Variant records. If the code you're converting needs these constructs, you'll have to use the 1.1 development branch of the compiler... which isn't always guaranteed to work with Lazarus.<br />
<br />
See also:<br />
* [http://www.freepascal.org/probs.html Known problems]<br />
* [http://www.freepascal.org/bugs/db.php3?statusfield=Unfixed Unfixed bugs]<br />
<br />
=== Platform and OS Issues ===<br />
<br />
Lazarus and the Free Pascal Compiler are cross-platform and cross-architecture development tools. In contrast, most existing Delphi code was specifically designed to run on an Intel processor under Win32. If your candidate component has a lot of Win32 specific code, it might be wise to try and find a less platform dependant alternative. But don't let this stop you... it's genuinely amazing what the LCL supports!<br />
<br />
== Fazendo a conversão ==<br />
<br />
=== Montando o ambiente de Lazarus para um projeto de conversão ===<br />
<br />
====Crie um projeto teste====<br />
* Coloque o código a ser convertido em um subdiretório (ie: convertdir) <br />
* Abra-o com o Lazarus <br />
* File->Save All para o subdiretório de convertdir. Meaningful names for the Project and default unit are optional. <br />
* Open the "main" unit to be converted in convertdir * Add it to the project: Project->Add Active Unit to Project * Run Tools->Quick Syntax Check or Run Build All to get started. <br />
* Run Tools->Quick Syntax Check or Run Build All to get started.<br />
====Termos iniciais para se cuidar====<br />
* Nomes de arquivos são sensíveis ao letras maiúsculas e minúsculas nos compiladores da série 1.0.x Se você estiver trabalhando com uma versão como essa, faça com que todos os seus arquivos sejam escritos em minúsculas, pois do contrário, você terá como frase de erro "File not found" - arquivo não encontrado.<br />
====Fontes Delphi VCL, Kylix CLX no Lazarus====<br />
<br />
Ao converter fontes de Delphi/Kylix, é freqüentemente útil fazer uma declaração sobre o que uma função específica está fazendo. A IDE Lazarus pode analisar as fontes de Delphi/Kylix. Para isto, é necessário indicar o local dos arquivos para o compilador. Pode-se conseguir isso através do menu Environment->CodeTools Defines Editor->Insert Template<br />
<br />
=== Problemas de conversão e soluções ===<br />
<br />
==== Arquivos Delphi / Kylix equivalentes no Lazarus ====<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi / Kylix || class="header" | Lazarus || class="header" | Descrição<br />
|- class="code"<br />
| class="code" |.pas<br />
.dfm / .xfm<br />
.dcu / .dpu<br />
.dpr<br />
.res<br />
.dof / .kof<br />
---<br />
---<br />
---<br />
| class="code" |.pas, .pp<br />
.lfm<br />
.o<br />
.lpr<br />
---<br />
---<br />
.lrs<br />
.lpi<br />
.ppu<br />
| class="code" |Arquivo unit de Pascal<br />
Arquivos de dados do form<br />
Arquivo da unit compilada<br />
Arquivo do Projeto<br />
Arquivo de recursos<br />
Arquivo de opções do projeto<br />
Arquivo de recursos do Lazarus<br />
Arquivo de informações do projeto<br />
Arquivo de descrição de unit FPC<br />
|}<br />
<br />
==== Converting Delphi projects/forms/units to Lazarus ====<br />
<br />
Rename or copy the .dpr file to a .lpr file. Comment out or remove the <div class="dir">{$R *.res}</div> directive and add a <div class="dir">{$mode delphi}{$H+}</div> or <div class="dir">{$mode objfpc}{$H+}</div> directive to the .lpr file. The Lazarus IDE can assist in this conversion through the Tools menu item "Convert Delphi Project to Lazarus Project". It asks for a .dpr (Delphi Project) file and converts it to .lpr; furthermore, it creates the .lpi file.<br />
<br />
Many existing Delphi forms can be converted to work with Lazarus by using the IDE's built in .dfm to .lfm form converter. It can be found under the Tools menu item as "Convert DFM file to LFM". Bring up the file dialog, select the dfm and the converter will do the rest.<br />
<br />
If you need to convert the whole unit (with or without a form), Lazarus also includes a built in "Convert Delphi unit to Lazarus unit" which will do the following for you -<br />
<br />
# renames the .pas and .dfm file to lowercase.<br />
# converts .dfm file to .lfm file (currently without content check, just format)<br />
# creates an empty .lrs file (the content will be created later)<br />
# adds <div class="dir">{$mode delphi}</div> directive<br />
# replaces windows unit with LCLIntf<br />
# adds LResources unit if needed (i.e., if unit.lrs is to be used; <div class="dir">uses LResources </div> can be in the implementation part)<br />
# removes variants unit<br />
# removes <div class="dir">{$R *.dfm}</div> directive<br />
# adds initialization section and <div class="dir">{$i unit.lrs}</div> directive<br />
<br />
This allows quick and easy conversion of most units from Delphi format to Lazarus format. It does not do any validity check, or automatic syntax changes, so any syntax changes you need to make, additional unit/unit name changes, or dfm/pas changes for control/component differences you must still do manually, though in time some wizards to help facilitate some of this, especially the repairing of converted forms(lfm), may become available.<br />
<br />
==== Selecting the right compiler mode ====<br />
<br />
The [[Free Pascal]] Compiler supports 5 different pascal modes. For example TP for turbo pascal, lets you compile turbo pascal units. There is also a DELPHI compatibility mode that can be set to make existing code easier to convert. Lazarus prefers the OBJFPC mode, which almost equals the DELPHI mode, but is less ambigious than the Delphi syntax. Here are the important points:<br />
<br />
The mode can be selected at command line or at the start of the source. Using the command line has the advantage, that you don't need to change the source, but the disadvantage, that others must be told.<br />
<br />
Most Delphi units can be compiled by the [[Free Pascal]] compiler by adding <br />
{$IFDEF FPC}<br />
{$MODE DELPHI}<br />
{$ENDIF}<br />
right after the unit name.<br />
<br />
For more details about [[Free Pascal]] modes see the [http://www.freepascal.org/docs-html/prog/progap4.html#progse62.html Free Pascal Documentation]<br />
<br />
==== Cross-Platform considerations ====<br />
<br />
* Inline assembler is always a problem because it will bind the code to the Intel architecture. Some developers do algorithm prototypes in Pascal and ifdef the their optimized assembler. Fortunately TurboPower did this in numerous places with their code. If this is the case with the package you're converting, throw the switch back to Pascal.<br />
* Don't reference specific memory location like the BIOS data area. Find out what the code needs and try to find a cross platform alternative.<br />
* Don't do processor specific tricks (like using the Intel TSC) without enclosing your code in an ifdef for the platform the code needs... and providing an alternative for environments that don't have the hardware capability.<br />
* If you need some OS specific code, then you can use IFDEFs. See below for a list of macros.<br />
<br />
==== Useful compiler variables ====<br />
<br />
To write code, that behaves on different systems differently, you can use the <div class="dir">{$IFDEF Name}</div> directives.<br />
<br />
* <div class="dir">{$IfDef LCL}</div><br />
This variable is defined, when using the LCL package. Useful to write code, that works with the LCL and Delphi.<br />
* <div class="dir">{$IfDef FPC}</div><br />
This variable is defined, when using the FPC compiler. Useful to write code, that works with FPC and Delphi.<br />
* <div class="dir">{$IfDef Unix}</div>, <div class="dir">{$IfDef Win32}</div>, ...<br />
Defined by FPC for the current Target OS. Delphi defines "Linux", "Win32" and "MSWindows". [[Free Pascal]] runs on much more platforms and so it is recommended to use the more general items. For example "Unix" is defined for Linux, FreeBSD, NetBSD and OpenBSD, where Lazarus already runs.<br />
Use<br />
{$IfDef Linux}<br />
{$Define Unix}<br />
{$EndIf}<br />
to work around this for Kylix.<br />
<br />
For more details see the [http://www.freepascal.org/docs-html/prog/prog.html#QQ2-23-21 Free Pascal Documentation].<br />
<br />
==== Finding a missing identifier ====<br />
<br />
There are differences in how the LCL is organized when compared to the Delphi VCL. If you get a "not found" compiler error about a major class or identifier, the chances are good that it's in a different unit. A complete cross reference can be found by grep'ing lazarus/docs/xml or the lcl subdirectory.<br />
<br />
For example the commonly used tbutton typically throws an error in Delphi code because it's located in a unit named buttons.pp. The following command finds the correct unit very quickly (in the lazarus source directory):<br />
<br />
grep -in ' tbutton =' lcl/*<br />
<br />
<br />
==== Major unit differences between Lazarus and Delphi ====<br />
<br />
** Please add to this topic! **<br />
<br />
* Windows->Interfaces, LCLIntf, LCLType, LCLProc, VCLGlobals, ...)<br />
<br />
As the LCL is not windows specific, the code that is in the Delphi Windows unit for directly accessing the Win32 API is abstracted into seperate interfaces, which can be accessed from the LCLIntf unit. Keep in mind, that Lazarus does not emulate win32, so many functions are missing and some do not work as their win32 counterparts. These functions only exist for Delphi compatibility and should only be used for quick & dirty porting. LCL also breaks out many of the types, so often LCLType, and sometimes VCLGlobals are required. LCLProc also contains a few functions which can be useful for lower level handling such as "FreeThenNil" as is in Delphi 5 and higher, "DeleteAmpersands" to remove additional ampersands from a string for controls(& vs && etc). The Interfaces unit needs to be included in the .lpr file to initialize the appropriate widgetset.<br />
<br />
* Messages->LMessages<br />
<br />
TControl Messages for win32 event callbacks of the format WM_CALLBACK and the structs associated with them are often found in the Messages unit in Delphi. In the LCL these types of messages and there structs are usually found in LMessages, usually with name changes of WM to LM, so for instance WM_MOUSEENTER becomes LM_MOUSEENTER, and TWMMouse becomes TLMMouse.<br />
<br />
* Graphics, Controls->GraphTypes, GraphMath, Graphics, Controls<br />
<br />
To simplify some things and break complexity of circles between units, a few types have been abstracted into a shared unit called GraphType, which includes things, which in Delphi are located in Graphics or Controls, for instance the bvNone etc of panels. So sometimes you have to include it. Also a unit which, although incompatible with Delphi, adds other useful functionality is GraphMath, which adds a TFloatPoint for precision, misc routines for dealing with beziers, lines, and arcs, as well as some operator overloading for use with TPoints and TRect, such as for instance Point1 := Point2 + Point3, and comparing two rects like if (rect1 = rect2) then ...<br />
<br />
* Mask->MaskEdit<br />
<br />
For more intelligent naming considerations, the unit for TMaskEdit is called [MaskEdit|] instead of the slightly more nebulous Mask as in many versions of Delphi.<br />
<br />
* StdCtrls->StdCtrls,Buttons<br />
<br />
In many version of Delphi TButton is located in StdCtrls, while TSpeedButton and TBitBtn are in Buttons. For consistency and simplicity the LCL puts all button types in Buttons, which can occasionally break code conversion, so it is always a good idea to include.<br />
<br />
==== Property and method differences Delphi -> FPC/LCL ====<br />
* TBitmap contains a canvas in the LCL<br />
==== Syntax differences ====<br />
<br />
'''Please add to this topic!'''<br />
<br />
Because of the inherent strictness in FPC, some syntax changes are necessary, even though <div class="dir">{$Mode Delphi}</div> does allow more laziness like Delphi does. For this reason complying as much with the syntax rules of <div class="dir">{$Mode ObjFPC}</div> as possible is highly recommended, even when the codebase is still going to be shared between Delphi and the LCL. Some of these are simply better coding practices, and sometimes because Delphi mode is not entirely accurate, or in a few instances Delphi acceptible code does not function as expected with FPC, even though it might compile. To that end even though not all such are strictly required, the following list of changes should be considered mandatory :<br />
<br />
<br />
;When assigning an event handling entry point, prefix it with an "@"<br />
<br />
For instance, you might assign a button callback manually <br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">begin</div> <br />
<div class="key">if not</div> Assigned(MyButton.OnClick) <div class="key">then</div><br />
MyButton.OnClick:= SomeFunction; <div class="cmt">//@ not required</div><br />
<div class="cmt">//more code...</div><br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">begin</div><br />
<div class="key">if not</div> Assigned(MyButton.OnClick) <div class="key">then</div><br />
MyButton.OnClick:= @SomeFunction; <div class="cmt">//@ IS required</div><br />
<div class="cmt">//more code...</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
;When calling a procedure variable use this syntax: theprocname()<br />
<br />
In Delphi there is no difference between a function result and a variable, however there is in FPC, so to call a function, even if it has no parameters, you must append parenthesis. For Example -<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">With</div> (SomeObject) <div class="key">do begin</div> <br />
<div class="key">If</div> Assigned(OnMyCallback) <div class="key">then</div> <br />
OnMyCallback; <div class="cmt">//parenthesis not required</div> <br />
<div class="key">end</div>; <br />
| class="code" | <div class="key">With</div> (SomeObject) <div class="key">do begin</div><br />
<div class="key">If</div> Assigned(OnMyCallback) <div class="key">then</div><br />
OnMyCallback(); <div class="cmt">//parenthesis required</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
;When accessing values in a pointer to a record you must dereference first<br />
<br />
In Delphi it is not required to de-reference a pointer to a record to access values within it, it can, in fact, be treated just like the record itself, or any other object. In FPC it must be first de-referenced. As an example,<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">Function</div> GetSomeValue(ARecord: PMyRecord) <br />
<div class="symbol">:</div> Integer;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Assigned(ARecord) <div class="key">then</div><br />
Result<div class="symbol">:=</div> ARecord.SomeValue<br />
<div class="key">else</div><br />
Result:= <div class="int">0</div>;<br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">Function</div> GetSomeValue(ARecord: PMyRecord) <br />
<div class="symbol">:</div> Integer;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Assigned(ARecord) <div class="key">then</div><br />
Result<div class="symbol">:=</div> ARecord^.SomeValue<br />
<div class="key">else</div><br />
Result:= <div class="int">0</div>;<br />
<div class="key">end</div>; <br />
|}<br />
<br />
;When accessing chars of an indexed string Property of an object, it must be enclosed in parentheses<br />
<br />
With Delphi it is possible to treat a Property exactly like some other const or var, even to accessing for instance individual chars of a string directly, while this is not always possible in FPC, specifically for indexed properties. Instead it must be enclosed in parentheses, to make distinct. While this may not always hold true it is probably a good practice to consider anyway. For example<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
<div class="key">Property</div> MyString: <div class="key">String</div> <div class="key">index</div> <div class="int">3</div><br />
<div class="key">read</div> GetMyString;<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">var</div><br />
MyChar<div class="symbol">:</div> char;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Length(MyString)> <div class="int">2</div> <div class="key">then</div><br />
<div class="cmt">//no parenthesis needed</div><br />
MyChar:= MyString[<div class="int">3</div>];<br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
<div class="key">Property</div> MyString: <div class="key">String</div> <div class="key">index</div> <div class="int">3</div><br />
<div class="key">read</div> GetMyString;<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">var</div><br />
MyChar<div class="symbol">:</div> char;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Length(MyString)> <div class="int">2</div> <div class="key">then</div><br />
<div class="cmt">//parenthesis sometimes needed</div><br />
MyChar:= (MyString)[<div class="int">3</div>];<br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
<br />
;You must typecast pointers to actual type when using with var or function of that type<br />
<br />
Sometimes in Delphi you will have a null pointer variable representing an object. While it might seem a complex situation, it is oddly quite common especially in large component packs as a method of preventing too many circular includes between objects in different units. In Delphi it is then possible to send this null pointer to a function expecting that object, without bothering to typecast to actual type, in fpc you must typecast. <br />
<br />
For example -<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" |Unit 1<br />
<div class="key">Type</div> TSomeObject= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">Procedure</div> DoSomething(Value: TSomeObject);<br />
<div class="key">Function</div> GetSomeObject: TSomeObject;<br />
<div></div> <br />
<div class="symbol">Unit 2</div><br />
<div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
SomeObject: Pointer<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div><br />
<div class="symbol">Application</div><br />
<div class="key">var</div><br />
MyComponent: TSomeComponent<div class="symbol">;</div><br />
<div class="key">begin</div><br />
MyComponent.SomeObject<div class="symbol">:=</div> GetSomeObject;<br />
<div class="cmt">//More code...</div><br />
DoSomething(MyComponent.SomeObject)<div class="symbol">;</div><br />
<div class="key">end</div>;<br />
| class="code" |Unit 1<br />
<div class="key">Type</div> TSomeObject= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">Procedure</div> DoSomething(Value: TSomeObject);<br />
<div class="key">Function</div> GetSomeObject: TSomeObject;<br />
<div></div> <br />
<div class="symbol">Unit 2</div><br />
<div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
SomeObject: Pointer<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="symbol">Application</div> <br />
<div class="key">var</div><br />
MyComponent: TSomeComponent<div class="symbol">;</div><br />
<div class="key">begin</div><br />
MyComponent.SomeObject<div class="symbol">:=</div> Pointer(GetSomeObject);<br />
<div class="cmt">//More code...</div><br />
DoSomething(TSomeObject(MyComponent.SomeObject))<div class="symbol">;</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
==== Resources ====<br />
<br />
Delphi resource files are win32 specific and not compatible with Lazarus, so you'll have to recreate and compile them using the lazres. Lazres can be found in the lazarus/tools subdirectory. If you've downloaded the Lazarus sources, you'll need to compile it first.<br />
* cd lazarus/tools<br />
* make install<br />
To add a resource to your application:<br />
* lazres myresource.lrs mypix.xpm anotherpix.xpm<br />
* Add the LResources unit to your Uses clause<br />
* Include the .lrs file you created under the initialization block<br />
Example:<br />
{| class="code" <br />
|- class="code"<br />
| class="code" | <div class="key">function</div> TForm1.LoadGlyph(<div class="key">const</div> GlyphName: <div class="key">String</div>): TBitMap;<br />
<div class="key">begin</div><br />
Result:= TPixmap.Create<div class="symbol">;</div><br />
Result.LoadFromLazarusResource(GlyphName)<div class="symbol">;</div><br />
<div class="key">end</div>; <br />
<div class="cmt">//More code...</div><br />
<div class="key">begin</div><br />
Speedbutton1.glyph:= LoadGlyph('mypix')<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
<div></div> <br />
<div class="key">initialization</div><br />
<div class="dir">{$I unit1.lrs}</div><br />
<div class="dir">{$I myresource.lrs}</div><br />
<div class="key">end</div>.<br />
|}<br />
<br />
== Getting Help ==<br />
<br />
If you encounter a problem during conversion that you just can't solve, there are a wide variety of places to get help. For pure Object Pascal and FPC issues, the best place to start is the Free Pascal [http://www.freepascal.org/docs-html/ Documentation] by Michaël Van Canneyt and Florian Klämpfl. For more Lazarus oriented problems, the Lazarus Project Documentation in the Lazarus-CCR Knowledgebase [Main Page] is the next place to look. Finally you can post a question on any of the [http://www.freepascal.org/maillist.html mailing lists for the Free Pascal Compiler] or the [http://community.freepascal.org:10000/bboard/ FPC forums] where a lot of experts are subscribed.<br />
<br />
There are some outstanding search and knowledge bases online that can also be a great help for learning new techniques and solving problems. Tamarack Associates operates a fast [http://www.tamaracka.com/search.htm search] engine specifically for the Borland usenet archives. Mer Systems Inc. provides a similar search [http://www.mers.com/searchsite.html engine]. Another outstanding source of information along with a sitewide [http://www.efg2.com/Lab/search.htm search] capability is Earl F. Glynn's Computer Lab and Reference [http://www.efg2.com/ Library].<br />
<br />
== Packaging and Releasing your component ==<br />
<br />
=== Creating a Lazarus package for your component(s) ===<br />
<br />
Creating a package makes installing the code you've converted a much easier process... especially if you're providing more then one component. Mattias Gärtner has written an overview of [[Lazarus Packages]] that should be read before beginning this process.<br />
<br />
=== Documentation ===<br />
<br />
The purpose of this site and the wiki format is to make the generation of professional documentation an easy and quick process. The wiki also makes it possible to see the results of your posting immediately and make any changes you'd like in real time.<br />
<br />
Using the Lazarus-CCR wiki to create nice looking documentation is very easy. If you've never used wiki markup before, you can get familiar with it in the [[Sand Box]] practice area.<br />
<br />
=== Creating a Code Release Page ===<br />
<br />
The Code Release Page contains vital information about your component that a potential downloader will need to know, such as license, intended platform, status (alpha, beta, stable...), where to download it, who wrote it, is support available... etc.<br />
<br />
The following procedure will let you create a Code Release Page with your browser: <br />
<br />
* Edit the [[Components and Code examples]] page and add a project name wiki link entry for your component in the "Released Components" section. Save the modified page.<br />
<br />
* Go to the [[Component Release Template]], select all and copy. Hit the back button on your browser to return to the [[Components and Code examples]] page.<br />
* Click on your new wiki component name entry and paste the release template into the blank edit box.<br />
* Edit the template accordingly and hit save.<br />
* Do edit-saves until your document looks the way you want it to.<br />
<br />
=== Submitting the component ===<br />
<br />
If you're a release technician on the project, upload your component to the SourceForge File Release System and add it to the list of release packages. Otherwise send it to one of the project administrators ([[User:Tom | Tom Lisjac]] or [[User:Vincent | Vincent Snijders]]) and we'll add it to the repository. <br />
<br />
If you think you need to continue to develop on the component, we can also put it into CVS so you'll continue to have access to it.<br />
<br />
== Contributors and Changes ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=CodeConversionGuide version].<br />
* Initial version by Tom Lisjac and Mattias Gärtner - 9/22/2003 [[User:Tom | VlxAdmin]]<br />
* Moved Getting help from the main page. T. Lisjac - 9/24/2003 [[User:Tom | VlxAdmin]]<br />
* Added documentation templates, procedure and links. 9/25/2003 [[User:Tom | VlxAdmin]]<br />
* LCLLinux was renamed to LCLIntf, [[User:Jesusrmx | Jesus Reyes]], 9/27/2003<br />
* added more information on Unit changes, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* Updated Syntax differences, including some examples, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* FPC 1.0.x doesn't support interfaces, [[User:Vincent | Vincent Snijders]] 9/28/2003<br />
* Fixed some of the examples per new WikiWord definition, 9/28/2003 [[User:Tom | VlxAdmin]]<br />
* Made code more consistant to remove last accidental Pascal WikiWord definitions, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* Use tables for code examples for nice blocks, and easy side by side view of Delphi->FPC differences, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 10/17/2003<br />
* Use pascal stylesheet to make example code more readable, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 10/18/2003</div>Fititnthttps://wiki.freepascal.org/index.php?title=Code_Conversion_Guide/pt&diff=3806Code Conversion Guide/pt2005-11-20T20:56:27Z<p>Fititnt: </p>
<hr />
<div>Guia de conversão do Delphi para o Lazarus <br />
<br />
== Sobre ==<br />
<br />
Esta página é sobre como converter um código para poder usá-lo no compilador [[Free Pascal]] e a IDE do Lazarus. O Lazarus e o Free Pascal tem aspectos em comum com o Delphi e Kylix, porém, não são clones. há várias diferenças nos códigos e convenções... e em algumas áreas, o FPC pode exigir uma sintaxe mais correta. Por favor veja o [[Lazarus For Delphi Users]] guia para uma descrição de algumas das diferenças funcionais. <br />
<br />
O propósito deste guia é documentar algumas das diferenças específicas que freqüentemente são encontradas durante o processo de conversão de código ao traduzir código existente de Delphi para Lazarus. <br />
<br />
Este documento foi colocado na área de conhecimento-base de wiki para que assim pudesse ser estendido facilmente por qualquer um que tenha encontrado um problema sem igual e gostaria de postar isto para outros estarem atentos<br />
<br />
== Selecting a component or library for conversion ==<br />
<br />
=== Where to find code to convert ===<br />
<br />
There is a LOT of code available on the net that can be converted for use with FPC and Lazarus. Here is a [[Page Of Code Sites]] that is just a start. Please add to it if you know of any other good locations. TurboPower Software has recently released their entire commercial offering under the MPL. A list of available packages can be found [http://sourceforge.net/users/tpsfadmin/ here].<br />
<br />
To avoid duplicating effort, packages that have already been converted are listed on the [[Components and Code examples]] page. If you've converted a package or are working on one, please add a note on the [[Current conversion projects]] page.<br />
<br />
=== Licensing ===<br />
<br />
Licenses for existing code range from freeware/public domain to restrictive versions that prohibit modification, re-distribution and commercial use. Before converting any package, it's a good idea to examine its licensing and make sure it's going to be compatible with Lazarus and the Free Pascal Compiler. License selection is especially important with components since dropping one on a form can impose an unwanted or incompatible license on an entire application.<br />
<br />
When converting components, please respect the wishes of the original author and retain all copyright and licensing headers along with email addresses and url's. It's courteous and often useful to inform the author that their component is being converted... especially if the component is under a restrictive license. New interest in an old or forgotten component can sometimes inspire authors to revise their original and overly restrictive licensing.<br />
<br />
In general, Public Domain (freeware), and the LGPL/MPL are the the most flexible for distributing components. For more information, the [http://www.opensource.org/docs/definition.php Open Source Definition] is a good place to start. There are also several comparisons available to help clarify how the various types of licenses work and what impact they'll have on code they're linked to. Search for "open source license comparison"<br />
<br />
=== Dependencies ===<br />
<br />
Another step before starting to work on a conversion is to verify that the code doesn't have deep dependancies on other packages that might not be available or represent a considerable conversion challenge. Some freeware offerings are bound to or extend proprietary packages that are frequently no longer available or come with inappropriate licenses.<br />
<br />
=== Compiler Issues ===<br />
<br />
Currently the stable 1.0.x version of the [[Free Pascal]] Compiler doesn't support interfaces, threads or Variant records. If the code you're converting needs these constructs, you'll have to use the 1.1 development branch of the compiler... which isn't always guaranteed to work with Lazarus.<br />
<br />
See also:<br />
* [http://www.freepascal.org/probs.html Known problems]<br />
* [http://www.freepascal.org/bugs/db.php3?statusfield=Unfixed Unfixed bugs]<br />
<br />
=== Platform and OS Issues ===<br />
<br />
Lazarus and the Free Pascal Compiler are cross-platform and cross-architecture development tools. In contrast, most existing Delphi code was specifically designed to run on an Intel processor under Win32. If your candidate component has a lot of Win32 specific code, it might be wise to try and find a less platform dependant alternative. But don't let this stop you... it's genuinely amazing what the LCL supports!<br />
<br />
== Doing the conversion ==<br />
<br />
=== Setting up the Lazarus environment for a conversion project ===<br />
<br />
====Create a test project====<br />
* Place code to be converted into a subdirectory (ie: convertdir)<br />
* Bring up Lazarus<br />
* File->Save All to the convertdir subdirectory. Meaningful names for the Project and default unit are optional.<br />
* Open the "main" unit to be converted in convertdir<br />
* Add it to the project: Project->Add Active Unit to Project<br />
* Run Tools->Quick Syntax Check or Run Build All to get started.<br />
====Initial items to watch out for====<br />
* Filenames are case sensitive with the 1.0.x series compilers. If you're working with this version, make all your filenames lower case. You'll get "File not found" errors if you don't.<br />
====Delphi VCL, Kylix CLX Sources in Lazarus====<br />
<br />
When converting Delphi/Kylix sources, it is often useful to do a find declaration to see, what a specific function is doing. The Lazarus IDE can parse the Delphi/Kylix sources. To do this it needs some searchpaths and compiler settings. You can easily setup this in<br />
Environment->CodeTools Defines Editor->Insert Template<br />
<br />
=== Conversion problems and solutions ===<br />
<br />
==== Delphi / Kylix file equivalents in Lazarus ====<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi / Kylix || class="header" | Lazarus || class="header" | Description<br />
|- class="code"<br />
| class="code" |.pas<br />
.dfm / .xfm<br />
.dcu / .dpu<br />
.dpr<br />
.res<br />
.dof / .kof<br />
---<br />
---<br />
---<br />
| class="code" |.pas, .pp<br />
.lfm<br />
.o<br />
.lpr<br />
---<br />
---<br />
.lrs<br />
.lpi<br />
.ppu<br />
| class="code" |Pascal unit file<br />
Form data file<br />
Compiled unit file<br />
Project file<br />
Resource file<br />
Project options file<br />
Lazarus resource file<br />
Lazarus project information file<br />
FPC unit description file<br />
|}<br />
<br />
==== Converting Delphi projects/forms/units to Lazarus ====<br />
<br />
Rename or copy the .dpr file to a .lpr file. Comment out or remove the <div class="dir">{$R *.res}</div> directive and add a <div class="dir">{$mode delphi}{$H+}</div> or <div class="dir">{$mode objfpc}{$H+}</div> directive to the .lpr file. The Lazarus IDE can assist in this conversion through the Tools menu item "Convert Delphi Project to Lazarus Project". It asks for a .dpr (Delphi Project) file and converts it to .lpr; furthermore, it creates the .lpi file.<br />
<br />
Many existing Delphi forms can be converted to work with Lazarus by using the IDE's built in .dfm to .lfm form converter. It can be found under the Tools menu item as "Convert DFM file to LFM". Bring up the file dialog, select the dfm and the converter will do the rest.<br />
<br />
If you need to convert the whole unit (with or without a form), Lazarus also includes a built in "Convert Delphi unit to Lazarus unit" which will do the following for you -<br />
<br />
# renames the .pas and .dfm file to lowercase.<br />
# converts .dfm file to .lfm file (currently without content check, just format)<br />
# creates an empty .lrs file (the content will be created later)<br />
# adds <div class="dir">{$mode delphi}</div> directive<br />
# replaces windows unit with LCLIntf<br />
# adds LResources unit if needed (i.e., if unit.lrs is to be used; <div class="dir">uses LResources </div> can be in the implementation part)<br />
# removes variants unit<br />
# removes <div class="dir">{$R *.dfm}</div> directive<br />
# adds initialization section and <div class="dir">{$i unit.lrs}</div> directive<br />
<br />
This allows quick and easy conversion of most units from Delphi format to Lazarus format. It does not do any validity check, or automatic syntax changes, so any syntax changes you need to make, additional unit/unit name changes, or dfm/pas changes for control/component differences you must still do manually, though in time some wizards to help facilitate some of this, especially the repairing of converted forms(lfm), may become available.<br />
<br />
==== Selecting the right compiler mode ====<br />
<br />
The [[Free Pascal]] Compiler supports 5 different pascal modes. For example TP for turbo pascal, lets you compile turbo pascal units. There is also a DELPHI compatibility mode that can be set to make existing code easier to convert. Lazarus prefers the OBJFPC mode, which almost equals the DELPHI mode, but is less ambigious than the Delphi syntax. Here are the important points:<br />
<br />
The mode can be selected at command line or at the start of the source. Using the command line has the advantage, that you don't need to change the source, but the disadvantage, that others must be told.<br />
<br />
Most Delphi units can be compiled by the [[Free Pascal]] compiler by adding <br />
{$IFDEF FPC}<br />
{$MODE DELPHI}<br />
{$ENDIF}<br />
right after the unit name.<br />
<br />
For more details about [[Free Pascal]] modes see the [http://www.freepascal.org/docs-html/prog/progap4.html#progse62.html Free Pascal Documentation]<br />
<br />
==== Cross-Platform considerations ====<br />
<br />
* Inline assembler is always a problem because it will bind the code to the Intel architecture. Some developers do algorithm prototypes in Pascal and ifdef the their optimized assembler. Fortunately TurboPower did this in numerous places with their code. If this is the case with the package you're converting, throw the switch back to Pascal.<br />
* Don't reference specific memory location like the BIOS data area. Find out what the code needs and try to find a cross platform alternative.<br />
* Don't do processor specific tricks (like using the Intel TSC) without enclosing your code in an ifdef for the platform the code needs... and providing an alternative for environments that don't have the hardware capability.<br />
* If you need some OS specific code, then you can use IFDEFs. See below for a list of macros.<br />
<br />
==== Useful compiler variables ====<br />
<br />
To write code, that behaves on different systems differently, you can use the <div class="dir">{$IFDEF Name}</div> directives.<br />
<br />
* <div class="dir">{$IfDef LCL}</div><br />
This variable is defined, when using the LCL package. Useful to write code, that works with the LCL and Delphi.<br />
* <div class="dir">{$IfDef FPC}</div><br />
This variable is defined, when using the FPC compiler. Useful to write code, that works with FPC and Delphi.<br />
* <div class="dir">{$IfDef Unix}</div>, <div class="dir">{$IfDef Win32}</div>, ...<br />
Defined by FPC for the current Target OS. Delphi defines "Linux", "Win32" and "MSWindows". [[Free Pascal]] runs on much more platforms and so it is recommended to use the more general items. For example "Unix" is defined for Linux, FreeBSD, NetBSD and OpenBSD, where Lazarus already runs.<br />
Use<br />
{$IfDef Linux}<br />
{$Define Unix}<br />
{$EndIf}<br />
to work around this for Kylix.<br />
<br />
For more details see the [http://www.freepascal.org/docs-html/prog/prog.html#QQ2-23-21 Free Pascal Documentation].<br />
<br />
==== Finding a missing identifier ====<br />
<br />
There are differences in how the LCL is organized when compared to the Delphi VCL. If you get a "not found" compiler error about a major class or identifier, the chances are good that it's in a different unit. A complete cross reference can be found by grep'ing lazarus/docs/xml or the lcl subdirectory.<br />
<br />
For example the commonly used tbutton typically throws an error in Delphi code because it's located in a unit named buttons.pp. The following command finds the correct unit very quickly (in the lazarus source directory):<br />
<br />
grep -in ' tbutton =' lcl/*<br />
<br />
<br />
==== Major unit differences between Lazarus and Delphi ====<br />
<br />
** Please add to this topic! **<br />
<br />
* Windows->Interfaces, LCLIntf, LCLType, LCLProc, VCLGlobals, ...)<br />
<br />
As the LCL is not windows specific, the code that is in the Delphi Windows unit for directly accessing the Win32 API is abstracted into seperate interfaces, which can be accessed from the LCLIntf unit. Keep in mind, that Lazarus does not emulate win32, so many functions are missing and some do not work as their win32 counterparts. These functions only exist for Delphi compatibility and should only be used for quick & dirty porting. LCL also breaks out many of the types, so often LCLType, and sometimes VCLGlobals are required. LCLProc also contains a few functions which can be useful for lower level handling such as "FreeThenNil" as is in Delphi 5 and higher, "DeleteAmpersands" to remove additional ampersands from a string for controls(& vs && etc). The Interfaces unit needs to be included in the .lpr file to initialize the appropriate widgetset.<br />
<br />
* Messages->LMessages<br />
<br />
TControl Messages for win32 event callbacks of the format WM_CALLBACK and the structs associated with them are often found in the Messages unit in Delphi. In the LCL these types of messages and there structs are usually found in LMessages, usually with name changes of WM to LM, so for instance WM_MOUSEENTER becomes LM_MOUSEENTER, and TWMMouse becomes TLMMouse.<br />
<br />
* Graphics, Controls->GraphTypes, GraphMath, Graphics, Controls<br />
<br />
To simplify some things and break complexity of circles between units, a few types have been abstracted into a shared unit called GraphType, which includes things, which in Delphi are located in Graphics or Controls, for instance the bvNone etc of panels. So sometimes you have to include it. Also a unit which, although incompatible with Delphi, adds other useful functionality is GraphMath, which adds a TFloatPoint for precision, misc routines for dealing with beziers, lines, and arcs, as well as some operator overloading for use with TPoints and TRect, such as for instance Point1 := Point2 + Point3, and comparing two rects like if (rect1 = rect2) then ...<br />
<br />
* Mask->MaskEdit<br />
<br />
For more intelligent naming considerations, the unit for TMaskEdit is called [MaskEdit|] instead of the slightly more nebulous Mask as in many versions of Delphi.<br />
<br />
* StdCtrls->StdCtrls,Buttons<br />
<br />
In many version of Delphi TButton is located in StdCtrls, while TSpeedButton and TBitBtn are in Buttons. For consistency and simplicity the LCL puts all button types in Buttons, which can occasionally break code conversion, so it is always a good idea to include.<br />
<br />
==== Property and method differences Delphi -> FPC/LCL ====<br />
* TBitmap contains a canvas in the LCL<br />
==== Syntax differences ====<br />
<br />
'''Please add to this topic!'''<br />
<br />
Because of the inherent strictness in FPC, some syntax changes are necessary, even though <div class="dir">{$Mode Delphi}</div> does allow more laziness like Delphi does. For this reason complying as much with the syntax rules of <div class="dir">{$Mode ObjFPC}</div> as possible is highly recommended, even when the codebase is still going to be shared between Delphi and the LCL. Some of these are simply better coding practices, and sometimes because Delphi mode is not entirely accurate, or in a few instances Delphi acceptible code does not function as expected with FPC, even though it might compile. To that end even though not all such are strictly required, the following list of changes should be considered mandatory :<br />
<br />
<br />
;When assigning an event handling entry point, prefix it with an "@"<br />
<br />
For instance, you might assign a button callback manually <br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">begin</div> <br />
<div class="key">if not</div> Assigned(MyButton.OnClick) <div class="key">then</div><br />
MyButton.OnClick:= SomeFunction; <div class="cmt">//@ not required</div><br />
<div class="cmt">//more code...</div><br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">begin</div><br />
<div class="key">if not</div> Assigned(MyButton.OnClick) <div class="key">then</div><br />
MyButton.OnClick:= @SomeFunction; <div class="cmt">//@ IS required</div><br />
<div class="cmt">//more code...</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
;When calling a procedure variable use this syntax: theprocname()<br />
<br />
In Delphi there is no difference between a function result and a variable, however there is in FPC, so to call a function, even if it has no parameters, you must append parenthesis. For Example -<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">With</div> (SomeObject) <div class="key">do begin</div> <br />
<div class="key">If</div> Assigned(OnMyCallback) <div class="key">then</div> <br />
OnMyCallback; <div class="cmt">//parenthesis not required</div> <br />
<div class="key">end</div>; <br />
| class="code" | <div class="key">With</div> (SomeObject) <div class="key">do begin</div><br />
<div class="key">If</div> Assigned(OnMyCallback) <div class="key">then</div><br />
OnMyCallback(); <div class="cmt">//parenthesis required</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
;When accessing values in a pointer to a record you must dereference first<br />
<br />
In Delphi it is not required to de-reference a pointer to a record to access values within it, it can, in fact, be treated just like the record itself, or any other object. In FPC it must be first de-referenced. As an example,<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">Function</div> GetSomeValue(ARecord: PMyRecord) <br />
<div class="symbol">:</div> Integer;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Assigned(ARecord) <div class="key">then</div><br />
Result<div class="symbol">:=</div> ARecord.SomeValue<br />
<div class="key">else</div><br />
Result:= <div class="int">0</div>;<br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">Function</div> GetSomeValue(ARecord: PMyRecord) <br />
<div class="symbol">:</div> Integer;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Assigned(ARecord) <div class="key">then</div><br />
Result<div class="symbol">:=</div> ARecord^.SomeValue<br />
<div class="key">else</div><br />
Result:= <div class="int">0</div>;<br />
<div class="key">end</div>; <br />
|}<br />
<br />
;When accessing chars of an indexed string Property of an object, it must be enclosed in parentheses<br />
<br />
With Delphi it is possible to treat a Property exactly like some other const or var, even to accessing for instance individual chars of a string directly, while this is not always possible in FPC, specifically for indexed properties. Instead it must be enclosed in parentheses, to make distinct. While this may not always hold true it is probably a good practice to consider anyway. For example<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" | <div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
<div class="key">Property</div> MyString: <div class="key">String</div> <div class="key">index</div> <div class="int">3</div><br />
<div class="key">read</div> GetMyString;<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">var</div><br />
MyChar<div class="symbol">:</div> char;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Length(MyString)> <div class="int">2</div> <div class="key">then</div><br />
<div class="cmt">//no parenthesis needed</div><br />
MyChar:= MyString[<div class="int">3</div>];<br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
| class="code" | <div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
<div class="key">Property</div> MyString: <div class="key">String</div> <div class="key">index</div> <div class="int">3</div><br />
<div class="key">read</div> GetMyString;<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">var</div><br />
MyChar<div class="symbol">:</div> char;<br />
<div class="key">begin</div><br />
<div class="key">If</div> Length(MyString)> <div class="int">2</div> <div class="key">then</div><br />
<div class="cmt">//parenthesis sometimes needed</div><br />
MyChar:= (MyString)[<div class="int">3</div>];<br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
<br />
;You must typecast pointers to actual type when using with var or function of that type<br />
<br />
Sometimes in Delphi you will have a null pointer variable representing an object. While it might seem a complex situation, it is oddly quite common especially in large component packs as a method of preventing too many circular includes between objects in different units. In Delphi it is then possible to send this null pointer to a function expecting that object, without bothering to typecast to actual type, in fpc you must typecast. <br />
<br />
For example -<br />
{| class="code"<br />
|- <br />
| class="header" | Delphi || class="header" | FPC<br />
|- class="code"<br />
| class="code" |Unit 1<br />
<div class="key">Type</div> TSomeObject= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">Procedure</div> DoSomething(Value: TSomeObject);<br />
<div class="key">Function</div> GetSomeObject: TSomeObject;<br />
<div></div> <br />
<div class="symbol">Unit 2</div><br />
<div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
SomeObject: Pointer<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div><br />
<div class="symbol">Application</div><br />
<div class="key">var</div><br />
MyComponent: TSomeComponent<div class="symbol">;</div><br />
<div class="key">begin</div><br />
MyComponent.SomeObject<div class="symbol">:=</div> GetSomeObject;<br />
<div class="cmt">//More code...</div><br />
DoSomething(MyComponent.SomeObject)<div class="symbol">;</div><br />
<div class="key">end</div>;<br />
| class="code" |Unit 1<br />
<div class="key">Type</div> TSomeObject= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="key">Procedure</div> DoSomething(Value: TSomeObject);<br />
<div class="key">Function</div> GetSomeObject: TSomeObject;<br />
<div></div> <br />
<div class="symbol">Unit 2</div><br />
<div class="key">Type</div> TSomeComponent= <div class="key">class</div>(TComponent)<br />
<div class="cmt">//More code...</div><br />
<div class="key">Published</div><br />
SomeObject: Pointer<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">End</div>;<br />
<div></div> <br />
<div class="symbol">Application</div> <br />
<div class="key">var</div><br />
MyComponent: TSomeComponent<div class="symbol">;</div><br />
<div class="key">begin</div><br />
MyComponent.SomeObject<div class="symbol">:=</div> Pointer(GetSomeObject);<br />
<div class="cmt">//More code...</div><br />
DoSomething(TSomeObject(MyComponent.SomeObject))<div class="symbol">;</div><br />
<div class="key">end</div>;<br />
|}<br />
<br />
==== Resources ====<br />
<br />
Delphi resource files are win32 specific and not compatible with Lazarus, so you'll have to recreate and compile them using the lazres. Lazres can be found in the lazarus/tools subdirectory. If you've downloaded the Lazarus sources, you'll need to compile it first.<br />
* cd lazarus/tools<br />
* make install<br />
To add a resource to your application:<br />
* lazres myresource.lrs mypix.xpm anotherpix.xpm<br />
* Add the LResources unit to your Uses clause<br />
* Include the .lrs file you created under the initialization block<br />
Example:<br />
{| class="code" <br />
|- class="code"<br />
| class="code" | <div class="key">function</div> TForm1.LoadGlyph(<div class="key">const</div> GlyphName: <div class="key">String</div>): TBitMap;<br />
<div class="key">begin</div><br />
Result:= TPixmap.Create<div class="symbol">;</div><br />
Result.LoadFromLazarusResource(GlyphName)<div class="symbol">;</div><br />
<div class="key">end</div>; <br />
<div class="cmt">//More code...</div><br />
<div class="key">begin</div><br />
Speedbutton1.glyph:= LoadGlyph('mypix')<div class="symbol">;</div><br />
<div class="cmt">//More code...</div><br />
<div class="key">end</div>;<br />
<div></div> <br />
<div class="key">initialization</div><br />
<div class="dir">{$I unit1.lrs}</div><br />
<div class="dir">{$I myresource.lrs}</div><br />
<div class="key">end</div>.<br />
|}<br />
<br />
== Getting Help ==<br />
<br />
If you encounter a problem during conversion that you just can't solve, there are a wide variety of places to get help. For pure Object Pascal and FPC issues, the best place to start is the Free Pascal [http://www.freepascal.org/docs-html/ Documentation] by Michaël Van Canneyt and Florian Klämpfl. For more Lazarus oriented problems, the Lazarus Project Documentation in the Lazarus-CCR Knowledgebase [Main Page] is the next place to look. Finally you can post a question on any of the [http://www.freepascal.org/maillist.html mailing lists for the Free Pascal Compiler] or the [http://community.freepascal.org:10000/bboard/ FPC forums] where a lot of experts are subscribed.<br />
<br />
There are some outstanding search and knowledge bases online that can also be a great help for learning new techniques and solving problems. Tamarack Associates operates a fast [http://www.tamaracka.com/search.htm search] engine specifically for the Borland usenet archives. Mer Systems Inc. provides a similar search [http://www.mers.com/searchsite.html engine]. Another outstanding source of information along with a sitewide [http://www.efg2.com/Lab/search.htm search] capability is Earl F. Glynn's Computer Lab and Reference [http://www.efg2.com/ Library].<br />
<br />
== Packaging and Releasing your component ==<br />
<br />
=== Creating a Lazarus package for your component(s) ===<br />
<br />
Creating a package makes installing the code you've converted a much easier process... especially if you're providing more then one component. Mattias Gärtner has written an overview of [[Lazarus Packages]] that should be read before beginning this process.<br />
<br />
=== Documentation ===<br />
<br />
The purpose of this site and the wiki format is to make the generation of professional documentation an easy and quick process. The wiki also makes it possible to see the results of your posting immediately and make any changes you'd like in real time.<br />
<br />
Using the Lazarus-CCR wiki to create nice looking documentation is very easy. If you've never used wiki markup before, you can get familiar with it in the [[Sand Box]] practice area.<br />
<br />
=== Creating a Code Release Page ===<br />
<br />
The Code Release Page contains vital information about your component that a potential downloader will need to know, such as license, intended platform, status (alpha, beta, stable...), where to download it, who wrote it, is support available... etc.<br />
<br />
The following procedure will let you create a Code Release Page with your browser: <br />
<br />
* Edit the [[Components and Code examples]] page and add a project name wiki link entry for your component in the "Released Components" section. Save the modified page.<br />
<br />
* Go to the [[Component Release Template]], select all and copy. Hit the back button on your browser to return to the [[Components and Code examples]] page.<br />
* Click on your new wiki component name entry and paste the release template into the blank edit box.<br />
* Edit the template accordingly and hit save.<br />
* Do edit-saves until your document looks the way you want it to.<br />
<br />
=== Submitting the component ===<br />
<br />
If you're a release technician on the project, upload your component to the SourceForge File Release System and add it to the list of release packages. Otherwise send it to one of the project administrators ([[User:Tom | Tom Lisjac]] or [[User:Vincent | Vincent Snijders]]) and we'll add it to the repository. <br />
<br />
If you think you need to continue to develop on the component, we can also put it into CVS so you'll continue to have access to it.<br />
<br />
== Contributors and Changes ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=CodeConversionGuide version].<br />
* Initial version by Tom Lisjac and Mattias Gärtner - 9/22/2003 [[User:Tom | VlxAdmin]]<br />
* Moved Getting help from the main page. T. Lisjac - 9/24/2003 [[User:Tom | VlxAdmin]]<br />
* Added documentation templates, procedure and links. 9/25/2003 [[User:Tom | VlxAdmin]]<br />
* LCLLinux was renamed to LCLIntf, [[User:Jesusrmx | Jesus Reyes]], 9/27/2003<br />
* added more information on Unit changes, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* Updated Syntax differences, including some examples, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* FPC 1.0.x doesn't support interfaces, [[User:Vincent | Vincent Snijders]] 9/28/2003<br />
* Fixed some of the examples per new WikiWord definition, 9/28/2003 [[User:Tom | VlxAdmin]]<br />
* Made code more consistant to remove last accidental Pascal WikiWord definitions, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 9/27/2003<br />
* Use tables for code examples for nice blocks, and easy side by side view of Delphi->FPC differences, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 10/17/2003<br />
* Use pascal stylesheet to make example code more readable, [http://lazarus-ccr.sourceforge.net/index.php?wiki=AndrewJohnson AndrewJohnson] 10/18/2003</div>Fititnthttps://wiki.freepascal.org/index.php?title=Installing_Lazarus/pt&diff=3884Installing Lazarus/pt2005-11-20T19:32:47Z<p>Fititnt: /* Original contributors and changes */</p>
<hr />
<div>{{Installing Lazarus}}<br />
<br />
==Overview==<br />
Para pessoas que simplesmente querem instalar Lazarus e começar a usá-lo para programar, a maneira mais fácil é instalar uma versão recente, razoavelmente estável, de um binário (como um pacote linux ". rpm" ou um Windows ". exe"). Você pode ler as seções abaixo de linux ou Windows intitulado "binários de fpc" ou os primeiros parágrafos nas seções em instalar Lazarus em linux ou Windows; a maioria da informação restantes podem ser ignoradas seguramente. <br />
<br />
Para os que querem participar no desenvolvimento do compilador ou da IDE, ou para quem quer ter as ferramentas com atualizações em dia, uma instalação de arquivos de fonte é necessária, e muito do resto desta informação é pertinente. <br />
Lazarus provê duas partes principais: <br />
<br />
<br />
Lazarus provê duas partes principais: <br />
* LCL - Biblioteca de Componentes do Lazarus ( Lazarus Component Library ) <br />
* IDE - ferramenta de RAD <br />
<br />
Estes são em troca dependentes de <br />
* FPC - o compilador de freePascal ( freePascal compiler ) <br />
* FCL - a Biblioteca de Componentes FreePascal Componente biblioteca (FreePascal Component Library ), contendo a maioria dos componentes de não-gráficos usado pelo Lazarus.<br />
<br />
===Requerimentos de Sistema do Lazarus===<br />
<br />
# Compilador de FreePascal, pacotes (packages), e fontes ( sources). (*important*: of the same version/date)<br />
# Uma Widget tool-kit de suporte<br />
#:;Win32: : API nativas do Win32 podem ser usadas<br />
#:;Linux/xxxBSD: GTK+ 1.2.x : A maioria distribuições de Linux e * BSDs já instalam bibliotecas GTK+ 1.2.x. Você também pode achar em http://www.gtk.org. <br> Você também desejará ter gdk-pixbuf, 0.13 ou mais novo ( preferencialmente 0.18 ou mais recente), que também é achado na maioria das recentes distribuições dos últimos 2 anos. A fonte está disponível em ftp://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/<br />
#:;Mac OS X: GTK+ 1.2.x : Você precisa das ferramentas de desenvolvedor da apple, X11 e GTK1.2. Veja abaixo como instalar o Lazarus no Mac OS X.<br />
#:;GTK+ 2.x: ADVERTÊNCIA : A interface interativa GTK2 não está totalmente implementada é só deve ser usada para testes. <br> É encontrada na maioria das distribuições recentes. Peque a fonte em http://www.gtk.org.<br />
<br />
<br />
A FAQ - As perguntas frequentemente perguntadas podem ser encontradas em http://www.lazarus.freepascal.org . Algumas respostas podem ser encontradas no arquivo local 'FAQ'.<br />
<br />
<br />
As seções seguintes descreverão como adquirir FreePascal e como instalar lazarus corretamente.<br />
<br />
==Installing The Free Pascal Compiler==<br />
<br />
There is an extensive discussion of how to install and build Free Pascal compilers available here http://www.stack.nl/~marcov/buildfaq.pdf - it may be a little too detailed for some users, but is very comprehensive.<br />
<br />
Lazarus requires fpc (FreePascal) version 1.9.x and it requires both the compiled fpc libs (binaries) and the fpc sources and of the same version. fpc 1.0.6 is too buggy and fpc 1.0.10 has problems opening forms created with fpc 1.9.x. FreePascal version 2.0.0 has now been released, and is the preferred compiler (fpc-2.0.0).<br />
<br />
===Installing Free Pascal under Linux===<br />
<br />
====FPC Binaries====<br />
<br />
The latest release of FreePascal, version 2.0.1, can be obtained from the FreePascal website (http://www.freepascal.org/download.html, then choose a mirror) or from sourceforge (http://sourceforge.net/projects/lazarus). <br />
<br />
At the lazarus downloads section (http://www.lazarus.freepascal.org ) you can get the RPM of the Free Pascal compiler (compiler / linux) and its packages. If you don't have an RPM-based distribution, you can download and install the tarballs from http://www.freepascal.org. If you want to compile the binaries for yourself, see the BSD section.<br />
<br />
Instructions: <br />
<br />
Download lastest files from http://sourceforge.net/project/showfiles.php?group_id=89339.<br />
As example:<br />
:* fpc-2.0.1-050923.i386.rpm<br />
:* fpcsrc-2.0.1-050923.i386.rpm<br />
:* lazarus-0.9.10-0.i386.rpm<br><br />
and install them with:<br />
:* rpm -Uvh fpc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh fpcsrc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh lazarus-0.9.10-0.i386.rpm<br><br />
<br />
Daily snapshot Debian packages can be downloaded from http://cYcnus.de/deb/. At present this contains only the compiled fpc components, but not the sources, which would be needed for most Lazarus programming.<br />
<br />
====FPC Sources====<br />
<br />
Together with the release of version 2.0, FPC no longer uses CVS, but has migrated to Subversion (SVN). For now, there is no CVS mirror yet, so you have to use SVN to get the FPC sources.<br />
<br />
===== Download Daily Source Snapshot of Development Tree (version 2.1.x) =====<br />
You can download today's development (v 2.1.x) sources in the form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.1.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v21/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
===== Download Daily Source Snapshot of Release Tree (version 2.0.x) =====<br />
You can download today's development (v 2.0.x) sources that will lead to the next stable release in form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.0.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v20/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
<br />
===== Connect to Source Repository with SVN (replaces section on connection to CVS) =====<br />
As an alternative to the daily zip files of the SVN sources, the SVN repository has been made accessible for everyone, with read-only access. This means that you can directly access the code, and you will have really the last-minute sources available. It is also a method which requires less bandwidth once you have done the first download (checkout in SVN lingo).<br />
===== Development snapshots =====<br />
How to do this? <br />
(You need to have SVN installed, of course. Look [http://subversion.tigris.org/ here] for instructions on how to do that.)<br />
<br />
Change Directory (cd) to the parent directory of your development area, eg <br />
<br />
[]$ cd /home/username/FreePascal<br />
<br />
To retrieve the full source repository, all publicly available modules, type<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc<br />
<br />
Normally, you should perform this step just once.<br />
<br />
To update the sources which were downloaded (checkout) above<br />
<br />
[]$svn update fpc<br />
<br />
<br />
===== Fixes to 2.0.x =====<br />
<br />
The fixes need a separate directory, create a separate directory 'fixes', enter it, and repeat the above checkout command with the URL http://svn.freepascal.org/svn/fpc/branches/fixes_2_0:<br />
<br />
[]$ cd mysvn/fixes<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_0 fpc<br />
<br />
and to update:<br />
<br />
[]$ svn update fpc<br />
<br />
The sources of docs are in a separate repository called fpcdocs, so the command to get them is<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs<br />
<br />
If you want to learn more about subversion, read this excellent [http://svnbook.red-bean.com/ Subversion book] which is also available online in different formats for free.<br />
<br />
For the curious: You have only read-only access, so don't try to commit anything :-)<br />
<br />
For more information, see the [http://www.freepascal.org/develop.html FreePascal] website<br />
<br />
===Instalando o Lazarus no Windows===<br />
<br />
====Binários FPC do Windows====<br />
<br />
Sem dúvida o modo mais fácil para adquirir uma instalação funcional de Free Pascal é baixar a última liberação dos binários do Lazarus para o Windows no SourceForge - a liberação contém as versões atuais do compilador do FreePascal e as bibliotecas de FreePascal como também o lazarus IDE. Se você quer instalar direto das fontes, vá em frente e siga lendo!<br />
<br />
Você pode adquirir o instalador zipado para o fpc 2.0.0 na seção Free Pascal em http://www.freepascal.org/download.html, e então escolha um mirror).<br />
Instalando direto das fontes - -veja a próxima seção para saber os adquirir-- não é para novatos, desde que você precisa de um compilador é um bom começo<br />
<br />
====FPC Sources for Windows====<br />
<<<< See section above under [[#FPC Sources|FPC Sources]] for Linux, where the use of SVN is described >>>><br />
<br />
The easiest way to get the Free Pascal sources is via CVS; see the next section for more on that. You can also download the package as a whole -- see http://www.freepascal.org/develop.html for the daily snapshot of the 2.1.x release tree.<br />
<br />
Windows FPC Sources via CVS ()<br />
<br />
You will need to have a CVS client such as TortoiseCVS or WinCVS installed in order to perform the steps below. The exact commands vary between CVS clients; the ones given below are to be used under CVS home's client, which is available for download here.<br />
<br />
First create a directory in which you'd like to put the sources. Any normal user can do this. Create a directory for fpc (e.g. C:\Source), then do the following at the command prompt:<br />
C:\Source> set CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
C:\Source> cvs login // password is 'cvs' without the commas<br />
C:\source> cvs -z3 co fpc // This will create a directory fpc, which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
C:\> cd Source\FPC<br />
C:\Source\FPC> cvs -z3 update -dP<br />
''ToDo: Write me.''<br />
<br />
See: http://www.freepascal.org/down-win32.html . You can find a list of mirrors at http://www.freepascal.org/sdown.html. Download FPC as one big file, unzip it and run the install.exe. <br />
<br />
Extending your PATH variable to the fpc directory:<br />
<br />
* Win98: Edit autoexec.bat and add the line: PATH=%PATH%;C:\pp\bin\bin\win32<br />
* WinXP/2k: My Computer (Right Click) -> Properties -> Advanced (Page) -> Enviroment Variables -> System Variables -> Edit "PATH", Add "C:\pp\bin\bin\win32" there.<br />
<br />
Then restart windows.<br />
<br />
''ToDo: Explain how to download fpc sources and build the compiler''<br />
<br />
===Installing Free Pascal under BSD/manually===<br />
<br />
Effectively, you need<br />
<br />
A file with all sources, or two (fpc and lazarus)<br />
<br />
1. e.g. for fpc ftp://ftp.freepascal.org/fpc/dist/Linux/separate/sources.tar preferably an export (no CVS/ dirs). The above file misses this.<br />
2. Lazarus source snapshot.<br />
* _any_ starting compiler from the 1.9 branch) You can do a check by parsing the output of ppc386 -i if it is 1.9.3 .. 2.0.x it is ok.<br />
* - dependant packages. (for FreeBSD that is gtk12, glib12 and gdk_pixbuf and GNU make, iconv and gettext)<br />
<br />
FPC build:<br />
<br />
1. (fetch) necessary files (FPC source, starting compiler)<br />
2. (extract) Then de-tgz in work directory,<br />
3. (build) enter work/fpc/ and run<br />
<br />
$MAKE all OPT='-gl -O3p3' PP=/path/to/startingcompiler-name-ppc386<br />
(/path/to/ can be omitted when ppc386 is in the path)<br />
($MAKE is make on linux and gmake on BSD)<br />
<br />
4. (install) then, again in work/fpc, run<br />
<br />
$MAKE install PP=compiler/ppc386 PREFIX=$THEPREFIX<br />
(THEPREFIX= usually is /usr/lcoal, but e.g. on NetBSD it is /usr/pkg for ports)<br />
Create a symlink:<br />
ln -s $THEPREFIX/lib/fpc/2.0.1/ppc386 $THEPREFIX/bin/ppc386<br />
install sourceinstall PREFIX=$THEPREFIX<br />
<br />
5. (configure) run compiler/utils/samplecfg $THEPREFIX/lib/fpc/2.0.1 $ETCDIR<br />
6. (optional, test), see if ppc386 -i gives output, else give a warning that user need to add $PREFIX/bin to his current path. Try to compiler a program with -viwn, and see if that gives errors.<br />
Notes:<br />
<br />
* If you need fpcmake package lists, you need to generate or supply them yourself, (in the port, or in an extra archive) either way, do a dummy install to /tmp/pack and determine the files installed with find . >ll<br />
<br />
* $THEPREFIX and $ETCDIR should be user configurable. Otherwise local installs aren't possible.<br />
<br />
* BSDHIER=1 on all make commands forces BSD hierarchy conventions.<br />
<br />
===Installing Free Pascal under Mac OS X===<br />
<br />
You need the Apple Developer-tools, X11, gtk1.2:<br />
<br />
Downloading packages and installing them properly can be a time consuming task. Therefore there are various package managers. One of them is fink:<br />
: Download fink from http://fink.sourceforge.net/download/index.php?phpLang=en; follow the install instructions.<br />
<br />
Developer-tools: Are included on the original OSX installation-CDs, or download at ADC (free registration required)<br />
: http://developer.apple.com/.<br />
<br />
Apple X11: On a fresh system: choose "Customize" in the install-dialogue, check "X11".<br />
<br />
On an already installed system: download at<br />
: http://www.apple.com/downloads/macosx/apple/x11formacosx.html<br />
<br />
In the Terminal, run<br />
sudo fink install gdk-pixbuf gtk+ gtk+-data gtk+-shlibs gtk-doc gtkglarea gtk-engines<br />
The X11-Application is in /Applications/Utilities/X11.<br />
<br />
Hint: Most X11 programs, including lazarus expect to receive focus, when the users clicks on a window. Under MacOSX this is deactivated. You can activate it for all X11 applications by typing in the terminal:<br />
defaults write com.apple.x11 wm_click_through -bool true<br />
<br />
;Free Pascal Compiler:<br />
Then download and install the Free Pascal Compiler (at least 1.9.5 from 16th August 2004) from<br />
: https://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
When compiling gtk-related software, you need to add two lines to the fpc.cfg file, to enable use of libraries<br />
-Fl/sw/lib<br />
-Fl/usr/X11R6/lib<br />
<br />
<br />
For lazarus you need the fpc sources as well (obsolete: use svn):<br />
Create a directory, where you would like to put the sources. You don't need to be root to do this. Any normal user can do this. <br />
First create a directory for fpc <br />
: (e.g. /Users/username/freepascal) <br />
then open a terminal and do the following:<br />
[]$ bash<br />
[]$ export CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
[]$ cvs login<br />
password is 'cvs' without the 'quotes'<br />
[]$ cvs -z3 co fpc<br />
This will create a directory called 'fpc', which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
[]$ cd /Users/username/freepascal/fpc<br />
[]$ cvs -z3 update -dP<br />
<br />
==Installing Lazarus==<br />
<br />
===Installing Lazarus under Linux===<br />
====Installing using rpms====<br />
The easiest way to get a current working installation of Lazarus is to download the RPMs for FreePascal and Lazarus from the SourceForge repository.<br />
<br />
You need to download the selected version of<br />
* the compiler (eg fpc-1.9.5-041207.i386.rpm)<br />
* the pascal source library (eg fpcsrc-1.9.5-041207.i386.rpm)<br />
* the Lazarus package (eg lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm).<br />
<br />
You then issue the following commands (you need to have root privileges - use su or sudo)<br />
rpm -Uvh fpc-1.9.5-041207.i386.rpm<br />
rpm -Uvh fpcsrc-1.9.5-041207.i386.rpm<br />
rpm -Uvh lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm<br />
<br />
====Installing from source====<br />
If you prefer to install from source and compile the files yourself, follow these instructions. Because the whole lazarus stuff is installed into one directory, uninstall is very easy and you don't need to be root to install lazarus. You can get tgz files for fpc, fpcsrc and lazarus from the downloads section or you can download it directly via svn.<br />
<br />
=====Downloading Lazarus SVN=====<br />
<br />
The lazarus repository has moved from cvs to svn (Subversion). SVN provides an easy way to update your sources by only downloading the changes. This is the recommended way and saves you a lot of time. A connection to the internet is needed for this: you don't need to be root. Lazarus does not need any special permissions, neither during installation nor at runtime.<br />
<br />
With the move we also changed the directory layout of the lazarus sources. The main difference<br />
is that all ide sources are moved from the root to a separate ide subdir. As anybody might understand, this has an impact on the Makefiles, the searchpaths etc. We are in progress of fixing things, so if something doesn't work, please let us know.<br />
<br />
;Now the most important thing.... getting the sources:<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk/ lazarus<br />
(or any other dir where you want to place your sources)<br />
<br />
On subsequent occasions, to update simply type<br />
<br />
[]$ svn update lazarus<br />
<br />
For more information on Subversion, see:<br />
http://subversion.tigris.org/<br />
<br />
Note: the CVS is still accessable, but it frozen. This means<br />
that no new updates are comitted.<br />
<br />
=====Compiling and running=====<br />
Whether you checkout from cvs or svn, the next step is: <br />
<br />
;compile lazarus:<br />
[]$ cd lazarus<br />
[]$ make (gmake on BSD)<br />
<br />
<br />
If fpc is installed correctly, the compilation should work without problems. If not, see FAQ.<br />
<br />
;Start lazarus<br />
[]$ ./lazarus<br />
<br />
The IDE should start. If you started lazarus in a terminal, you can see some notes about missing settings. This is normal at first start. The IDE automatically tries to find out where the freepascal compiler and its sources are installed by searching in the most common directories.<br />
<br />
;Check the paths:<br />
: Use the IDE menu to go to<br />
:: Environment -> Environment Options -> Files<br />
<br />
The 'FPC Source directory' should point to your fpc source directory. This directory normally ends with /fpc/ or /fpcsrc/ (e.g. /usr/src/fpcsrc or /home/username/freepascal/fpc) and contains directories like 'compiler', 'docs', 'fcl', 'rtl' and 'packages'.<br />
<br />
''ToDo: explain the other paths''<br />
<br />
;Hint:<br />
To update lazarus you can use<br />
[]$ svn update lazarus<br />
then for either update pathway:<br />
[]$ make clean all (gmake on BSD)<br />
This will rebuild lazarus and create an IDE without lazarus packages. To link your installed packages do '''after''' the above:<br />
[]$ make idepkg<br />
<br />
====Installing Lazarus under Debian GNU/Linux====<br />
<br />
There are preliminary Debian packages for lazarus available for download. Make sure you read /usr/share/doc/lazarus/README.Debian carefully before you start using it. Feedback is needed and appreciated; please send your comments to Carlos Laviola <claviola@debian.org>.<br />
<br />
====Another (?easier) way to install Lazarus under Debian====<br />
Added by [[User:Kirkpatc]].<br />
<br />
;Simple Lazarus Installation in Debian<br />
(assume new Debian installation, without development libraries loaded)<br />
<br />
From sourceforge repository, download latest fpc, fpclib and lazarus releases; follow links from http://lazarus.freepascal.org, click the "downloads" button on the left, then click on "binaries" then "linux" then "Current Lazarus RPM". This will bring you to <br />
: http://sourceforge.net/project/showfiles.php?group_id=89339<br />
then download the following files (or more recent, if available)<br />
* fpc-2.0.0-0.i586.rpm<br />
* fpcsrc-2.0.0-0.i386.rpm<br />
* lazarus-0.9.8-fpc_2.0.0_0.i386.rpm<br />
cd to the directory where these files are stored, then become root (su) and type:<br />
<br />
alien fpc* //this will convert both the fpc and fpcsrc files to debian format<br />
alien laz*<br />
then install the generated Debian (.deb) packages by (as root):<br />
<br />
dpkg -i fpc*.deb laz*.deb<br />
or use kpackage or a similar utility to install the generated fpc, fpcsrc and lazarus .deb files.<br />
<br />
Note, if you do not have alien type:<br />
<br />
apt-get install alien<br />
<br />
You need to produce a configuration file, which will reside in /etc/fpc.cfg. Still as root, cd to the main fpc directory /usr/lib/fpc/2.0.0 and then type<br />
sh ./samplecfg /usr/lib/fpc/2.0.0 /etc<br />
Check the contents of your new configuration file (cat /etc/fpc.cfg) and make any changes you want using vi or another text editor. Also make sure that there are no old configuration files in for example your home directory (~/.fpc.cfg).<br />
<br />
You need to install the development packages of the GTK and pixbuf libraries, so<br />
apt-get install libgtk2.0-dev<br />
apt-get install libgdk-pixbuf-dev<br />
Then you should be ready to start programming!<br />
<br />
===Installing Lazarus under Mac OS X===<br />
<br />
Works pretty much the same as under Linux. But you need to install first the apple developer tools and X11.<br />
<br />
Snapshots are available at http://www.de.freepascal.org/lazarus/.<br />
<br />
If you want to experiment and develop the carbon widgetset interface, look at [[Installing Carbon on OSX]].<br />
<br />
===Installing Lazarus under Windows===<br />
<br />
The current releases of the Windows Lazarus binary packages install very easily, and should work 'out-of-the-box'. <br />
<br />
It is even possible to install the whole Lazarus/FPC package on a portable USB drive (capacity at least 256 MB), for use in environments where you are not allowed to install software on your Windows workstation or where you haven't got administrator privileges. You do have to be a little careful about adjusting the paths in the compiler and environment options and the fpc.cfg file. It may also be necessary to keep the directory for test compilation on your portable drive. << DOES ANYONE KNOW HOW TO SET UP RELATIVE PATHS IN THESE TAGS AND FILES, SO THAT THE ADDRESSING WORKS WHEN YOU MOVE THE USB DEVICE TO ANOTHER MACHINE WHERE IT HAS A DIFFERENT DRIVE LETTER? >><br />
<br />
The binary package is available for Linux and Windows from<br />
<br />
http://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
Download the latest release (currently Lazarus-0.9.6-20050225-win32.exe) and launch the application. You will be taken through a typical Windows installation, in which the FPC compiler and source libraries are installed within the same directory structure as Lazarus, and the IDE should launch and operate without significant problems, provided you have uninstalled any previous version of Lazarus and/or FPC (often found in the C:\pp directory).<br />
<br />
You can also get a Lazarus Snapshot for Windows at: http://www.de.freepascal.org/lazarus/<br />
<br />
====Installing from source====<br />
If you prefer to install from sources, then follow these instructions (Thanks to Joe for the initial Step-by-step description)<br />
<br />
You have to download the lazarus source:<br />
: http://www.de.freepascal.org/lazarus/<br />
<br />
Then unzip it to c:\lazarus for example. You have to install at least fpc-2.0.0, but a fpc-2.0.1 or fpc 2.1.1 snapshot is also possible. It compiles for me, and lazarus.exe works. The path to my fpc is: c:\pp\bin\win32. In this directory you can find a lot of exe (make, grep, ppc386, and so on).<br />
<br />
Open a command line. Start->Run...>command or choose MS-DOS icon.<br />
<br />
Type:<br />
cd c:\lazarus<br />
set path=c:\pp\bin\win32;c:\lazarus //of course change the first to<br />
//the path of yours<br />
windres -i lazarus.rc -o lazarus.res<br />
make<br />
<br />
If you are lucky then you can type: lazarus.exe. The source editor, dialogs and the property editor work, but not perfectly... Look and you will see.<br />
<br />
You can compile examples also:<br />
<br />
cd examples<br />
make<br />
<br />
If you extracted lazarus to another drive, eg.: d:\lazarus. It can happen that you need the gnu utility to make it. If you have it, you can take its path to set path=...;<gmakepath> but it is simpler not to choose drive d:\<br />
<br />
That's all.<br />
<br />
=== Additional experiences and advice on installing FPC and Lazarus ===<br />
On linux, getting Lazarus to work can be complicated. If you have already installed earlier versions of FPC and/or Lazarus, you have to take great care that the PATHS are adjusted so that only your new versions are called.<br />
<br />
Pitfalls that I have experienced in various attempts with SuSE linux include:<br />
<br />
The rpm versions often install FPC in /bin or /usr/bin, with the libraries in /lib or /usr/lib.<br />
<br />
If you perform a make install on a source version or use a .tar.gz, the compiler is usually installed in /usr/local/bin with the libraries in /usr/local/lib.<br />
<br />
So if earlier versions have been installed from rpm, make sure all links are changed to reflect the directory structure of your new compiler. The place to make the changes is in /etc/fpc.cfg ; make sure there are no remnant configuration files in your home directory or in your FPC download directory. Typically they are found in ~/.fpc.cfg<br />
<br />
Make sure the links in /etc/fpc.cfg point to the correct versions of the libraries (particularly if you have older versions still lurking around).<br />
<br />
In /usr/local/bin or /usr/bin there is a file called fpc ; this is the executable that is called when you invoke the compiler. One of the first things it does is to open ppc386 in the same directory. This has to be the same version as the fpc file, or can be a link pointing to the true ppc386 in some other directory (such as a library directory, or the fpc directory in your own development space); be sure to update your link if you install a newer version of the compiler.<br />
<br />
Try running the compiler from the command line using one of the simple example programs or one which you wrote yourself.<br />
<br />
Turning to Lazarus:<br />
<br />
If you use a downloaded snapshot (.tar.gz) or get the source from CVS, enter your lazarus directory and type<br />
<br />
make<br />
./lazarus <br />
<br />
and hopefully the IDE should load. There may be a message saying it can't find the sources; if so, go to the menu at the top and select Environment -> Environment options and insert the name of the directory where you expect to find your lazarus files (eg ~/FreePascal/lazarus), your compiler (eg /usr/local/bin/ppc386), the FreePascal source directory (eg /usr/local/lib/fpc/$version/fpc or a directory in your own space eg ~/FreePascal/fpc). Then close the dialog and start programming.<br />
<br />
You may find further problems when you start programming or compiling; most of these will be related to PATH selection.<br />
<br />
Many of the difficulties are dealt with in the Lazarus FAQ, found either on this WiKi site, or a more complete list on the main Lazarus site<br />
<br />
http://www.lazarus.freepascal.org/modules.php?op=modload&name=FAQ&file=index<br />
<br />
From the top menu select Run -> Compiler Options (or Project -> Compiler Options in more recent releases of Lazarus) and select the Paths tab on the resulting dialog. There are several boxes for entry of paths for Unit files, Include files, Other source files, Libraries etc. For each of these, it is worth pressing the ... (ellipsis) button on the right, and you will be given a blank window for inserting path information, and a lower window giving some suggestions. Select as many as you like (or ALL!) and press the ADD button to transfer the selections to the upper window. When your selection is complete, press OK and move on to the next box. If you know of other paths which need to be followed, press the Browse button associated with each box, and insert the additional paths.<br />
<br />
When you think you have got your paths right, try to compile your application. If there are further path-related errors ('can't find unit .......') then go back and check your paths, both in /etc/fpc.cfg and in your Run -> Compiler Options dialog (or Project -> Compiler Options depending on your version).<br />
<br />
Once you have got the environment and PATHS correct, it is worth saving the settings to a file, otherwise you will have to go through this process for each new project. In the Run -> Compiler options dialog there is a Load/Save button; select this and then save the setings to the filename of your choice: mine is ~/FreePascal/default.cfg. Then each time I start a new project, I can go to the Run -> Compiler Options dialog (or Project -> Compiler Options), select Load/Save, and load my default.cfg file to the new project. You can, of course, modify the options for each new project if you so desire.<br />
<br />
===Installing Lazarus under BSD===<br />
<br />
Please write me!<br />
<br />
==Contribuições Originais e Mudanças==<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=InstallingLazarus version].<br />
* Iniciada a tradução para o português [[User:fititnt | fititnt]] 20/11/2005<br />
* Initially imported and formatted. [[User:Tom | VlxAdmin]] 9/22/2003<br />
* Changed Joe's part for Windows to require fpc 1.0.10. [[User:Vincent | Vincent]] 9/25/2003<br />
* Updated "What is required for lazarus". AndrewJohnson 10/1/2003<br />
* Finished formatted the InstallingLazarus page [[User:Tom | VlxAdmin]] 2/22/2004<br />
* Posted some notes about Installing FPC and Lazarus: mostly reflecting experiences in trying to get the PATHS right in Linux. 3/11/2004 [[User:Kirkpatc]]<br />
* Copied the contents of my note into the main InstallingLazarus section, edited it slightly. I don't know how to remove the original note. 3/12/2004 [[User:Kirkpatc]]<br />
* Removed the original note. Tidied the wiki and formatting a bit. [[User:Tom | VlxAdmin]]<br />
* Corrected a couple of typos - 3/12/2004 [[User:Kirkpatc]]<br />
* Added link for daily snapshot deb packages - 3/27/2004 [[User:Vincent | Vincent]]<br />
* Fixed links in GettingLazarus (downloading binaries) and several other pages. 22 July 2004 [[User:Kirkpatc]]<br />
* Added link for lazarus deb packages - 19 August 2004 VincentSnijders<br />
* Added a short note on installing in Debian - 23 Nov 2004 [[User:Kirkpatc]]<br />
* Considerable re-write and re-organization of installation section - 11 Dec 2004 [[User:Kirkpatc]]<br />
* Fixed broken link - 9 Oct 2005 [[User:Avantman42]]</div>Fititnthttps://wiki.freepascal.org/index.php?title=Installing_Lazarus/pt&diff=3804Installing Lazarus/pt2005-11-20T19:30:15Z<p>Fititnt: /* Installing Free Pascal under Windows */</p>
<hr />
<div>{{Installing Lazarus}}<br />
<br />
==Overview==<br />
Para pessoas que simplesmente querem instalar Lazarus e começar a usá-lo para programar, a maneira mais fácil é instalar uma versão recente, razoavelmente estável, de um binário (como um pacote linux ". rpm" ou um Windows ". exe"). Você pode ler as seções abaixo de linux ou Windows intitulado "binários de fpc" ou os primeiros parágrafos nas seções em instalar Lazarus em linux ou Windows; a maioria da informação restantes podem ser ignoradas seguramente. <br />
<br />
Para os que querem participar no desenvolvimento do compilador ou da IDE, ou para quem quer ter as ferramentas com atualizações em dia, uma instalação de arquivos de fonte é necessária, e muito do resto desta informação é pertinente. <br />
Lazarus provê duas partes principais: <br />
<br />
<br />
Lazarus provê duas partes principais: <br />
* LCL - Biblioteca de Componentes do Lazarus ( Lazarus Component Library ) <br />
* IDE - ferramenta de RAD <br />
<br />
Estes são em troca dependentes de <br />
* FPC - o compilador de freePascal ( freePascal compiler ) <br />
* FCL - a Biblioteca de Componentes FreePascal Componente biblioteca (FreePascal Component Library ), contendo a maioria dos componentes de não-gráficos usado pelo Lazarus.<br />
<br />
===Requerimentos de Sistema do Lazarus===<br />
<br />
# Compilador de FreePascal, pacotes (packages), e fontes ( sources). (*important*: of the same version/date)<br />
# Uma Widget tool-kit de suporte<br />
#:;Win32: : API nativas do Win32 podem ser usadas<br />
#:;Linux/xxxBSD: GTK+ 1.2.x : A maioria distribuições de Linux e * BSDs já instalam bibliotecas GTK+ 1.2.x. Você também pode achar em http://www.gtk.org. <br> Você também desejará ter gdk-pixbuf, 0.13 ou mais novo ( preferencialmente 0.18 ou mais recente), que também é achado na maioria das recentes distribuições dos últimos 2 anos. A fonte está disponível em ftp://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/<br />
#:;Mac OS X: GTK+ 1.2.x : Você precisa das ferramentas de desenvolvedor da apple, X11 e GTK1.2. Veja abaixo como instalar o Lazarus no Mac OS X.<br />
#:;GTK+ 2.x: ADVERTÊNCIA : A interface interativa GTK2 não está totalmente implementada é só deve ser usada para testes. <br> É encontrada na maioria das distribuições recentes. Peque a fonte em http://www.gtk.org.<br />
<br />
<br />
A FAQ - As perguntas frequentemente perguntadas podem ser encontradas em http://www.lazarus.freepascal.org . Algumas respostas podem ser encontradas no arquivo local 'FAQ'.<br />
<br />
<br />
As seções seguintes descreverão como adquirir FreePascal e como instalar lazarus corretamente.<br />
<br />
==Installing The Free Pascal Compiler==<br />
<br />
There is an extensive discussion of how to install and build Free Pascal compilers available here http://www.stack.nl/~marcov/buildfaq.pdf - it may be a little too detailed for some users, but is very comprehensive.<br />
<br />
Lazarus requires fpc (FreePascal) version 1.9.x and it requires both the compiled fpc libs (binaries) and the fpc sources and of the same version. fpc 1.0.6 is too buggy and fpc 1.0.10 has problems opening forms created with fpc 1.9.x. FreePascal version 2.0.0 has now been released, and is the preferred compiler (fpc-2.0.0).<br />
<br />
===Installing Free Pascal under Linux===<br />
<br />
====FPC Binaries====<br />
<br />
The latest release of FreePascal, version 2.0.1, can be obtained from the FreePascal website (http://www.freepascal.org/download.html, then choose a mirror) or from sourceforge (http://sourceforge.net/projects/lazarus). <br />
<br />
At the lazarus downloads section (http://www.lazarus.freepascal.org ) you can get the RPM of the Free Pascal compiler (compiler / linux) and its packages. If you don't have an RPM-based distribution, you can download and install the tarballs from http://www.freepascal.org. If you want to compile the binaries for yourself, see the BSD section.<br />
<br />
Instructions: <br />
<br />
Download lastest files from http://sourceforge.net/project/showfiles.php?group_id=89339.<br />
As example:<br />
:* fpc-2.0.1-050923.i386.rpm<br />
:* fpcsrc-2.0.1-050923.i386.rpm<br />
:* lazarus-0.9.10-0.i386.rpm<br><br />
and install them with:<br />
:* rpm -Uvh fpc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh fpcsrc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh lazarus-0.9.10-0.i386.rpm<br><br />
<br />
Daily snapshot Debian packages can be downloaded from http://cYcnus.de/deb/. At present this contains only the compiled fpc components, but not the sources, which would be needed for most Lazarus programming.<br />
<br />
====FPC Sources====<br />
<br />
Together with the release of version 2.0, FPC no longer uses CVS, but has migrated to Subversion (SVN). For now, there is no CVS mirror yet, so you have to use SVN to get the FPC sources.<br />
<br />
===== Download Daily Source Snapshot of Development Tree (version 2.1.x) =====<br />
You can download today's development (v 2.1.x) sources in the form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.1.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v21/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
===== Download Daily Source Snapshot of Release Tree (version 2.0.x) =====<br />
You can download today's development (v 2.0.x) sources that will lead to the next stable release in form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.0.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v20/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
<br />
===== Connect to Source Repository with SVN (replaces section on connection to CVS) =====<br />
As an alternative to the daily zip files of the SVN sources, the SVN repository has been made accessible for everyone, with read-only access. This means that you can directly access the code, and you will have really the last-minute sources available. It is also a method which requires less bandwidth once you have done the first download (checkout in SVN lingo).<br />
===== Development snapshots =====<br />
How to do this? <br />
(You need to have SVN installed, of course. Look [http://subversion.tigris.org/ here] for instructions on how to do that.)<br />
<br />
Change Directory (cd) to the parent directory of your development area, eg <br />
<br />
[]$ cd /home/username/FreePascal<br />
<br />
To retrieve the full source repository, all publicly available modules, type<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc<br />
<br />
Normally, you should perform this step just once.<br />
<br />
To update the sources which were downloaded (checkout) above<br />
<br />
[]$svn update fpc<br />
<br />
<br />
===== Fixes to 2.0.x =====<br />
<br />
The fixes need a separate directory, create a separate directory 'fixes', enter it, and repeat the above checkout command with the URL http://svn.freepascal.org/svn/fpc/branches/fixes_2_0:<br />
<br />
[]$ cd mysvn/fixes<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_0 fpc<br />
<br />
and to update:<br />
<br />
[]$ svn update fpc<br />
<br />
The sources of docs are in a separate repository called fpcdocs, so the command to get them is<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs<br />
<br />
If you want to learn more about subversion, read this excellent [http://svnbook.red-bean.com/ Subversion book] which is also available online in different formats for free.<br />
<br />
For the curious: You have only read-only access, so don't try to commit anything :-)<br />
<br />
For more information, see the [http://www.freepascal.org/develop.html FreePascal] website<br />
<br />
===Instalando o Lazarus no Windows===<br />
<br />
====Binários FPC do Windows====<br />
<br />
Sem dúvida o modo mais fácil para adquirir uma instalação funcional de Free Pascal é baixar a última liberação dos binários do Lazarus para o Windows no SourceForge - a liberação contém as versões atuais do compilador do FreePascal e as bibliotecas de FreePascal como também o lazarus IDE. Se você quer instalar direto das fontes, vá em frente e siga lendo!<br />
<br />
Você pode adquirir o instalador zipado para o fpc 2.0.0 na seção Free Pascal em http://www.freepascal.org/download.html, e então escolha um mirror).<br />
Instalando direto das fontes - -veja a próxima seção para saber os adquirir-- não é para novatos, desde que você precisa de um compilador é um bom começo<br />
<br />
====FPC Sources for Windows====<br />
<<<< See section above under [[#FPC Sources|FPC Sources]] for Linux, where the use of SVN is described >>>><br />
<br />
The easiest way to get the Free Pascal sources is via CVS; see the next section for more on that. You can also download the package as a whole -- see http://www.freepascal.org/develop.html for the daily snapshot of the 2.1.x release tree.<br />
<br />
Windows FPC Sources via CVS ()<br />
<br />
You will need to have a CVS client such as TortoiseCVS or WinCVS installed in order to perform the steps below. The exact commands vary between CVS clients; the ones given below are to be used under CVS home's client, which is available for download here.<br />
<br />
First create a directory in which you'd like to put the sources. Any normal user can do this. Create a directory for fpc (e.g. C:\Source), then do the following at the command prompt:<br />
C:\Source> set CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
C:\Source> cvs login // password is 'cvs' without the commas<br />
C:\source> cvs -z3 co fpc // This will create a directory fpc, which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
C:\> cd Source\FPC<br />
C:\Source\FPC> cvs -z3 update -dP<br />
''ToDo: Write me.''<br />
<br />
See: http://www.freepascal.org/down-win32.html . You can find a list of mirrors at http://www.freepascal.org/sdown.html. Download FPC as one big file, unzip it and run the install.exe. <br />
<br />
Extending your PATH variable to the fpc directory:<br />
<br />
* Win98: Edit autoexec.bat and add the line: PATH=%PATH%;C:\pp\bin\bin\win32<br />
* WinXP/2k: My Computer (Right Click) -> Properties -> Advanced (Page) -> Enviroment Variables -> System Variables -> Edit "PATH", Add "C:\pp\bin\bin\win32" there.<br />
<br />
Then restart windows.<br />
<br />
''ToDo: Explain how to download fpc sources and build the compiler''<br />
<br />
===Installing Free Pascal under BSD/manually===<br />
<br />
Effectively, you need<br />
<br />
A file with all sources, or two (fpc and lazarus)<br />
<br />
1. e.g. for fpc ftp://ftp.freepascal.org/fpc/dist/Linux/separate/sources.tar preferably an export (no CVS/ dirs). The above file misses this.<br />
2. Lazarus source snapshot.<br />
* _any_ starting compiler from the 1.9 branch) You can do a check by parsing the output of ppc386 -i if it is 1.9.3 .. 2.0.x it is ok.<br />
* - dependant packages. (for FreeBSD that is gtk12, glib12 and gdk_pixbuf and GNU make, iconv and gettext)<br />
<br />
FPC build:<br />
<br />
1. (fetch) necessary files (FPC source, starting compiler)<br />
2. (extract) Then de-tgz in work directory,<br />
3. (build) enter work/fpc/ and run<br />
<br />
$MAKE all OPT='-gl -O3p3' PP=/path/to/startingcompiler-name-ppc386<br />
(/path/to/ can be omitted when ppc386 is in the path)<br />
($MAKE is make on linux and gmake on BSD)<br />
<br />
4. (install) then, again in work/fpc, run<br />
<br />
$MAKE install PP=compiler/ppc386 PREFIX=$THEPREFIX<br />
(THEPREFIX= usually is /usr/lcoal, but e.g. on NetBSD it is /usr/pkg for ports)<br />
Create a symlink:<br />
ln -s $THEPREFIX/lib/fpc/2.0.1/ppc386 $THEPREFIX/bin/ppc386<br />
install sourceinstall PREFIX=$THEPREFIX<br />
<br />
5. (configure) run compiler/utils/samplecfg $THEPREFIX/lib/fpc/2.0.1 $ETCDIR<br />
6. (optional, test), see if ppc386 -i gives output, else give a warning that user need to add $PREFIX/bin to his current path. Try to compiler a program with -viwn, and see if that gives errors.<br />
Notes:<br />
<br />
* If you need fpcmake package lists, you need to generate or supply them yourself, (in the port, or in an extra archive) either way, do a dummy install to /tmp/pack and determine the files installed with find . >ll<br />
<br />
* $THEPREFIX and $ETCDIR should be user configurable. Otherwise local installs aren't possible.<br />
<br />
* BSDHIER=1 on all make commands forces BSD hierarchy conventions.<br />
<br />
===Installing Free Pascal under Mac OS X===<br />
<br />
You need the Apple Developer-tools, X11, gtk1.2:<br />
<br />
Downloading packages and installing them properly can be a time consuming task. Therefore there are various package managers. One of them is fink:<br />
: Download fink from http://fink.sourceforge.net/download/index.php?phpLang=en; follow the install instructions.<br />
<br />
Developer-tools: Are included on the original OSX installation-CDs, or download at ADC (free registration required)<br />
: http://developer.apple.com/.<br />
<br />
Apple X11: On a fresh system: choose "Customize" in the install-dialogue, check "X11".<br />
<br />
On an already installed system: download at<br />
: http://www.apple.com/downloads/macosx/apple/x11formacosx.html<br />
<br />
In the Terminal, run<br />
sudo fink install gdk-pixbuf gtk+ gtk+-data gtk+-shlibs gtk-doc gtkglarea gtk-engines<br />
The X11-Application is in /Applications/Utilities/X11.<br />
<br />
Hint: Most X11 programs, including lazarus expect to receive focus, when the users clicks on a window. Under MacOSX this is deactivated. You can activate it for all X11 applications by typing in the terminal:<br />
defaults write com.apple.x11 wm_click_through -bool true<br />
<br />
;Free Pascal Compiler:<br />
Then download and install the Free Pascal Compiler (at least 1.9.5 from 16th August 2004) from<br />
: https://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
When compiling gtk-related software, you need to add two lines to the fpc.cfg file, to enable use of libraries<br />
-Fl/sw/lib<br />
-Fl/usr/X11R6/lib<br />
<br />
<br />
For lazarus you need the fpc sources as well (obsolete: use svn):<br />
Create a directory, where you would like to put the sources. You don't need to be root to do this. Any normal user can do this. <br />
First create a directory for fpc <br />
: (e.g. /Users/username/freepascal) <br />
then open a terminal and do the following:<br />
[]$ bash<br />
[]$ export CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
[]$ cvs login<br />
password is 'cvs' without the 'quotes'<br />
[]$ cvs -z3 co fpc<br />
This will create a directory called 'fpc', which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
[]$ cd /Users/username/freepascal/fpc<br />
[]$ cvs -z3 update -dP<br />
<br />
==Installing Lazarus==<br />
<br />
===Installing Lazarus under Linux===<br />
====Installing using rpms====<br />
The easiest way to get a current working installation of Lazarus is to download the RPMs for FreePascal and Lazarus from the SourceForge repository.<br />
<br />
You need to download the selected version of<br />
* the compiler (eg fpc-1.9.5-041207.i386.rpm)<br />
* the pascal source library (eg fpcsrc-1.9.5-041207.i386.rpm)<br />
* the Lazarus package (eg lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm).<br />
<br />
You then issue the following commands (you need to have root privileges - use su or sudo)<br />
rpm -Uvh fpc-1.9.5-041207.i386.rpm<br />
rpm -Uvh fpcsrc-1.9.5-041207.i386.rpm<br />
rpm -Uvh lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm<br />
<br />
====Installing from source====<br />
If you prefer to install from source and compile the files yourself, follow these instructions. Because the whole lazarus stuff is installed into one directory, uninstall is very easy and you don't need to be root to install lazarus. You can get tgz files for fpc, fpcsrc and lazarus from the downloads section or you can download it directly via svn.<br />
<br />
=====Downloading Lazarus SVN=====<br />
<br />
The lazarus repository has moved from cvs to svn (Subversion). SVN provides an easy way to update your sources by only downloading the changes. This is the recommended way and saves you a lot of time. A connection to the internet is needed for this: you don't need to be root. Lazarus does not need any special permissions, neither during installation nor at runtime.<br />
<br />
With the move we also changed the directory layout of the lazarus sources. The main difference<br />
is that all ide sources are moved from the root to a separate ide subdir. As anybody might understand, this has an impact on the Makefiles, the searchpaths etc. We are in progress of fixing things, so if something doesn't work, please let us know.<br />
<br />
;Now the most important thing.... getting the sources:<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk/ lazarus<br />
(or any other dir where you want to place your sources)<br />
<br />
On subsequent occasions, to update simply type<br />
<br />
[]$ svn update lazarus<br />
<br />
For more information on Subversion, see:<br />
http://subversion.tigris.org/<br />
<br />
Note: the CVS is still accessable, but it frozen. This means<br />
that no new updates are comitted.<br />
<br />
=====Compiling and running=====<br />
Whether you checkout from cvs or svn, the next step is: <br />
<br />
;compile lazarus:<br />
[]$ cd lazarus<br />
[]$ make (gmake on BSD)<br />
<br />
<br />
If fpc is installed correctly, the compilation should work without problems. If not, see FAQ.<br />
<br />
;Start lazarus<br />
[]$ ./lazarus<br />
<br />
The IDE should start. If you started lazarus in a terminal, you can see some notes about missing settings. This is normal at first start. The IDE automatically tries to find out where the freepascal compiler and its sources are installed by searching in the most common directories.<br />
<br />
;Check the paths:<br />
: Use the IDE menu to go to<br />
:: Environment -> Environment Options -> Files<br />
<br />
The 'FPC Source directory' should point to your fpc source directory. This directory normally ends with /fpc/ or /fpcsrc/ (e.g. /usr/src/fpcsrc or /home/username/freepascal/fpc) and contains directories like 'compiler', 'docs', 'fcl', 'rtl' and 'packages'.<br />
<br />
''ToDo: explain the other paths''<br />
<br />
;Hint:<br />
To update lazarus you can use<br />
[]$ svn update lazarus<br />
then for either update pathway:<br />
[]$ make clean all (gmake on BSD)<br />
This will rebuild lazarus and create an IDE without lazarus packages. To link your installed packages do '''after''' the above:<br />
[]$ make idepkg<br />
<br />
====Installing Lazarus under Debian GNU/Linux====<br />
<br />
There are preliminary Debian packages for lazarus available for download. Make sure you read /usr/share/doc/lazarus/README.Debian carefully before you start using it. Feedback is needed and appreciated; please send your comments to Carlos Laviola <claviola@debian.org>.<br />
<br />
====Another (?easier) way to install Lazarus under Debian====<br />
Added by [[User:Kirkpatc]].<br />
<br />
;Simple Lazarus Installation in Debian<br />
(assume new Debian installation, without development libraries loaded)<br />
<br />
From sourceforge repository, download latest fpc, fpclib and lazarus releases; follow links from http://lazarus.freepascal.org, click the "downloads" button on the left, then click on "binaries" then "linux" then "Current Lazarus RPM". This will bring you to <br />
: http://sourceforge.net/project/showfiles.php?group_id=89339<br />
then download the following files (or more recent, if available)<br />
* fpc-2.0.0-0.i586.rpm<br />
* fpcsrc-2.0.0-0.i386.rpm<br />
* lazarus-0.9.8-fpc_2.0.0_0.i386.rpm<br />
cd to the directory where these files are stored, then become root (su) and type:<br />
<br />
alien fpc* //this will convert both the fpc and fpcsrc files to debian format<br />
alien laz*<br />
then install the generated Debian (.deb) packages by (as root):<br />
<br />
dpkg -i fpc*.deb laz*.deb<br />
or use kpackage or a similar utility to install the generated fpc, fpcsrc and lazarus .deb files.<br />
<br />
Note, if you do not have alien type:<br />
<br />
apt-get install alien<br />
<br />
You need to produce a configuration file, which will reside in /etc/fpc.cfg. Still as root, cd to the main fpc directory /usr/lib/fpc/2.0.0 and then type<br />
sh ./samplecfg /usr/lib/fpc/2.0.0 /etc<br />
Check the contents of your new configuration file (cat /etc/fpc.cfg) and make any changes you want using vi or another text editor. Also make sure that there are no old configuration files in for example your home directory (~/.fpc.cfg).<br />
<br />
You need to install the development packages of the GTK and pixbuf libraries, so<br />
apt-get install libgtk2.0-dev<br />
apt-get install libgdk-pixbuf-dev<br />
Then you should be ready to start programming!<br />
<br />
===Installing Lazarus under Mac OS X===<br />
<br />
Works pretty much the same as under Linux. But you need to install first the apple developer tools and X11.<br />
<br />
Snapshots are available at http://www.de.freepascal.org/lazarus/.<br />
<br />
If you want to experiment and develop the carbon widgetset interface, look at [[Installing Carbon on OSX]].<br />
<br />
===Installing Lazarus under Windows===<br />
<br />
The current releases of the Windows Lazarus binary packages install very easily, and should work 'out-of-the-box'. <br />
<br />
It is even possible to install the whole Lazarus/FPC package on a portable USB drive (capacity at least 256 MB), for use in environments where you are not allowed to install software on your Windows workstation or where you haven't got administrator privileges. You do have to be a little careful about adjusting the paths in the compiler and environment options and the fpc.cfg file. It may also be necessary to keep the directory for test compilation on your portable drive. << DOES ANYONE KNOW HOW TO SET UP RELATIVE PATHS IN THESE TAGS AND FILES, SO THAT THE ADDRESSING WORKS WHEN YOU MOVE THE USB DEVICE TO ANOTHER MACHINE WHERE IT HAS A DIFFERENT DRIVE LETTER? >><br />
<br />
The binary package is available for Linux and Windows from<br />
<br />
http://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
Download the latest release (currently Lazarus-0.9.6-20050225-win32.exe) and launch the application. You will be taken through a typical Windows installation, in which the FPC compiler and source libraries are installed within the same directory structure as Lazarus, and the IDE should launch and operate without significant problems, provided you have uninstalled any previous version of Lazarus and/or FPC (often found in the C:\pp directory).<br />
<br />
You can also get a Lazarus Snapshot for Windows at: http://www.de.freepascal.org/lazarus/<br />
<br />
====Installing from source====<br />
If you prefer to install from sources, then follow these instructions (Thanks to Joe for the initial Step-by-step description)<br />
<br />
You have to download the lazarus source:<br />
: http://www.de.freepascal.org/lazarus/<br />
<br />
Then unzip it to c:\lazarus for example. You have to install at least fpc-2.0.0, but a fpc-2.0.1 or fpc 2.1.1 snapshot is also possible. It compiles for me, and lazarus.exe works. The path to my fpc is: c:\pp\bin\win32. In this directory you can find a lot of exe (make, grep, ppc386, and so on).<br />
<br />
Open a command line. Start->Run...>command or choose MS-DOS icon.<br />
<br />
Type:<br />
cd c:\lazarus<br />
set path=c:\pp\bin\win32;c:\lazarus //of course change the first to<br />
//the path of yours<br />
windres -i lazarus.rc -o lazarus.res<br />
make<br />
<br />
If you are lucky then you can type: lazarus.exe. The source editor, dialogs and the property editor work, but not perfectly... Look and you will see.<br />
<br />
You can compile examples also:<br />
<br />
cd examples<br />
make<br />
<br />
If you extracted lazarus to another drive, eg.: d:\lazarus. It can happen that you need the gnu utility to make it. If you have it, you can take its path to set path=...;<gmakepath> but it is simpler not to choose drive d:\<br />
<br />
That's all.<br />
<br />
=== Additional experiences and advice on installing FPC and Lazarus ===<br />
On linux, getting Lazarus to work can be complicated. If you have already installed earlier versions of FPC and/or Lazarus, you have to take great care that the PATHS are adjusted so that only your new versions are called.<br />
<br />
Pitfalls that I have experienced in various attempts with SuSE linux include:<br />
<br />
The rpm versions often install FPC in /bin or /usr/bin, with the libraries in /lib or /usr/lib.<br />
<br />
If you perform a make install on a source version or use a .tar.gz, the compiler is usually installed in /usr/local/bin with the libraries in /usr/local/lib.<br />
<br />
So if earlier versions have been installed from rpm, make sure all links are changed to reflect the directory structure of your new compiler. The place to make the changes is in /etc/fpc.cfg ; make sure there are no remnant configuration files in your home directory or in your FPC download directory. Typically they are found in ~/.fpc.cfg<br />
<br />
Make sure the links in /etc/fpc.cfg point to the correct versions of the libraries (particularly if you have older versions still lurking around).<br />
<br />
In /usr/local/bin or /usr/bin there is a file called fpc ; this is the executable that is called when you invoke the compiler. One of the first things it does is to open ppc386 in the same directory. This has to be the same version as the fpc file, or can be a link pointing to the true ppc386 in some other directory (such as a library directory, or the fpc directory in your own development space); be sure to update your link if you install a newer version of the compiler.<br />
<br />
Try running the compiler from the command line using one of the simple example programs or one which you wrote yourself.<br />
<br />
Turning to Lazarus:<br />
<br />
If you use a downloaded snapshot (.tar.gz) or get the source from CVS, enter your lazarus directory and type<br />
<br />
make<br />
./lazarus <br />
<br />
and hopefully the IDE should load. There may be a message saying it can't find the sources; if so, go to the menu at the top and select Environment -> Environment options and insert the name of the directory where you expect to find your lazarus files (eg ~/FreePascal/lazarus), your compiler (eg /usr/local/bin/ppc386), the FreePascal source directory (eg /usr/local/lib/fpc/$version/fpc or a directory in your own space eg ~/FreePascal/fpc). Then close the dialog and start programming.<br />
<br />
You may find further problems when you start programming or compiling; most of these will be related to PATH selection.<br />
<br />
Many of the difficulties are dealt with in the Lazarus FAQ, found either on this WiKi site, or a more complete list on the main Lazarus site<br />
<br />
http://www.lazarus.freepascal.org/modules.php?op=modload&name=FAQ&file=index<br />
<br />
From the top menu select Run -> Compiler Options (or Project -> Compiler Options in more recent releases of Lazarus) and select the Paths tab on the resulting dialog. There are several boxes for entry of paths for Unit files, Include files, Other source files, Libraries etc. For each of these, it is worth pressing the ... (ellipsis) button on the right, and you will be given a blank window for inserting path information, and a lower window giving some suggestions. Select as many as you like (or ALL!) and press the ADD button to transfer the selections to the upper window. When your selection is complete, press OK and move on to the next box. If you know of other paths which need to be followed, press the Browse button associated with each box, and insert the additional paths.<br />
<br />
When you think you have got your paths right, try to compile your application. If there are further path-related errors ('can't find unit .......') then go back and check your paths, both in /etc/fpc.cfg and in your Run -> Compiler Options dialog (or Project -> Compiler Options depending on your version).<br />
<br />
Once you have got the environment and PATHS correct, it is worth saving the settings to a file, otherwise you will have to go through this process for each new project. In the Run -> Compiler options dialog there is a Load/Save button; select this and then save the setings to the filename of your choice: mine is ~/FreePascal/default.cfg. Then each time I start a new project, I can go to the Run -> Compiler Options dialog (or Project -> Compiler Options), select Load/Save, and load my default.cfg file to the new project. You can, of course, modify the options for each new project if you so desire.<br />
<br />
===Installing Lazarus under BSD===<br />
<br />
Please write me!<br />
<br />
==Original contributors and changes==<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=InstallingLazarus version].<br />
* Initially imported and formatted. [[User:Tom | VlxAdmin]] 9/22/2003<br />
* Changed Joe's part for Windows to require fpc 1.0.10. [[User:Vincent | Vincent]] 9/25/2003<br />
* Updated "What is required for lazarus". AndrewJohnson 10/1/2003<br />
* Finished formatted the InstallingLazarus page [[User:Tom | VlxAdmin]] 2/22/2004<br />
* Posted some notes about Installing FPC and Lazarus: mostly reflecting experiences in trying to get the PATHS right in Linux. 3/11/2004 [[User:Kirkpatc]]<br />
* Copied the contents of my note into the main InstallingLazarus section, edited it slightly. I don't know how to remove the original note. 3/12/2004 [[User:Kirkpatc]]<br />
* Removed the original note. Tidied the wiki and formatting a bit. [[User:Tom | VlxAdmin]]<br />
* Corrected a couple of typos - 3/12/2004 [[User:Kirkpatc]]<br />
* Added link for daily snapshot deb packages - 3/27/2004 [[User:Vincent | Vincent]]<br />
* Fixed links in GettingLazarus (downloading binaries) and several other pages. 22 July 2004 [[User:Kirkpatc]]<br />
* Added link for lazarus deb packages - 19 August 2004 VincentSnijders<br />
* Added a short note on installing in Debian - 23 Nov 2004 [[User:Kirkpatc]]<br />
* Considerable re-write and re-organization of installation section - 11 Dec 2004 [[User:Kirkpatc]]<br />
* Fixed broken link - 9 Oct 2005 [[User:Avantman42]]</div>Fititnthttps://wiki.freepascal.org/index.php?title=Installing_Lazarus/pt&diff=3803Installing Lazarus/pt2005-11-20T19:08:52Z<p>Fititnt: /* Lazarus System Requirements */</p>
<hr />
<div>{{Installing Lazarus}}<br />
<br />
==Overview==<br />
Para pessoas que simplesmente querem instalar Lazarus e começar a usá-lo para programar, a maneira mais fácil é instalar uma versão recente, razoavelmente estável, de um binário (como um pacote linux ". rpm" ou um Windows ". exe"). Você pode ler as seções abaixo de linux ou Windows intitulado "binários de fpc" ou os primeiros parágrafos nas seções em instalar Lazarus em linux ou Windows; a maioria da informação restantes podem ser ignoradas seguramente. <br />
<br />
Para os que querem participar no desenvolvimento do compilador ou da IDE, ou para quem quer ter as ferramentas com atualizações em dia, uma instalação de arquivos de fonte é necessária, e muito do resto desta informação é pertinente. <br />
Lazarus provê duas partes principais: <br />
<br />
<br />
Lazarus provê duas partes principais: <br />
* LCL - Biblioteca de Componentes do Lazarus ( Lazarus Component Library ) <br />
* IDE - ferramenta de RAD <br />
<br />
Estes são em troca dependentes de <br />
* FPC - o compilador de freePascal ( freePascal compiler ) <br />
* FCL - a Biblioteca de Componentes FreePascal Componente biblioteca (FreePascal Component Library ), contendo a maioria dos componentes de não-gráficos usado pelo Lazarus.<br />
<br />
===Requerimentos de Sistema do Lazarus===<br />
<br />
# Compilador de FreePascal, pacotes (packages), e fontes ( sources). (*important*: of the same version/date)<br />
# Uma Widget tool-kit de suporte<br />
#:;Win32: : API nativas do Win32 podem ser usadas<br />
#:;Linux/xxxBSD: GTK+ 1.2.x : A maioria distribuições de Linux e * BSDs já instalam bibliotecas GTK+ 1.2.x. Você também pode achar em http://www.gtk.org. <br> Você também desejará ter gdk-pixbuf, 0.13 ou mais novo ( preferencialmente 0.18 ou mais recente), que também é achado na maioria das recentes distribuições dos últimos 2 anos. A fonte está disponível em ftp://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/<br />
#:;Mac OS X: GTK+ 1.2.x : Você precisa das ferramentas de desenvolvedor da apple, X11 e GTK1.2. Veja abaixo como instalar o Lazarus no Mac OS X.<br />
#:;GTK+ 2.x: ADVERTÊNCIA : A interface interativa GTK2 não está totalmente implementada é só deve ser usada para testes. <br> É encontrada na maioria das distribuições recentes. Peque a fonte em http://www.gtk.org.<br />
<br />
<br />
A FAQ - As perguntas frequentemente perguntadas podem ser encontradas em http://www.lazarus.freepascal.org . Algumas respostas podem ser encontradas no arquivo local 'FAQ'.<br />
<br />
<br />
As seções seguintes descreverão como adquirir FreePascal e como instalar lazarus corretamente.<br />
<br />
==Installing The Free Pascal Compiler==<br />
<br />
There is an extensive discussion of how to install and build Free Pascal compilers available here http://www.stack.nl/~marcov/buildfaq.pdf - it may be a little too detailed for some users, but is very comprehensive.<br />
<br />
Lazarus requires fpc (FreePascal) version 1.9.x and it requires both the compiled fpc libs (binaries) and the fpc sources and of the same version. fpc 1.0.6 is too buggy and fpc 1.0.10 has problems opening forms created with fpc 1.9.x. FreePascal version 2.0.0 has now been released, and is the preferred compiler (fpc-2.0.0).<br />
<br />
===Installing Free Pascal under Linux===<br />
<br />
====FPC Binaries====<br />
<br />
The latest release of FreePascal, version 2.0.1, can be obtained from the FreePascal website (http://www.freepascal.org/download.html, then choose a mirror) or from sourceforge (http://sourceforge.net/projects/lazarus). <br />
<br />
At the lazarus downloads section (http://www.lazarus.freepascal.org ) you can get the RPM of the Free Pascal compiler (compiler / linux) and its packages. If you don't have an RPM-based distribution, you can download and install the tarballs from http://www.freepascal.org. If you want to compile the binaries for yourself, see the BSD section.<br />
<br />
Instructions: <br />
<br />
Download lastest files from http://sourceforge.net/project/showfiles.php?group_id=89339.<br />
As example:<br />
:* fpc-2.0.1-050923.i386.rpm<br />
:* fpcsrc-2.0.1-050923.i386.rpm<br />
:* lazarus-0.9.10-0.i386.rpm<br><br />
and install them with:<br />
:* rpm -Uvh fpc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh fpcsrc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh lazarus-0.9.10-0.i386.rpm<br><br />
<br />
Daily snapshot Debian packages can be downloaded from http://cYcnus.de/deb/. At present this contains only the compiled fpc components, but not the sources, which would be needed for most Lazarus programming.<br />
<br />
====FPC Sources====<br />
<br />
Together with the release of version 2.0, FPC no longer uses CVS, but has migrated to Subversion (SVN). For now, there is no CVS mirror yet, so you have to use SVN to get the FPC sources.<br />
<br />
===== Download Daily Source Snapshot of Development Tree (version 2.1.x) =====<br />
You can download today's development (v 2.1.x) sources in the form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.1.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v21/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
===== Download Daily Source Snapshot of Release Tree (version 2.0.x) =====<br />
You can download today's development (v 2.0.x) sources that will lead to the next stable release in form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.0.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v20/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
<br />
===== Connect to Source Repository with SVN (replaces section on connection to CVS) =====<br />
As an alternative to the daily zip files of the SVN sources, the SVN repository has been made accessible for everyone, with read-only access. This means that you can directly access the code, and you will have really the last-minute sources available. It is also a method which requires less bandwidth once you have done the first download (checkout in SVN lingo).<br />
===== Development snapshots =====<br />
How to do this? <br />
(You need to have SVN installed, of course. Look [http://subversion.tigris.org/ here] for instructions on how to do that.)<br />
<br />
Change Directory (cd) to the parent directory of your development area, eg <br />
<br />
[]$ cd /home/username/FreePascal<br />
<br />
To retrieve the full source repository, all publicly available modules, type<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc<br />
<br />
Normally, you should perform this step just once.<br />
<br />
To update the sources which were downloaded (checkout) above<br />
<br />
[]$svn update fpc<br />
<br />
<br />
===== Fixes to 2.0.x =====<br />
<br />
The fixes need a separate directory, create a separate directory 'fixes', enter it, and repeat the above checkout command with the URL http://svn.freepascal.org/svn/fpc/branches/fixes_2_0:<br />
<br />
[]$ cd mysvn/fixes<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_0 fpc<br />
<br />
and to update:<br />
<br />
[]$ svn update fpc<br />
<br />
The sources of docs are in a separate repository called fpcdocs, so the command to get them is<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs<br />
<br />
If you want to learn more about subversion, read this excellent [http://svnbook.red-bean.com/ Subversion book] which is also available online in different formats for free.<br />
<br />
For the curious: You have only read-only access, so don't try to commit anything :-)<br />
<br />
For more information, see the [http://www.freepascal.org/develop.html FreePascal] website<br />
<br />
===Installing Free Pascal under Windows===<br />
<br />
====FPC Binaries for Windows====<br />
<br />
By far the easiest way to get a working installation of Free Pascal is to download the current binary Windows release of Lazarus from the SourceForge repository - the release contains the current versions of the FreePascal compiler and the FreePascal libraries as well as the lazarus IDE. If you want to install from sources, read on!<br />
<br />
You can get the installer zip for fpc 2.0.0 at Free Pascal's download section http://www.freepascal.org/download.html, then choose a mirror). <br />
Installing from the sources -- see the next section to know how to get them -- is not for novices, since you need a starting compiler as well.<br />
<br />
====FPC Sources for Windows====<br />
<<<< See section above under [[#FPC Sources|FPC Sources]] for Linux, where the use of SVN is described >>>><br />
<br />
The easiest way to get the Free Pascal sources is via CVS; see the next section for more on that. You can also download the package as a whole -- see http://www.freepascal.org/develop.html for the daily snapshot of the 2.1.x release tree.<br />
<br />
Windows FPC Sources via CVS ()<br />
<br />
You will need to have a CVS client such as TortoiseCVS or WinCVS installed in order to perform the steps below. The exact commands vary between CVS clients; the ones given below are to be used under CVS home's client, which is available for download here.<br />
<br />
First create a directory in which you'd like to put the sources. Any normal user can do this. Create a directory for fpc (e.g. C:\Source), then do the following at the command prompt:<br />
C:\Source> set CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
C:\Source> cvs login // password is 'cvs' without the commas<br />
C:\source> cvs -z3 co fpc // This will create a directory fpc, which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
C:\> cd Source\FPC<br />
C:\Source\FPC> cvs -z3 update -dP<br />
''ToDo: Write me.''<br />
<br />
See: http://www.freepascal.org/down-win32.html . You can find a list of mirrors at http://www.freepascal.org/sdown.html. Download FPC as one big file, unzip it and run the install.exe. <br />
<br />
Extending your PATH variable to the fpc directory:<br />
<br />
* Win98: Edit autoexec.bat and add the line: PATH=%PATH%;C:\pp\bin\bin\win32<br />
* WinXP/2k: My Computer (Right Click) -> Properties -> Advanced (Page) -> Enviroment Variables -> System Variables -> Edit "PATH", Add "C:\pp\bin\bin\win32" there.<br />
<br />
Then restart windows.<br />
<br />
''ToDo: Explain how to download fpc sources and build the compiler''<br />
<br />
===Installing Free Pascal under BSD/manually===<br />
<br />
Effectively, you need<br />
<br />
A file with all sources, or two (fpc and lazarus)<br />
<br />
1. e.g. for fpc ftp://ftp.freepascal.org/fpc/dist/Linux/separate/sources.tar preferably an export (no CVS/ dirs). The above file misses this.<br />
2. Lazarus source snapshot.<br />
* _any_ starting compiler from the 1.9 branch) You can do a check by parsing the output of ppc386 -i if it is 1.9.3 .. 2.0.x it is ok.<br />
* - dependant packages. (for FreeBSD that is gtk12, glib12 and gdk_pixbuf and GNU make, iconv and gettext)<br />
<br />
FPC build:<br />
<br />
1. (fetch) necessary files (FPC source, starting compiler)<br />
2. (extract) Then de-tgz in work directory,<br />
3. (build) enter work/fpc/ and run<br />
<br />
$MAKE all OPT='-gl -O3p3' PP=/path/to/startingcompiler-name-ppc386<br />
(/path/to/ can be omitted when ppc386 is in the path)<br />
($MAKE is make on linux and gmake on BSD)<br />
<br />
4. (install) then, again in work/fpc, run<br />
<br />
$MAKE install PP=compiler/ppc386 PREFIX=$THEPREFIX<br />
(THEPREFIX= usually is /usr/lcoal, but e.g. on NetBSD it is /usr/pkg for ports)<br />
Create a symlink:<br />
ln -s $THEPREFIX/lib/fpc/2.0.1/ppc386 $THEPREFIX/bin/ppc386<br />
install sourceinstall PREFIX=$THEPREFIX<br />
<br />
5. (configure) run compiler/utils/samplecfg $THEPREFIX/lib/fpc/2.0.1 $ETCDIR<br />
6. (optional, test), see if ppc386 -i gives output, else give a warning that user need to add $PREFIX/bin to his current path. Try to compiler a program with -viwn, and see if that gives errors.<br />
Notes:<br />
<br />
* If you need fpcmake package lists, you need to generate or supply them yourself, (in the port, or in an extra archive) either way, do a dummy install to /tmp/pack and determine the files installed with find . >ll<br />
<br />
* $THEPREFIX and $ETCDIR should be user configurable. Otherwise local installs aren't possible.<br />
<br />
* BSDHIER=1 on all make commands forces BSD hierarchy conventions.<br />
<br />
===Installing Free Pascal under Mac OS X===<br />
<br />
You need the Apple Developer-tools, X11, gtk1.2:<br />
<br />
Downloading packages and installing them properly can be a time consuming task. Therefore there are various package managers. One of them is fink:<br />
: Download fink from http://fink.sourceforge.net/download/index.php?phpLang=en; follow the install instructions.<br />
<br />
Developer-tools: Are included on the original OSX installation-CDs, or download at ADC (free registration required)<br />
: http://developer.apple.com/.<br />
<br />
Apple X11: On a fresh system: choose "Customize" in the install-dialogue, check "X11".<br />
<br />
On an already installed system: download at<br />
: http://www.apple.com/downloads/macosx/apple/x11formacosx.html<br />
<br />
In the Terminal, run<br />
sudo fink install gdk-pixbuf gtk+ gtk+-data gtk+-shlibs gtk-doc gtkglarea gtk-engines<br />
The X11-Application is in /Applications/Utilities/X11.<br />
<br />
Hint: Most X11 programs, including lazarus expect to receive focus, when the users clicks on a window. Under MacOSX this is deactivated. You can activate it for all X11 applications by typing in the terminal:<br />
defaults write com.apple.x11 wm_click_through -bool true<br />
<br />
;Free Pascal Compiler:<br />
Then download and install the Free Pascal Compiler (at least 1.9.5 from 16th August 2004) from<br />
: https://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
When compiling gtk-related software, you need to add two lines to the fpc.cfg file, to enable use of libraries<br />
-Fl/sw/lib<br />
-Fl/usr/X11R6/lib<br />
<br />
<br />
For lazarus you need the fpc sources as well (obsolete: use svn):<br />
Create a directory, where you would like to put the sources. You don't need to be root to do this. Any normal user can do this. <br />
First create a directory for fpc <br />
: (e.g. /Users/username/freepascal) <br />
then open a terminal and do the following:<br />
[]$ bash<br />
[]$ export CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
[]$ cvs login<br />
password is 'cvs' without the 'quotes'<br />
[]$ cvs -z3 co fpc<br />
This will create a directory called 'fpc', which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
[]$ cd /Users/username/freepascal/fpc<br />
[]$ cvs -z3 update -dP<br />
<br />
==Installing Lazarus==<br />
<br />
===Installing Lazarus under Linux===<br />
====Installing using rpms====<br />
The easiest way to get a current working installation of Lazarus is to download the RPMs for FreePascal and Lazarus from the SourceForge repository.<br />
<br />
You need to download the selected version of<br />
* the compiler (eg fpc-1.9.5-041207.i386.rpm)<br />
* the pascal source library (eg fpcsrc-1.9.5-041207.i386.rpm)<br />
* the Lazarus package (eg lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm).<br />
<br />
You then issue the following commands (you need to have root privileges - use su or sudo)<br />
rpm -Uvh fpc-1.9.5-041207.i386.rpm<br />
rpm -Uvh fpcsrc-1.9.5-041207.i386.rpm<br />
rpm -Uvh lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm<br />
<br />
====Installing from source====<br />
If you prefer to install from source and compile the files yourself, follow these instructions. Because the whole lazarus stuff is installed into one directory, uninstall is very easy and you don't need to be root to install lazarus. You can get tgz files for fpc, fpcsrc and lazarus from the downloads section or you can download it directly via svn.<br />
<br />
=====Downloading Lazarus SVN=====<br />
<br />
The lazarus repository has moved from cvs to svn (Subversion). SVN provides an easy way to update your sources by only downloading the changes. This is the recommended way and saves you a lot of time. A connection to the internet is needed for this: you don't need to be root. Lazarus does not need any special permissions, neither during installation nor at runtime.<br />
<br />
With the move we also changed the directory layout of the lazarus sources. The main difference<br />
is that all ide sources are moved from the root to a separate ide subdir. As anybody might understand, this has an impact on the Makefiles, the searchpaths etc. We are in progress of fixing things, so if something doesn't work, please let us know.<br />
<br />
;Now the most important thing.... getting the sources:<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk/ lazarus<br />
(or any other dir where you want to place your sources)<br />
<br />
On subsequent occasions, to update simply type<br />
<br />
[]$ svn update lazarus<br />
<br />
For more information on Subversion, see:<br />
http://subversion.tigris.org/<br />
<br />
Note: the CVS is still accessable, but it frozen. This means<br />
that no new updates are comitted.<br />
<br />
=====Compiling and running=====<br />
Whether you checkout from cvs or svn, the next step is: <br />
<br />
;compile lazarus:<br />
[]$ cd lazarus<br />
[]$ make (gmake on BSD)<br />
<br />
<br />
If fpc is installed correctly, the compilation should work without problems. If not, see FAQ.<br />
<br />
;Start lazarus<br />
[]$ ./lazarus<br />
<br />
The IDE should start. If you started lazarus in a terminal, you can see some notes about missing settings. This is normal at first start. The IDE automatically tries to find out where the freepascal compiler and its sources are installed by searching in the most common directories.<br />
<br />
;Check the paths:<br />
: Use the IDE menu to go to<br />
:: Environment -> Environment Options -> Files<br />
<br />
The 'FPC Source directory' should point to your fpc source directory. This directory normally ends with /fpc/ or /fpcsrc/ (e.g. /usr/src/fpcsrc or /home/username/freepascal/fpc) and contains directories like 'compiler', 'docs', 'fcl', 'rtl' and 'packages'.<br />
<br />
''ToDo: explain the other paths''<br />
<br />
;Hint:<br />
To update lazarus you can use<br />
[]$ svn update lazarus<br />
then for either update pathway:<br />
[]$ make clean all (gmake on BSD)<br />
This will rebuild lazarus and create an IDE without lazarus packages. To link your installed packages do '''after''' the above:<br />
[]$ make idepkg<br />
<br />
====Installing Lazarus under Debian GNU/Linux====<br />
<br />
There are preliminary Debian packages for lazarus available for download. Make sure you read /usr/share/doc/lazarus/README.Debian carefully before you start using it. Feedback is needed and appreciated; please send your comments to Carlos Laviola <claviola@debian.org>.<br />
<br />
====Another (?easier) way to install Lazarus under Debian====<br />
Added by [[User:Kirkpatc]].<br />
<br />
;Simple Lazarus Installation in Debian<br />
(assume new Debian installation, without development libraries loaded)<br />
<br />
From sourceforge repository, download latest fpc, fpclib and lazarus releases; follow links from http://lazarus.freepascal.org, click the "downloads" button on the left, then click on "binaries" then "linux" then "Current Lazarus RPM". This will bring you to <br />
: http://sourceforge.net/project/showfiles.php?group_id=89339<br />
then download the following files (or more recent, if available)<br />
* fpc-2.0.0-0.i586.rpm<br />
* fpcsrc-2.0.0-0.i386.rpm<br />
* lazarus-0.9.8-fpc_2.0.0_0.i386.rpm<br />
cd to the directory where these files are stored, then become root (su) and type:<br />
<br />
alien fpc* //this will convert both the fpc and fpcsrc files to debian format<br />
alien laz*<br />
then install the generated Debian (.deb) packages by (as root):<br />
<br />
dpkg -i fpc*.deb laz*.deb<br />
or use kpackage or a similar utility to install the generated fpc, fpcsrc and lazarus .deb files.<br />
<br />
Note, if you do not have alien type:<br />
<br />
apt-get install alien<br />
<br />
You need to produce a configuration file, which will reside in /etc/fpc.cfg. Still as root, cd to the main fpc directory /usr/lib/fpc/2.0.0 and then type<br />
sh ./samplecfg /usr/lib/fpc/2.0.0 /etc<br />
Check the contents of your new configuration file (cat /etc/fpc.cfg) and make any changes you want using vi or another text editor. Also make sure that there are no old configuration files in for example your home directory (~/.fpc.cfg).<br />
<br />
You need to install the development packages of the GTK and pixbuf libraries, so<br />
apt-get install libgtk2.0-dev<br />
apt-get install libgdk-pixbuf-dev<br />
Then you should be ready to start programming!<br />
<br />
===Installing Lazarus under Mac OS X===<br />
<br />
Works pretty much the same as under Linux. But you need to install first the apple developer tools and X11.<br />
<br />
Snapshots are available at http://www.de.freepascal.org/lazarus/.<br />
<br />
If you want to experiment and develop the carbon widgetset interface, look at [[Installing Carbon on OSX]].<br />
<br />
===Installing Lazarus under Windows===<br />
<br />
The current releases of the Windows Lazarus binary packages install very easily, and should work 'out-of-the-box'. <br />
<br />
It is even possible to install the whole Lazarus/FPC package on a portable USB drive (capacity at least 256 MB), for use in environments where you are not allowed to install software on your Windows workstation or where you haven't got administrator privileges. You do have to be a little careful about adjusting the paths in the compiler and environment options and the fpc.cfg file. It may also be necessary to keep the directory for test compilation on your portable drive. << DOES ANYONE KNOW HOW TO SET UP RELATIVE PATHS IN THESE TAGS AND FILES, SO THAT THE ADDRESSING WORKS WHEN YOU MOVE THE USB DEVICE TO ANOTHER MACHINE WHERE IT HAS A DIFFERENT DRIVE LETTER? >><br />
<br />
The binary package is available for Linux and Windows from<br />
<br />
http://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
Download the latest release (currently Lazarus-0.9.6-20050225-win32.exe) and launch the application. You will be taken through a typical Windows installation, in which the FPC compiler and source libraries are installed within the same directory structure as Lazarus, and the IDE should launch and operate without significant problems, provided you have uninstalled any previous version of Lazarus and/or FPC (often found in the C:\pp directory).<br />
<br />
You can also get a Lazarus Snapshot for Windows at: http://www.de.freepascal.org/lazarus/<br />
<br />
====Installing from source====<br />
If you prefer to install from sources, then follow these instructions (Thanks to Joe for the initial Step-by-step description)<br />
<br />
You have to download the lazarus source:<br />
: http://www.de.freepascal.org/lazarus/<br />
<br />
Then unzip it to c:\lazarus for example. You have to install at least fpc-2.0.0, but a fpc-2.0.1 or fpc 2.1.1 snapshot is also possible. It compiles for me, and lazarus.exe works. The path to my fpc is: c:\pp\bin\win32. In this directory you can find a lot of exe (make, grep, ppc386, and so on).<br />
<br />
Open a command line. Start->Run...>command or choose MS-DOS icon.<br />
<br />
Type:<br />
cd c:\lazarus<br />
set path=c:\pp\bin\win32;c:\lazarus //of course change the first to<br />
//the path of yours<br />
windres -i lazarus.rc -o lazarus.res<br />
make<br />
<br />
If you are lucky then you can type: lazarus.exe. The source editor, dialogs and the property editor work, but not perfectly... Look and you will see.<br />
<br />
You can compile examples also:<br />
<br />
cd examples<br />
make<br />
<br />
If you extracted lazarus to another drive, eg.: d:\lazarus. It can happen that you need the gnu utility to make it. If you have it, you can take its path to set path=...;<gmakepath> but it is simpler not to choose drive d:\<br />
<br />
That's all.<br />
<br />
=== Additional experiences and advice on installing FPC and Lazarus ===<br />
On linux, getting Lazarus to work can be complicated. If you have already installed earlier versions of FPC and/or Lazarus, you have to take great care that the PATHS are adjusted so that only your new versions are called.<br />
<br />
Pitfalls that I have experienced in various attempts with SuSE linux include:<br />
<br />
The rpm versions often install FPC in /bin or /usr/bin, with the libraries in /lib or /usr/lib.<br />
<br />
If you perform a make install on a source version or use a .tar.gz, the compiler is usually installed in /usr/local/bin with the libraries in /usr/local/lib.<br />
<br />
So if earlier versions have been installed from rpm, make sure all links are changed to reflect the directory structure of your new compiler. The place to make the changes is in /etc/fpc.cfg ; make sure there are no remnant configuration files in your home directory or in your FPC download directory. Typically they are found in ~/.fpc.cfg<br />
<br />
Make sure the links in /etc/fpc.cfg point to the correct versions of the libraries (particularly if you have older versions still lurking around).<br />
<br />
In /usr/local/bin or /usr/bin there is a file called fpc ; this is the executable that is called when you invoke the compiler. One of the first things it does is to open ppc386 in the same directory. This has to be the same version as the fpc file, or can be a link pointing to the true ppc386 in some other directory (such as a library directory, or the fpc directory in your own development space); be sure to update your link if you install a newer version of the compiler.<br />
<br />
Try running the compiler from the command line using one of the simple example programs or one which you wrote yourself.<br />
<br />
Turning to Lazarus:<br />
<br />
If you use a downloaded snapshot (.tar.gz) or get the source from CVS, enter your lazarus directory and type<br />
<br />
make<br />
./lazarus <br />
<br />
and hopefully the IDE should load. There may be a message saying it can't find the sources; if so, go to the menu at the top and select Environment -> Environment options and insert the name of the directory where you expect to find your lazarus files (eg ~/FreePascal/lazarus), your compiler (eg /usr/local/bin/ppc386), the FreePascal source directory (eg /usr/local/lib/fpc/$version/fpc or a directory in your own space eg ~/FreePascal/fpc). Then close the dialog and start programming.<br />
<br />
You may find further problems when you start programming or compiling; most of these will be related to PATH selection.<br />
<br />
Many of the difficulties are dealt with in the Lazarus FAQ, found either on this WiKi site, or a more complete list on the main Lazarus site<br />
<br />
http://www.lazarus.freepascal.org/modules.php?op=modload&name=FAQ&file=index<br />
<br />
From the top menu select Run -> Compiler Options (or Project -> Compiler Options in more recent releases of Lazarus) and select the Paths tab on the resulting dialog. There are several boxes for entry of paths for Unit files, Include files, Other source files, Libraries etc. For each of these, it is worth pressing the ... (ellipsis) button on the right, and you will be given a blank window for inserting path information, and a lower window giving some suggestions. Select as many as you like (or ALL!) and press the ADD button to transfer the selections to the upper window. When your selection is complete, press OK and move on to the next box. If you know of other paths which need to be followed, press the Browse button associated with each box, and insert the additional paths.<br />
<br />
When you think you have got your paths right, try to compile your application. If there are further path-related errors ('can't find unit .......') then go back and check your paths, both in /etc/fpc.cfg and in your Run -> Compiler Options dialog (or Project -> Compiler Options depending on your version).<br />
<br />
Once you have got the environment and PATHS correct, it is worth saving the settings to a file, otherwise you will have to go through this process for each new project. In the Run -> Compiler options dialog there is a Load/Save button; select this and then save the setings to the filename of your choice: mine is ~/FreePascal/default.cfg. Then each time I start a new project, I can go to the Run -> Compiler Options dialog (or Project -> Compiler Options), select Load/Save, and load my default.cfg file to the new project. You can, of course, modify the options for each new project if you so desire.<br />
<br />
===Installing Lazarus under BSD===<br />
<br />
Please write me!<br />
<br />
==Original contributors and changes==<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=InstallingLazarus version].<br />
* Initially imported and formatted. [[User:Tom | VlxAdmin]] 9/22/2003<br />
* Changed Joe's part for Windows to require fpc 1.0.10. [[User:Vincent | Vincent]] 9/25/2003<br />
* Updated "What is required for lazarus". AndrewJohnson 10/1/2003<br />
* Finished formatted the InstallingLazarus page [[User:Tom | VlxAdmin]] 2/22/2004<br />
* Posted some notes about Installing FPC and Lazarus: mostly reflecting experiences in trying to get the PATHS right in Linux. 3/11/2004 [[User:Kirkpatc]]<br />
* Copied the contents of my note into the main InstallingLazarus section, edited it slightly. I don't know how to remove the original note. 3/12/2004 [[User:Kirkpatc]]<br />
* Removed the original note. Tidied the wiki and formatting a bit. [[User:Tom | VlxAdmin]]<br />
* Corrected a couple of typos - 3/12/2004 [[User:Kirkpatc]]<br />
* Added link for daily snapshot deb packages - 3/27/2004 [[User:Vincent | Vincent]]<br />
* Fixed links in GettingLazarus (downloading binaries) and several other pages. 22 July 2004 [[User:Kirkpatc]]<br />
* Added link for lazarus deb packages - 19 August 2004 VincentSnijders<br />
* Added a short note on installing in Debian - 23 Nov 2004 [[User:Kirkpatc]]<br />
* Considerable re-write and re-organization of installation section - 11 Dec 2004 [[User:Kirkpatc]]<br />
* Fixed broken link - 9 Oct 2005 [[User:Avantman42]]</div>Fititnthttps://wiki.freepascal.org/index.php?title=Installing_Lazarus/pt&diff=3800Installing Lazarus/pt2005-11-20T19:06:39Z<p>Fititnt: </p>
<hr />
<div>{{Installing Lazarus}}<br />
<br />
==Overview==<br />
Para pessoas que simplesmente querem instalar Lazarus e começar a usá-lo para programar, a maneira mais fácil é instalar uma versão recente, razoavelmente estável, de um binário (como um pacote linux ". rpm" ou um Windows ". exe"). Você pode ler as seções abaixo de linux ou Windows intitulado "binários de fpc" ou os primeiros parágrafos nas seções em instalar Lazarus em linux ou Windows; a maioria da informação restantes podem ser ignoradas seguramente. <br />
<br />
Para os que querem participar no desenvolvimento do compilador ou da IDE, ou para quem quer ter as ferramentas com atualizações em dia, uma instalação de arquivos de fonte é necessária, e muito do resto desta informação é pertinente. <br />
Lazarus provê duas partes principais: <br />
<br />
<br />
Lazarus provê duas partes principais: <br />
* LCL - Biblioteca de Componentes do Lazarus ( Lazarus Component Library ) <br />
* IDE - ferramenta de RAD <br />
<br />
Estes são em troca dependentes de <br />
* FPC - o compilador de freePascal ( freePascal compiler ) <br />
* FCL - a Biblioteca de Componentes FreePascal Componente biblioteca (FreePascal Component Library ), contendo a maioria dos componentes de não-gráficos usado pelo Lazarus.<br />
<br />
===Lazarus System Requirements===<br />
<br />
# Compilador de FreePascal, pacotes (packages), e fontes ( sources). (*important*: of the same version/date)<br />
# Uma Widget tool-kit de suporte<br />
#:;Win32: : API nativas do Win32 podem ser usadas<br />
#:;Linux/xxxBSD: GTK+ 1.2.x : A maioria distribuições de Linux e * BSDs já instalam bibliotecas GTK+ 1.2.x. Você também pode achar em http://www.gtk.org. <br> Você também desejará ter gdk-pixbuf, 0.13 ou mais novo ( preferencialmente 0.18 ou mais recente), que também é achado na maioria das recentes distribuições dos últimos 2 anos. A fonte está disponível em ftp://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/<br />
#:;Mac OS X: GTK+ 1.2.x : Você precisa das ferramentas de desenvolvedor da apple, X11 e GTK1.2. Veja abaixo como instalar o Lazarus no Mac OS X.<br />
#:;GTK+ 2.x: ADVERTÊNCIA : A interface interativa GTK2 não está totalmente implementada é só deve ser usada para testes. <br> É encontrada na maioria das distribuições recentes. Peque a fonte em http://www.gtk.org.<br />
<br />
<br />
A FAQ - As perguntas frequentemente perguntadas podem ser encontradas em http://www.lazarus.freepascal.org . Algumas respostas podem ser encontradas no arquivo local 'FAQ'.<br />
<br />
<br />
As seções seguintes descreverão como adquirir FreePascal e como instalar lazarus corretamente.<br />
<br />
==Installing The Free Pascal Compiler==<br />
<br />
There is an extensive discussion of how to install and build Free Pascal compilers available here http://www.stack.nl/~marcov/buildfaq.pdf - it may be a little too detailed for some users, but is very comprehensive.<br />
<br />
Lazarus requires fpc (FreePascal) version 1.9.x and it requires both the compiled fpc libs (binaries) and the fpc sources and of the same version. fpc 1.0.6 is too buggy and fpc 1.0.10 has problems opening forms created with fpc 1.9.x. FreePascal version 2.0.0 has now been released, and is the preferred compiler (fpc-2.0.0).<br />
<br />
===Installing Free Pascal under Linux===<br />
<br />
====FPC Binaries====<br />
<br />
The latest release of FreePascal, version 2.0.1, can be obtained from the FreePascal website (http://www.freepascal.org/download.html, then choose a mirror) or from sourceforge (http://sourceforge.net/projects/lazarus). <br />
<br />
At the lazarus downloads section (http://www.lazarus.freepascal.org ) you can get the RPM of the Free Pascal compiler (compiler / linux) and its packages. If you don't have an RPM-based distribution, you can download and install the tarballs from http://www.freepascal.org. If you want to compile the binaries for yourself, see the BSD section.<br />
<br />
Instructions: <br />
<br />
Download lastest files from http://sourceforge.net/project/showfiles.php?group_id=89339.<br />
As example:<br />
:* fpc-2.0.1-050923.i386.rpm<br />
:* fpcsrc-2.0.1-050923.i386.rpm<br />
:* lazarus-0.9.10-0.i386.rpm<br><br />
and install them with:<br />
:* rpm -Uvh fpc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh fpcsrc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh lazarus-0.9.10-0.i386.rpm<br><br />
<br />
Daily snapshot Debian packages can be downloaded from http://cYcnus.de/deb/. At present this contains only the compiled fpc components, but not the sources, which would be needed for most Lazarus programming.<br />
<br />
====FPC Sources====<br />
<br />
Together with the release of version 2.0, FPC no longer uses CVS, but has migrated to Subversion (SVN). For now, there is no CVS mirror yet, so you have to use SVN to get the FPC sources.<br />
<br />
===== Download Daily Source Snapshot of Development Tree (version 2.1.x) =====<br />
You can download today's development (v 2.1.x) sources in the form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.1.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v21/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
===== Download Daily Source Snapshot of Release Tree (version 2.0.x) =====<br />
You can download today's development (v 2.0.x) sources that will lead to the next stable release in form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.0.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v20/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
<br />
===== Connect to Source Repository with SVN (replaces section on connection to CVS) =====<br />
As an alternative to the daily zip files of the SVN sources, the SVN repository has been made accessible for everyone, with read-only access. This means that you can directly access the code, and you will have really the last-minute sources available. It is also a method which requires less bandwidth once you have done the first download (checkout in SVN lingo).<br />
===== Development snapshots =====<br />
How to do this? <br />
(You need to have SVN installed, of course. Look [http://subversion.tigris.org/ here] for instructions on how to do that.)<br />
<br />
Change Directory (cd) to the parent directory of your development area, eg <br />
<br />
[]$ cd /home/username/FreePascal<br />
<br />
To retrieve the full source repository, all publicly available modules, type<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc<br />
<br />
Normally, you should perform this step just once.<br />
<br />
To update the sources which were downloaded (checkout) above<br />
<br />
[]$svn update fpc<br />
<br />
<br />
===== Fixes to 2.0.x =====<br />
<br />
The fixes need a separate directory, create a separate directory 'fixes', enter it, and repeat the above checkout command with the URL http://svn.freepascal.org/svn/fpc/branches/fixes_2_0:<br />
<br />
[]$ cd mysvn/fixes<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_0 fpc<br />
<br />
and to update:<br />
<br />
[]$ svn update fpc<br />
<br />
The sources of docs are in a separate repository called fpcdocs, so the command to get them is<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs<br />
<br />
If you want to learn more about subversion, read this excellent [http://svnbook.red-bean.com/ Subversion book] which is also available online in different formats for free.<br />
<br />
For the curious: You have only read-only access, so don't try to commit anything :-)<br />
<br />
For more information, see the [http://www.freepascal.org/develop.html FreePascal] website<br />
<br />
===Installing Free Pascal under Windows===<br />
<br />
====FPC Binaries for Windows====<br />
<br />
By far the easiest way to get a working installation of Free Pascal is to download the current binary Windows release of Lazarus from the SourceForge repository - the release contains the current versions of the FreePascal compiler and the FreePascal libraries as well as the lazarus IDE. If you want to install from sources, read on!<br />
<br />
You can get the installer zip for fpc 2.0.0 at Free Pascal's download section http://www.freepascal.org/download.html, then choose a mirror). <br />
Installing from the sources -- see the next section to know how to get them -- is not for novices, since you need a starting compiler as well.<br />
<br />
====FPC Sources for Windows====<br />
<<<< See section above under [[#FPC Sources|FPC Sources]] for Linux, where the use of SVN is described >>>><br />
<br />
The easiest way to get the Free Pascal sources is via CVS; see the next section for more on that. You can also download the package as a whole -- see http://www.freepascal.org/develop.html for the daily snapshot of the 2.1.x release tree.<br />
<br />
Windows FPC Sources via CVS ()<br />
<br />
You will need to have a CVS client such as TortoiseCVS or WinCVS installed in order to perform the steps below. The exact commands vary between CVS clients; the ones given below are to be used under CVS home's client, which is available for download here.<br />
<br />
First create a directory in which you'd like to put the sources. Any normal user can do this. Create a directory for fpc (e.g. C:\Source), then do the following at the command prompt:<br />
C:\Source> set CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
C:\Source> cvs login // password is 'cvs' without the commas<br />
C:\source> cvs -z3 co fpc // This will create a directory fpc, which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
C:\> cd Source\FPC<br />
C:\Source\FPC> cvs -z3 update -dP<br />
''ToDo: Write me.''<br />
<br />
See: http://www.freepascal.org/down-win32.html . You can find a list of mirrors at http://www.freepascal.org/sdown.html. Download FPC as one big file, unzip it and run the install.exe. <br />
<br />
Extending your PATH variable to the fpc directory:<br />
<br />
* Win98: Edit autoexec.bat and add the line: PATH=%PATH%;C:\pp\bin\bin\win32<br />
* WinXP/2k: My Computer (Right Click) -> Properties -> Advanced (Page) -> Enviroment Variables -> System Variables -> Edit "PATH", Add "C:\pp\bin\bin\win32" there.<br />
<br />
Then restart windows.<br />
<br />
''ToDo: Explain how to download fpc sources and build the compiler''<br />
<br />
===Installing Free Pascal under BSD/manually===<br />
<br />
Effectively, you need<br />
<br />
A file with all sources, or two (fpc and lazarus)<br />
<br />
1. e.g. for fpc ftp://ftp.freepascal.org/fpc/dist/Linux/separate/sources.tar preferably an export (no CVS/ dirs). The above file misses this.<br />
2. Lazarus source snapshot.<br />
* _any_ starting compiler from the 1.9 branch) You can do a check by parsing the output of ppc386 -i if it is 1.9.3 .. 2.0.x it is ok.<br />
* - dependant packages. (for FreeBSD that is gtk12, glib12 and gdk_pixbuf and GNU make, iconv and gettext)<br />
<br />
FPC build:<br />
<br />
1. (fetch) necessary files (FPC source, starting compiler)<br />
2. (extract) Then de-tgz in work directory,<br />
3. (build) enter work/fpc/ and run<br />
<br />
$MAKE all OPT='-gl -O3p3' PP=/path/to/startingcompiler-name-ppc386<br />
(/path/to/ can be omitted when ppc386 is in the path)<br />
($MAKE is make on linux and gmake on BSD)<br />
<br />
4. (install) then, again in work/fpc, run<br />
<br />
$MAKE install PP=compiler/ppc386 PREFIX=$THEPREFIX<br />
(THEPREFIX= usually is /usr/lcoal, but e.g. on NetBSD it is /usr/pkg for ports)<br />
Create a symlink:<br />
ln -s $THEPREFIX/lib/fpc/2.0.1/ppc386 $THEPREFIX/bin/ppc386<br />
install sourceinstall PREFIX=$THEPREFIX<br />
<br />
5. (configure) run compiler/utils/samplecfg $THEPREFIX/lib/fpc/2.0.1 $ETCDIR<br />
6. (optional, test), see if ppc386 -i gives output, else give a warning that user need to add $PREFIX/bin to his current path. Try to compiler a program with -viwn, and see if that gives errors.<br />
Notes:<br />
<br />
* If you need fpcmake package lists, you need to generate or supply them yourself, (in the port, or in an extra archive) either way, do a dummy install to /tmp/pack and determine the files installed with find . >ll<br />
<br />
* $THEPREFIX and $ETCDIR should be user configurable. Otherwise local installs aren't possible.<br />
<br />
* BSDHIER=1 on all make commands forces BSD hierarchy conventions.<br />
<br />
===Installing Free Pascal under Mac OS X===<br />
<br />
You need the Apple Developer-tools, X11, gtk1.2:<br />
<br />
Downloading packages and installing them properly can be a time consuming task. Therefore there are various package managers. One of them is fink:<br />
: Download fink from http://fink.sourceforge.net/download/index.php?phpLang=en; follow the install instructions.<br />
<br />
Developer-tools: Are included on the original OSX installation-CDs, or download at ADC (free registration required)<br />
: http://developer.apple.com/.<br />
<br />
Apple X11: On a fresh system: choose "Customize" in the install-dialogue, check "X11".<br />
<br />
On an already installed system: download at<br />
: http://www.apple.com/downloads/macosx/apple/x11formacosx.html<br />
<br />
In the Terminal, run<br />
sudo fink install gdk-pixbuf gtk+ gtk+-data gtk+-shlibs gtk-doc gtkglarea gtk-engines<br />
The X11-Application is in /Applications/Utilities/X11.<br />
<br />
Hint: Most X11 programs, including lazarus expect to receive focus, when the users clicks on a window. Under MacOSX this is deactivated. You can activate it for all X11 applications by typing in the terminal:<br />
defaults write com.apple.x11 wm_click_through -bool true<br />
<br />
;Free Pascal Compiler:<br />
Then download and install the Free Pascal Compiler (at least 1.9.5 from 16th August 2004) from<br />
: https://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
When compiling gtk-related software, you need to add two lines to the fpc.cfg file, to enable use of libraries<br />
-Fl/sw/lib<br />
-Fl/usr/X11R6/lib<br />
<br />
<br />
For lazarus you need the fpc sources as well (obsolete: use svn):<br />
Create a directory, where you would like to put the sources. You don't need to be root to do this. Any normal user can do this. <br />
First create a directory for fpc <br />
: (e.g. /Users/username/freepascal) <br />
then open a terminal and do the following:<br />
[]$ bash<br />
[]$ export CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
[]$ cvs login<br />
password is 'cvs' without the 'quotes'<br />
[]$ cvs -z3 co fpc<br />
This will create a directory called 'fpc', which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
[]$ cd /Users/username/freepascal/fpc<br />
[]$ cvs -z3 update -dP<br />
<br />
==Installing Lazarus==<br />
<br />
===Installing Lazarus under Linux===<br />
====Installing using rpms====<br />
The easiest way to get a current working installation of Lazarus is to download the RPMs for FreePascal and Lazarus from the SourceForge repository.<br />
<br />
You need to download the selected version of<br />
* the compiler (eg fpc-1.9.5-041207.i386.rpm)<br />
* the pascal source library (eg fpcsrc-1.9.5-041207.i386.rpm)<br />
* the Lazarus package (eg lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm).<br />
<br />
You then issue the following commands (you need to have root privileges - use su or sudo)<br />
rpm -Uvh fpc-1.9.5-041207.i386.rpm<br />
rpm -Uvh fpcsrc-1.9.5-041207.i386.rpm<br />
rpm -Uvh lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm<br />
<br />
====Installing from source====<br />
If you prefer to install from source and compile the files yourself, follow these instructions. Because the whole lazarus stuff is installed into one directory, uninstall is very easy and you don't need to be root to install lazarus. You can get tgz files for fpc, fpcsrc and lazarus from the downloads section or you can download it directly via svn.<br />
<br />
=====Downloading Lazarus SVN=====<br />
<br />
The lazarus repository has moved from cvs to svn (Subversion). SVN provides an easy way to update your sources by only downloading the changes. This is the recommended way and saves you a lot of time. A connection to the internet is needed for this: you don't need to be root. Lazarus does not need any special permissions, neither during installation nor at runtime.<br />
<br />
With the move we also changed the directory layout of the lazarus sources. The main difference<br />
is that all ide sources are moved from the root to a separate ide subdir. As anybody might understand, this has an impact on the Makefiles, the searchpaths etc. We are in progress of fixing things, so if something doesn't work, please let us know.<br />
<br />
;Now the most important thing.... getting the sources:<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk/ lazarus<br />
(or any other dir where you want to place your sources)<br />
<br />
On subsequent occasions, to update simply type<br />
<br />
[]$ svn update lazarus<br />
<br />
For more information on Subversion, see:<br />
http://subversion.tigris.org/<br />
<br />
Note: the CVS is still accessable, but it frozen. This means<br />
that no new updates are comitted.<br />
<br />
=====Compiling and running=====<br />
Whether you checkout from cvs or svn, the next step is: <br />
<br />
;compile lazarus:<br />
[]$ cd lazarus<br />
[]$ make (gmake on BSD)<br />
<br />
<br />
If fpc is installed correctly, the compilation should work without problems. If not, see FAQ.<br />
<br />
;Start lazarus<br />
[]$ ./lazarus<br />
<br />
The IDE should start. If you started lazarus in a terminal, you can see some notes about missing settings. This is normal at first start. The IDE automatically tries to find out where the freepascal compiler and its sources are installed by searching in the most common directories.<br />
<br />
;Check the paths:<br />
: Use the IDE menu to go to<br />
:: Environment -> Environment Options -> Files<br />
<br />
The 'FPC Source directory' should point to your fpc source directory. This directory normally ends with /fpc/ or /fpcsrc/ (e.g. /usr/src/fpcsrc or /home/username/freepascal/fpc) and contains directories like 'compiler', 'docs', 'fcl', 'rtl' and 'packages'.<br />
<br />
''ToDo: explain the other paths''<br />
<br />
;Hint:<br />
To update lazarus you can use<br />
[]$ svn update lazarus<br />
then for either update pathway:<br />
[]$ make clean all (gmake on BSD)<br />
This will rebuild lazarus and create an IDE without lazarus packages. To link your installed packages do '''after''' the above:<br />
[]$ make idepkg<br />
<br />
====Installing Lazarus under Debian GNU/Linux====<br />
<br />
There are preliminary Debian packages for lazarus available for download. Make sure you read /usr/share/doc/lazarus/README.Debian carefully before you start using it. Feedback is needed and appreciated; please send your comments to Carlos Laviola <claviola@debian.org>.<br />
<br />
====Another (?easier) way to install Lazarus under Debian====<br />
Added by [[User:Kirkpatc]].<br />
<br />
;Simple Lazarus Installation in Debian<br />
(assume new Debian installation, without development libraries loaded)<br />
<br />
From sourceforge repository, download latest fpc, fpclib and lazarus releases; follow links from http://lazarus.freepascal.org, click the "downloads" button on the left, then click on "binaries" then "linux" then "Current Lazarus RPM". This will bring you to <br />
: http://sourceforge.net/project/showfiles.php?group_id=89339<br />
then download the following files (or more recent, if available)<br />
* fpc-2.0.0-0.i586.rpm<br />
* fpcsrc-2.0.0-0.i386.rpm<br />
* lazarus-0.9.8-fpc_2.0.0_0.i386.rpm<br />
cd to the directory where these files are stored, then become root (su) and type:<br />
<br />
alien fpc* //this will convert both the fpc and fpcsrc files to debian format<br />
alien laz*<br />
then install the generated Debian (.deb) packages by (as root):<br />
<br />
dpkg -i fpc*.deb laz*.deb<br />
or use kpackage or a similar utility to install the generated fpc, fpcsrc and lazarus .deb files.<br />
<br />
Note, if you do not have alien type:<br />
<br />
apt-get install alien<br />
<br />
You need to produce a configuration file, which will reside in /etc/fpc.cfg. Still as root, cd to the main fpc directory /usr/lib/fpc/2.0.0 and then type<br />
sh ./samplecfg /usr/lib/fpc/2.0.0 /etc<br />
Check the contents of your new configuration file (cat /etc/fpc.cfg) and make any changes you want using vi or another text editor. Also make sure that there are no old configuration files in for example your home directory (~/.fpc.cfg).<br />
<br />
You need to install the development packages of the GTK and pixbuf libraries, so<br />
apt-get install libgtk2.0-dev<br />
apt-get install libgdk-pixbuf-dev<br />
Then you should be ready to start programming!<br />
<br />
===Installing Lazarus under Mac OS X===<br />
<br />
Works pretty much the same as under Linux. But you need to install first the apple developer tools and X11.<br />
<br />
Snapshots are available at http://www.de.freepascal.org/lazarus/.<br />
<br />
If you want to experiment and develop the carbon widgetset interface, look at [[Installing Carbon on OSX]].<br />
<br />
===Installing Lazarus under Windows===<br />
<br />
The current releases of the Windows Lazarus binary packages install very easily, and should work 'out-of-the-box'. <br />
<br />
It is even possible to install the whole Lazarus/FPC package on a portable USB drive (capacity at least 256 MB), for use in environments where you are not allowed to install software on your Windows workstation or where you haven't got administrator privileges. You do have to be a little careful about adjusting the paths in the compiler and environment options and the fpc.cfg file. It may also be necessary to keep the directory for test compilation on your portable drive. << DOES ANYONE KNOW HOW TO SET UP RELATIVE PATHS IN THESE TAGS AND FILES, SO THAT THE ADDRESSING WORKS WHEN YOU MOVE THE USB DEVICE TO ANOTHER MACHINE WHERE IT HAS A DIFFERENT DRIVE LETTER? >><br />
<br />
The binary package is available for Linux and Windows from<br />
<br />
http://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
Download the latest release (currently Lazarus-0.9.6-20050225-win32.exe) and launch the application. You will be taken through a typical Windows installation, in which the FPC compiler and source libraries are installed within the same directory structure as Lazarus, and the IDE should launch and operate without significant problems, provided you have uninstalled any previous version of Lazarus and/or FPC (often found in the C:\pp directory).<br />
<br />
You can also get a Lazarus Snapshot for Windows at: http://www.de.freepascal.org/lazarus/<br />
<br />
====Installing from source====<br />
If you prefer to install from sources, then follow these instructions (Thanks to Joe for the initial Step-by-step description)<br />
<br />
You have to download the lazarus source:<br />
: http://www.de.freepascal.org/lazarus/<br />
<br />
Then unzip it to c:\lazarus for example. You have to install at least fpc-2.0.0, but a fpc-2.0.1 or fpc 2.1.1 snapshot is also possible. It compiles for me, and lazarus.exe works. The path to my fpc is: c:\pp\bin\win32. In this directory you can find a lot of exe (make, grep, ppc386, and so on).<br />
<br />
Open a command line. Start->Run...>command or choose MS-DOS icon.<br />
<br />
Type:<br />
cd c:\lazarus<br />
set path=c:\pp\bin\win32;c:\lazarus //of course change the first to<br />
//the path of yours<br />
windres -i lazarus.rc -o lazarus.res<br />
make<br />
<br />
If you are lucky then you can type: lazarus.exe. The source editor, dialogs and the property editor work, but not perfectly... Look and you will see.<br />
<br />
You can compile examples also:<br />
<br />
cd examples<br />
make<br />
<br />
If you extracted lazarus to another drive, eg.: d:\lazarus. It can happen that you need the gnu utility to make it. If you have it, you can take its path to set path=...;<gmakepath> but it is simpler not to choose drive d:\<br />
<br />
That's all.<br />
<br />
=== Additional experiences and advice on installing FPC and Lazarus ===<br />
On linux, getting Lazarus to work can be complicated. If you have already installed earlier versions of FPC and/or Lazarus, you have to take great care that the PATHS are adjusted so that only your new versions are called.<br />
<br />
Pitfalls that I have experienced in various attempts with SuSE linux include:<br />
<br />
The rpm versions often install FPC in /bin or /usr/bin, with the libraries in /lib or /usr/lib.<br />
<br />
If you perform a make install on a source version or use a .tar.gz, the compiler is usually installed in /usr/local/bin with the libraries in /usr/local/lib.<br />
<br />
So if earlier versions have been installed from rpm, make sure all links are changed to reflect the directory structure of your new compiler. The place to make the changes is in /etc/fpc.cfg ; make sure there are no remnant configuration files in your home directory or in your FPC download directory. Typically they are found in ~/.fpc.cfg<br />
<br />
Make sure the links in /etc/fpc.cfg point to the correct versions of the libraries (particularly if you have older versions still lurking around).<br />
<br />
In /usr/local/bin or /usr/bin there is a file called fpc ; this is the executable that is called when you invoke the compiler. One of the first things it does is to open ppc386 in the same directory. This has to be the same version as the fpc file, or can be a link pointing to the true ppc386 in some other directory (such as a library directory, or the fpc directory in your own development space); be sure to update your link if you install a newer version of the compiler.<br />
<br />
Try running the compiler from the command line using one of the simple example programs or one which you wrote yourself.<br />
<br />
Turning to Lazarus:<br />
<br />
If you use a downloaded snapshot (.tar.gz) or get the source from CVS, enter your lazarus directory and type<br />
<br />
make<br />
./lazarus <br />
<br />
and hopefully the IDE should load. There may be a message saying it can't find the sources; if so, go to the menu at the top and select Environment -> Environment options and insert the name of the directory where you expect to find your lazarus files (eg ~/FreePascal/lazarus), your compiler (eg /usr/local/bin/ppc386), the FreePascal source directory (eg /usr/local/lib/fpc/$version/fpc or a directory in your own space eg ~/FreePascal/fpc). Then close the dialog and start programming.<br />
<br />
You may find further problems when you start programming or compiling; most of these will be related to PATH selection.<br />
<br />
Many of the difficulties are dealt with in the Lazarus FAQ, found either on this WiKi site, or a more complete list on the main Lazarus site<br />
<br />
http://www.lazarus.freepascal.org/modules.php?op=modload&name=FAQ&file=index<br />
<br />
From the top menu select Run -> Compiler Options (or Project -> Compiler Options in more recent releases of Lazarus) and select the Paths tab on the resulting dialog. There are several boxes for entry of paths for Unit files, Include files, Other source files, Libraries etc. For each of these, it is worth pressing the ... (ellipsis) button on the right, and you will be given a blank window for inserting path information, and a lower window giving some suggestions. Select as many as you like (or ALL!) and press the ADD button to transfer the selections to the upper window. When your selection is complete, press OK and move on to the next box. If you know of other paths which need to be followed, press the Browse button associated with each box, and insert the additional paths.<br />
<br />
When you think you have got your paths right, try to compile your application. If there are further path-related errors ('can't find unit .......') then go back and check your paths, both in /etc/fpc.cfg and in your Run -> Compiler Options dialog (or Project -> Compiler Options depending on your version).<br />
<br />
Once you have got the environment and PATHS correct, it is worth saving the settings to a file, otherwise you will have to go through this process for each new project. In the Run -> Compiler options dialog there is a Load/Save button; select this and then save the setings to the filename of your choice: mine is ~/FreePascal/default.cfg. Then each time I start a new project, I can go to the Run -> Compiler Options dialog (or Project -> Compiler Options), select Load/Save, and load my default.cfg file to the new project. You can, of course, modify the options for each new project if you so desire.<br />
<br />
===Installing Lazarus under BSD===<br />
<br />
Please write me!<br />
<br />
==Original contributors and changes==<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=InstallingLazarus version].<br />
* Initially imported and formatted. [[User:Tom | VlxAdmin]] 9/22/2003<br />
* Changed Joe's part for Windows to require fpc 1.0.10. [[User:Vincent | Vincent]] 9/25/2003<br />
* Updated "What is required for lazarus". AndrewJohnson 10/1/2003<br />
* Finished formatted the InstallingLazarus page [[User:Tom | VlxAdmin]] 2/22/2004<br />
* Posted some notes about Installing FPC and Lazarus: mostly reflecting experiences in trying to get the PATHS right in Linux. 3/11/2004 [[User:Kirkpatc]]<br />
* Copied the contents of my note into the main InstallingLazarus section, edited it slightly. I don't know how to remove the original note. 3/12/2004 [[User:Kirkpatc]]<br />
* Removed the original note. Tidied the wiki and formatting a bit. [[User:Tom | VlxAdmin]]<br />
* Corrected a couple of typos - 3/12/2004 [[User:Kirkpatc]]<br />
* Added link for daily snapshot deb packages - 3/27/2004 [[User:Vincent | Vincent]]<br />
* Fixed links in GettingLazarus (downloading binaries) and several other pages. 22 July 2004 [[User:Kirkpatc]]<br />
* Added link for lazarus deb packages - 19 August 2004 VincentSnijders<br />
* Added a short note on installing in Debian - 23 Nov 2004 [[User:Kirkpatc]]<br />
* Considerable re-write and re-organization of installation section - 11 Dec 2004 [[User:Kirkpatc]]<br />
* Fixed broken link - 9 Oct 2005 [[User:Avantman42]]</div>Fititnthttps://wiki.freepascal.org/index.php?title=Installing_Lazarus/pt&diff=3799Installing Lazarus/pt2005-11-20T19:05:43Z<p>Fititnt: </p>
<hr />
<div>{{Installing Lazarus}}<br />
<br />
==Overview==<br />
Para pessoas que simplesmente querem instalar Lazarus e começar a usá-lo para programar, a maneira mais fácil é instalar uma versão recente, razoavelmente estável, de um binário (como um pacote linux ". rpm" ou um Windows ". exe"). Você pode ler as seções abaixo de linux ou Windows intitulado "binários de fpc" ou os primeiros parágrafos nas seções em instalar Lazarus em linux ou Windows; a maioria da informação restantes podem ser ignoradas seguramente. <br />
<br />
Para os que querem participar no desenvolvimento do compilador ou da IDE, ou para quem quer ter as ferramentas com atualizações em dia, uma instalação de arquivos de fonte é necessária, e muito do resto desta informação é pertinente. <br />
Lazarus provê duas partes principais: <br />
<br />
<br />
Lazarus provê duas partes principais: <br />
* LCL - Biblioteca de Componentes do Lazarus ( Lazarus Component Library ) <br />
* IDE - ferramenta de RAD <br />
<br />
Estes são em troca dependentes de <br />
* FPC - o compilador de freePascal ( freePascal compiler ) <br />
* FCL - a Biblioteca de Componentes FreePascal Componente biblioteca (FreePascal Component Library ), contendo a maioria dos componentes de não-gráficos usado pelo Lazarus.<br />
<br />
===Lazarus System Requirements===<br />
<br />
# Compilador de FreePascal, pacotes (packages), e fontes ( sources). (*important*: of the same version/date)<br />
# Uma Widget tool-kit de suporte<br />
#:;Win32: : API nativas do Win32 podem ser usadas<br />
#:;Linux/xxxBSD: GTK+ 1.2.x : A maioria distribuições de Linux e * BSDs já instalam bibliotecas GTK+ 1.2.x. Você também pode achar em http://www.gtk.org. <br> Você também desejará ter gdk-pixbuf, 0.13 ou mais novo ( preferencialmente 0.18 ou mais recente), que também é achado na maioria das recentes distribuições dos últimos 2 anos. A fonte está disponível em ftp://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/<br />
#:;Mac OS X: GTK+ 1.2.x : Você precisa das ferramentas de desenvolvedor da apple, X11 e GTK1.2. Veja abaixo como instalar o Lazarus no Mac OS X.<br />
#:;GTK+ 2.x: ADVERTÊNCIA : A interface interativa GTK2 não está totalmente implementada é só deve ser usada para testes. <br> É encontrada na maioria das distribuições recentes. Peque a fonte em http://www.gtk.org.<br />
<br />
A FAQ - As perguntas frequentemente perguntadas podem ser encontradas em http://www.lazarus.freepascal.org . Algumas respostas podem ser encontradas no arquivo local 'FAQ'.<br />
<br />
As seções seguintes descreverão como adquirir FreePascal e como instalar lazarus corretamente.<br />
<br />
==Installing The Free Pascal Compiler==<br />
<br />
There is an extensive discussion of how to install and build Free Pascal compilers available here http://www.stack.nl/~marcov/buildfaq.pdf - it may be a little too detailed for some users, but is very comprehensive.<br />
<br />
Lazarus requires fpc (FreePascal) version 1.9.x and it requires both the compiled fpc libs (binaries) and the fpc sources and of the same version. fpc 1.0.6 is too buggy and fpc 1.0.10 has problems opening forms created with fpc 1.9.x. FreePascal version 2.0.0 has now been released, and is the preferred compiler (fpc-2.0.0).<br />
<br />
===Installing Free Pascal under Linux===<br />
<br />
====FPC Binaries====<br />
<br />
The latest release of FreePascal, version 2.0.1, can be obtained from the FreePascal website (http://www.freepascal.org/download.html, then choose a mirror) or from sourceforge (http://sourceforge.net/projects/lazarus). <br />
<br />
At the lazarus downloads section (http://www.lazarus.freepascal.org ) you can get the RPM of the Free Pascal compiler (compiler / linux) and its packages. If you don't have an RPM-based distribution, you can download and install the tarballs from http://www.freepascal.org. If you want to compile the binaries for yourself, see the BSD section.<br />
<br />
Instructions: <br />
<br />
Download lastest files from http://sourceforge.net/project/showfiles.php?group_id=89339.<br />
As example:<br />
:* fpc-2.0.1-050923.i386.rpm<br />
:* fpcsrc-2.0.1-050923.i386.rpm<br />
:* lazarus-0.9.10-0.i386.rpm<br><br />
and install them with:<br />
:* rpm -Uvh fpc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh fpcsrc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh lazarus-0.9.10-0.i386.rpm<br><br />
<br />
Daily snapshot Debian packages can be downloaded from http://cYcnus.de/deb/. At present this contains only the compiled fpc components, but not the sources, which would be needed for most Lazarus programming.<br />
<br />
====FPC Sources====<br />
<br />
Together with the release of version 2.0, FPC no longer uses CVS, but has migrated to Subversion (SVN). For now, there is no CVS mirror yet, so you have to use SVN to get the FPC sources.<br />
<br />
===== Download Daily Source Snapshot of Development Tree (version 2.1.x) =====<br />
You can download today's development (v 2.1.x) sources in the form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.1.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v21/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
===== Download Daily Source Snapshot of Release Tree (version 2.0.x) =====<br />
You can download today's development (v 2.0.x) sources that will lead to the next stable release in form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.0.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v20/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
<br />
===== Connect to Source Repository with SVN (replaces section on connection to CVS) =====<br />
As an alternative to the daily zip files of the SVN sources, the SVN repository has been made accessible for everyone, with read-only access. This means that you can directly access the code, and you will have really the last-minute sources available. It is also a method which requires less bandwidth once you have done the first download (checkout in SVN lingo).<br />
===== Development snapshots =====<br />
How to do this? <br />
(You need to have SVN installed, of course. Look [http://subversion.tigris.org/ here] for instructions on how to do that.)<br />
<br />
Change Directory (cd) to the parent directory of your development area, eg <br />
<br />
[]$ cd /home/username/FreePascal<br />
<br />
To retrieve the full source repository, all publicly available modules, type<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc<br />
<br />
Normally, you should perform this step just once.<br />
<br />
To update the sources which were downloaded (checkout) above<br />
<br />
[]$svn update fpc<br />
<br />
<br />
===== Fixes to 2.0.x =====<br />
<br />
The fixes need a separate directory, create a separate directory 'fixes', enter it, and repeat the above checkout command with the URL http://svn.freepascal.org/svn/fpc/branches/fixes_2_0:<br />
<br />
[]$ cd mysvn/fixes<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_0 fpc<br />
<br />
and to update:<br />
<br />
[]$ svn update fpc<br />
<br />
The sources of docs are in a separate repository called fpcdocs, so the command to get them is<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs<br />
<br />
If you want to learn more about subversion, read this excellent [http://svnbook.red-bean.com/ Subversion book] which is also available online in different formats for free.<br />
<br />
For the curious: You have only read-only access, so don't try to commit anything :-)<br />
<br />
For more information, see the [http://www.freepascal.org/develop.html FreePascal] website<br />
<br />
===Installing Free Pascal under Windows===<br />
<br />
====FPC Binaries for Windows====<br />
<br />
By far the easiest way to get a working installation of Free Pascal is to download the current binary Windows release of Lazarus from the SourceForge repository - the release contains the current versions of the FreePascal compiler and the FreePascal libraries as well as the lazarus IDE. If you want to install from sources, read on!<br />
<br />
You can get the installer zip for fpc 2.0.0 at Free Pascal's download section http://www.freepascal.org/download.html, then choose a mirror). <br />
Installing from the sources -- see the next section to know how to get them -- is not for novices, since you need a starting compiler as well.<br />
<br />
====FPC Sources for Windows====<br />
<<<< See section above under [[#FPC Sources|FPC Sources]] for Linux, where the use of SVN is described >>>><br />
<br />
The easiest way to get the Free Pascal sources is via CVS; see the next section for more on that. You can also download the package as a whole -- see http://www.freepascal.org/develop.html for the daily snapshot of the 2.1.x release tree.<br />
<br />
Windows FPC Sources via CVS ()<br />
<br />
You will need to have a CVS client such as TortoiseCVS or WinCVS installed in order to perform the steps below. The exact commands vary between CVS clients; the ones given below are to be used under CVS home's client, which is available for download here.<br />
<br />
First create a directory in which you'd like to put the sources. Any normal user can do this. Create a directory for fpc (e.g. C:\Source), then do the following at the command prompt:<br />
C:\Source> set CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
C:\Source> cvs login // password is 'cvs' without the commas<br />
C:\source> cvs -z3 co fpc // This will create a directory fpc, which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
C:\> cd Source\FPC<br />
C:\Source\FPC> cvs -z3 update -dP<br />
''ToDo: Write me.''<br />
<br />
See: http://www.freepascal.org/down-win32.html . You can find a list of mirrors at http://www.freepascal.org/sdown.html. Download FPC as one big file, unzip it and run the install.exe. <br />
<br />
Extending your PATH variable to the fpc directory:<br />
<br />
* Win98: Edit autoexec.bat and add the line: PATH=%PATH%;C:\pp\bin\bin\win32<br />
* WinXP/2k: My Computer (Right Click) -> Properties -> Advanced (Page) -> Enviroment Variables -> System Variables -> Edit "PATH", Add "C:\pp\bin\bin\win32" there.<br />
<br />
Then restart windows.<br />
<br />
''ToDo: Explain how to download fpc sources and build the compiler''<br />
<br />
===Installing Free Pascal under BSD/manually===<br />
<br />
Effectively, you need<br />
<br />
A file with all sources, or two (fpc and lazarus)<br />
<br />
1. e.g. for fpc ftp://ftp.freepascal.org/fpc/dist/Linux/separate/sources.tar preferably an export (no CVS/ dirs). The above file misses this.<br />
2. Lazarus source snapshot.<br />
* _any_ starting compiler from the 1.9 branch) You can do a check by parsing the output of ppc386 -i if it is 1.9.3 .. 2.0.x it is ok.<br />
* - dependant packages. (for FreeBSD that is gtk12, glib12 and gdk_pixbuf and GNU make, iconv and gettext)<br />
<br />
FPC build:<br />
<br />
1. (fetch) necessary files (FPC source, starting compiler)<br />
2. (extract) Then de-tgz in work directory,<br />
3. (build) enter work/fpc/ and run<br />
<br />
$MAKE all OPT='-gl -O3p3' PP=/path/to/startingcompiler-name-ppc386<br />
(/path/to/ can be omitted when ppc386 is in the path)<br />
($MAKE is make on linux and gmake on BSD)<br />
<br />
4. (install) then, again in work/fpc, run<br />
<br />
$MAKE install PP=compiler/ppc386 PREFIX=$THEPREFIX<br />
(THEPREFIX= usually is /usr/lcoal, but e.g. on NetBSD it is /usr/pkg for ports)<br />
Create a symlink:<br />
ln -s $THEPREFIX/lib/fpc/2.0.1/ppc386 $THEPREFIX/bin/ppc386<br />
install sourceinstall PREFIX=$THEPREFIX<br />
<br />
5. (configure) run compiler/utils/samplecfg $THEPREFIX/lib/fpc/2.0.1 $ETCDIR<br />
6. (optional, test), see if ppc386 -i gives output, else give a warning that user need to add $PREFIX/bin to his current path. Try to compiler a program with -viwn, and see if that gives errors.<br />
Notes:<br />
<br />
* If you need fpcmake package lists, you need to generate or supply them yourself, (in the port, or in an extra archive) either way, do a dummy install to /tmp/pack and determine the files installed with find . >ll<br />
<br />
* $THEPREFIX and $ETCDIR should be user configurable. Otherwise local installs aren't possible.<br />
<br />
* BSDHIER=1 on all make commands forces BSD hierarchy conventions.<br />
<br />
===Installing Free Pascal under Mac OS X===<br />
<br />
You need the Apple Developer-tools, X11, gtk1.2:<br />
<br />
Downloading packages and installing them properly can be a time consuming task. Therefore there are various package managers. One of them is fink:<br />
: Download fink from http://fink.sourceforge.net/download/index.php?phpLang=en; follow the install instructions.<br />
<br />
Developer-tools: Are included on the original OSX installation-CDs, or download at ADC (free registration required)<br />
: http://developer.apple.com/.<br />
<br />
Apple X11: On a fresh system: choose "Customize" in the install-dialogue, check "X11".<br />
<br />
On an already installed system: download at<br />
: http://www.apple.com/downloads/macosx/apple/x11formacosx.html<br />
<br />
In the Terminal, run<br />
sudo fink install gdk-pixbuf gtk+ gtk+-data gtk+-shlibs gtk-doc gtkglarea gtk-engines<br />
The X11-Application is in /Applications/Utilities/X11.<br />
<br />
Hint: Most X11 programs, including lazarus expect to receive focus, when the users clicks on a window. Under MacOSX this is deactivated. You can activate it for all X11 applications by typing in the terminal:<br />
defaults write com.apple.x11 wm_click_through -bool true<br />
<br />
;Free Pascal Compiler:<br />
Then download and install the Free Pascal Compiler (at least 1.9.5 from 16th August 2004) from<br />
: https://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
When compiling gtk-related software, you need to add two lines to the fpc.cfg file, to enable use of libraries<br />
-Fl/sw/lib<br />
-Fl/usr/X11R6/lib<br />
<br />
<br />
For lazarus you need the fpc sources as well (obsolete: use svn):<br />
Create a directory, where you would like to put the sources. You don't need to be root to do this. Any normal user can do this. <br />
First create a directory for fpc <br />
: (e.g. /Users/username/freepascal) <br />
then open a terminal and do the following:<br />
[]$ bash<br />
[]$ export CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
[]$ cvs login<br />
password is 'cvs' without the 'quotes'<br />
[]$ cvs -z3 co fpc<br />
This will create a directory called 'fpc', which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
[]$ cd /Users/username/freepascal/fpc<br />
[]$ cvs -z3 update -dP<br />
<br />
==Installing Lazarus==<br />
<br />
===Installing Lazarus under Linux===<br />
====Installing using rpms====<br />
The easiest way to get a current working installation of Lazarus is to download the RPMs for FreePascal and Lazarus from the SourceForge repository.<br />
<br />
You need to download the selected version of<br />
* the compiler (eg fpc-1.9.5-041207.i386.rpm)<br />
* the pascal source library (eg fpcsrc-1.9.5-041207.i386.rpm)<br />
* the Lazarus package (eg lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm).<br />
<br />
You then issue the following commands (you need to have root privileges - use su or sudo)<br />
rpm -Uvh fpc-1.9.5-041207.i386.rpm<br />
rpm -Uvh fpcsrc-1.9.5-041207.i386.rpm<br />
rpm -Uvh lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm<br />
<br />
====Installing from source====<br />
If you prefer to install from source and compile the files yourself, follow these instructions. Because the whole lazarus stuff is installed into one directory, uninstall is very easy and you don't need to be root to install lazarus. You can get tgz files for fpc, fpcsrc and lazarus from the downloads section or you can download it directly via svn.<br />
<br />
=====Downloading Lazarus SVN=====<br />
<br />
The lazarus repository has moved from cvs to svn (Subversion). SVN provides an easy way to update your sources by only downloading the changes. This is the recommended way and saves you a lot of time. A connection to the internet is needed for this: you don't need to be root. Lazarus does not need any special permissions, neither during installation nor at runtime.<br />
<br />
With the move we also changed the directory layout of the lazarus sources. The main difference<br />
is that all ide sources are moved from the root to a separate ide subdir. As anybody might understand, this has an impact on the Makefiles, the searchpaths etc. We are in progress of fixing things, so if something doesn't work, please let us know.<br />
<br />
;Now the most important thing.... getting the sources:<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk/ lazarus<br />
(or any other dir where you want to place your sources)<br />
<br />
On subsequent occasions, to update simply type<br />
<br />
[]$ svn update lazarus<br />
<br />
For more information on Subversion, see:<br />
http://subversion.tigris.org/<br />
<br />
Note: the CVS is still accessable, but it frozen. This means<br />
that no new updates are comitted.<br />
<br />
=====Compiling and running=====<br />
Whether you checkout from cvs or svn, the next step is: <br />
<br />
;compile lazarus:<br />
[]$ cd lazarus<br />
[]$ make (gmake on BSD)<br />
<br />
<br />
If fpc is installed correctly, the compilation should work without problems. If not, see FAQ.<br />
<br />
;Start lazarus<br />
[]$ ./lazarus<br />
<br />
The IDE should start. If you started lazarus in a terminal, you can see some notes about missing settings. This is normal at first start. The IDE automatically tries to find out where the freepascal compiler and its sources are installed by searching in the most common directories.<br />
<br />
;Check the paths:<br />
: Use the IDE menu to go to<br />
:: Environment -> Environment Options -> Files<br />
<br />
The 'FPC Source directory' should point to your fpc source directory. This directory normally ends with /fpc/ or /fpcsrc/ (e.g. /usr/src/fpcsrc or /home/username/freepascal/fpc) and contains directories like 'compiler', 'docs', 'fcl', 'rtl' and 'packages'.<br />
<br />
''ToDo: explain the other paths''<br />
<br />
;Hint:<br />
To update lazarus you can use<br />
[]$ svn update lazarus<br />
then for either update pathway:<br />
[]$ make clean all (gmake on BSD)<br />
This will rebuild lazarus and create an IDE without lazarus packages. To link your installed packages do '''after''' the above:<br />
[]$ make idepkg<br />
<br />
====Installing Lazarus under Debian GNU/Linux====<br />
<br />
There are preliminary Debian packages for lazarus available for download. Make sure you read /usr/share/doc/lazarus/README.Debian carefully before you start using it. Feedback is needed and appreciated; please send your comments to Carlos Laviola <claviola@debian.org>.<br />
<br />
====Another (?easier) way to install Lazarus under Debian====<br />
Added by [[User:Kirkpatc]].<br />
<br />
;Simple Lazarus Installation in Debian<br />
(assume new Debian installation, without development libraries loaded)<br />
<br />
From sourceforge repository, download latest fpc, fpclib and lazarus releases; follow links from http://lazarus.freepascal.org, click the "downloads" button on the left, then click on "binaries" then "linux" then "Current Lazarus RPM". This will bring you to <br />
: http://sourceforge.net/project/showfiles.php?group_id=89339<br />
then download the following files (or more recent, if available)<br />
* fpc-2.0.0-0.i586.rpm<br />
* fpcsrc-2.0.0-0.i386.rpm<br />
* lazarus-0.9.8-fpc_2.0.0_0.i386.rpm<br />
cd to the directory where these files are stored, then become root (su) and type:<br />
<br />
alien fpc* //this will convert both the fpc and fpcsrc files to debian format<br />
alien laz*<br />
then install the generated Debian (.deb) packages by (as root):<br />
<br />
dpkg -i fpc*.deb laz*.deb<br />
or use kpackage or a similar utility to install the generated fpc, fpcsrc and lazarus .deb files.<br />
<br />
Note, if you do not have alien type:<br />
<br />
apt-get install alien<br />
<br />
You need to produce a configuration file, which will reside in /etc/fpc.cfg. Still as root, cd to the main fpc directory /usr/lib/fpc/2.0.0 and then type<br />
sh ./samplecfg /usr/lib/fpc/2.0.0 /etc<br />
Check the contents of your new configuration file (cat /etc/fpc.cfg) and make any changes you want using vi or another text editor. Also make sure that there are no old configuration files in for example your home directory (~/.fpc.cfg).<br />
<br />
You need to install the development packages of the GTK and pixbuf libraries, so<br />
apt-get install libgtk2.0-dev<br />
apt-get install libgdk-pixbuf-dev<br />
Then you should be ready to start programming!<br />
<br />
===Installing Lazarus under Mac OS X===<br />
<br />
Works pretty much the same as under Linux. But you need to install first the apple developer tools and X11.<br />
<br />
Snapshots are available at http://www.de.freepascal.org/lazarus/.<br />
<br />
If you want to experiment and develop the carbon widgetset interface, look at [[Installing Carbon on OSX]].<br />
<br />
===Installing Lazarus under Windows===<br />
<br />
The current releases of the Windows Lazarus binary packages install very easily, and should work 'out-of-the-box'. <br />
<br />
It is even possible to install the whole Lazarus/FPC package on a portable USB drive (capacity at least 256 MB), for use in environments where you are not allowed to install software on your Windows workstation or where you haven't got administrator privileges. You do have to be a little careful about adjusting the paths in the compiler and environment options and the fpc.cfg file. It may also be necessary to keep the directory for test compilation on your portable drive. << DOES ANYONE KNOW HOW TO SET UP RELATIVE PATHS IN THESE TAGS AND FILES, SO THAT THE ADDRESSING WORKS WHEN YOU MOVE THE USB DEVICE TO ANOTHER MACHINE WHERE IT HAS A DIFFERENT DRIVE LETTER? >><br />
<br />
The binary package is available for Linux and Windows from<br />
<br />
http://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
Download the latest release (currently Lazarus-0.9.6-20050225-win32.exe) and launch the application. You will be taken through a typical Windows installation, in which the FPC compiler and source libraries are installed within the same directory structure as Lazarus, and the IDE should launch and operate without significant problems, provided you have uninstalled any previous version of Lazarus and/or FPC (often found in the C:\pp directory).<br />
<br />
You can also get a Lazarus Snapshot for Windows at: http://www.de.freepascal.org/lazarus/<br />
<br />
====Installing from source====<br />
If you prefer to install from sources, then follow these instructions (Thanks to Joe for the initial Step-by-step description)<br />
<br />
You have to download the lazarus source:<br />
: http://www.de.freepascal.org/lazarus/<br />
<br />
Then unzip it to c:\lazarus for example. You have to install at least fpc-2.0.0, but a fpc-2.0.1 or fpc 2.1.1 snapshot is also possible. It compiles for me, and lazarus.exe works. The path to my fpc is: c:\pp\bin\win32. In this directory you can find a lot of exe (make, grep, ppc386, and so on).<br />
<br />
Open a command line. Start->Run...>command or choose MS-DOS icon.<br />
<br />
Type:<br />
cd c:\lazarus<br />
set path=c:\pp\bin\win32;c:\lazarus //of course change the first to<br />
//the path of yours<br />
windres -i lazarus.rc -o lazarus.res<br />
make<br />
<br />
If you are lucky then you can type: lazarus.exe. The source editor, dialogs and the property editor work, but not perfectly... Look and you will see.<br />
<br />
You can compile examples also:<br />
<br />
cd examples<br />
make<br />
<br />
If you extracted lazarus to another drive, eg.: d:\lazarus. It can happen that you need the gnu utility to make it. If you have it, you can take its path to set path=...;<gmakepath> but it is simpler not to choose drive d:\<br />
<br />
That's all.<br />
<br />
=== Additional experiences and advice on installing FPC and Lazarus ===<br />
On linux, getting Lazarus to work can be complicated. If you have already installed earlier versions of FPC and/or Lazarus, you have to take great care that the PATHS are adjusted so that only your new versions are called.<br />
<br />
Pitfalls that I have experienced in various attempts with SuSE linux include:<br />
<br />
The rpm versions often install FPC in /bin or /usr/bin, with the libraries in /lib or /usr/lib.<br />
<br />
If you perform a make install on a source version or use a .tar.gz, the compiler is usually installed in /usr/local/bin with the libraries in /usr/local/lib.<br />
<br />
So if earlier versions have been installed from rpm, make sure all links are changed to reflect the directory structure of your new compiler. The place to make the changes is in /etc/fpc.cfg ; make sure there are no remnant configuration files in your home directory or in your FPC download directory. Typically they are found in ~/.fpc.cfg<br />
<br />
Make sure the links in /etc/fpc.cfg point to the correct versions of the libraries (particularly if you have older versions still lurking around).<br />
<br />
In /usr/local/bin or /usr/bin there is a file called fpc ; this is the executable that is called when you invoke the compiler. One of the first things it does is to open ppc386 in the same directory. This has to be the same version as the fpc file, or can be a link pointing to the true ppc386 in some other directory (such as a library directory, or the fpc directory in your own development space); be sure to update your link if you install a newer version of the compiler.<br />
<br />
Try running the compiler from the command line using one of the simple example programs or one which you wrote yourself.<br />
<br />
Turning to Lazarus:<br />
<br />
If you use a downloaded snapshot (.tar.gz) or get the source from CVS, enter your lazarus directory and type<br />
<br />
make<br />
./lazarus <br />
<br />
and hopefully the IDE should load. There may be a message saying it can't find the sources; if so, go to the menu at the top and select Environment -> Environment options and insert the name of the directory where you expect to find your lazarus files (eg ~/FreePascal/lazarus), your compiler (eg /usr/local/bin/ppc386), the FreePascal source directory (eg /usr/local/lib/fpc/$version/fpc or a directory in your own space eg ~/FreePascal/fpc). Then close the dialog and start programming.<br />
<br />
You may find further problems when you start programming or compiling; most of these will be related to PATH selection.<br />
<br />
Many of the difficulties are dealt with in the Lazarus FAQ, found either on this WiKi site, or a more complete list on the main Lazarus site<br />
<br />
http://www.lazarus.freepascal.org/modules.php?op=modload&name=FAQ&file=index<br />
<br />
From the top menu select Run -> Compiler Options (or Project -> Compiler Options in more recent releases of Lazarus) and select the Paths tab on the resulting dialog. There are several boxes for entry of paths for Unit files, Include files, Other source files, Libraries etc. For each of these, it is worth pressing the ... (ellipsis) button on the right, and you will be given a blank window for inserting path information, and a lower window giving some suggestions. Select as many as you like (or ALL!) and press the ADD button to transfer the selections to the upper window. When your selection is complete, press OK and move on to the next box. If you know of other paths which need to be followed, press the Browse button associated with each box, and insert the additional paths.<br />
<br />
When you think you have got your paths right, try to compile your application. If there are further path-related errors ('can't find unit .......') then go back and check your paths, both in /etc/fpc.cfg and in your Run -> Compiler Options dialog (or Project -> Compiler Options depending on your version).<br />
<br />
Once you have got the environment and PATHS correct, it is worth saving the settings to a file, otherwise you will have to go through this process for each new project. In the Run -> Compiler options dialog there is a Load/Save button; select this and then save the setings to the filename of your choice: mine is ~/FreePascal/default.cfg. Then each time I start a new project, I can go to the Run -> Compiler Options dialog (or Project -> Compiler Options), select Load/Save, and load my default.cfg file to the new project. You can, of course, modify the options for each new project if you so desire.<br />
<br />
===Installing Lazarus under BSD===<br />
<br />
Please write me!<br />
<br />
==Original contributors and changes==<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=InstallingLazarus version].<br />
* Initially imported and formatted. [[User:Tom | VlxAdmin]] 9/22/2003<br />
* Changed Joe's part for Windows to require fpc 1.0.10. [[User:Vincent | Vincent]] 9/25/2003<br />
* Updated "What is required for lazarus". AndrewJohnson 10/1/2003<br />
* Finished formatted the InstallingLazarus page [[User:Tom | VlxAdmin]] 2/22/2004<br />
* Posted some notes about Installing FPC and Lazarus: mostly reflecting experiences in trying to get the PATHS right in Linux. 3/11/2004 [[User:Kirkpatc]]<br />
* Copied the contents of my note into the main InstallingLazarus section, edited it slightly. I don't know how to remove the original note. 3/12/2004 [[User:Kirkpatc]]<br />
* Removed the original note. Tidied the wiki and formatting a bit. [[User:Tom | VlxAdmin]]<br />
* Corrected a couple of typos - 3/12/2004 [[User:Kirkpatc]]<br />
* Added link for daily snapshot deb packages - 3/27/2004 [[User:Vincent | Vincent]]<br />
* Fixed links in GettingLazarus (downloading binaries) and several other pages. 22 July 2004 [[User:Kirkpatc]]<br />
* Added link for lazarus deb packages - 19 August 2004 VincentSnijders<br />
* Added a short note on installing in Debian - 23 Nov 2004 [[User:Kirkpatc]]<br />
* Considerable re-write and re-organization of installation section - 11 Dec 2004 [[User:Kirkpatc]]<br />
* Fixed broken link - 9 Oct 2005 [[User:Avantman42]]</div>Fititnthttps://wiki.freepascal.org/index.php?title=Installing_Lazarus/pt&diff=3798Installing Lazarus/pt2005-11-20T18:43:46Z<p>Fititnt: </p>
<hr />
<div>{{Installing Lazarus}}<br />
<br />
==Overview==<br />
Para pessoas que simplesmente querem instalar Lazarus e começar a usá-lo para programar, a maneira mais fácil é instalar uma versão recente, razoavelmente estável, de um binário (como um pacote linux ". rpm" ou um Windows ". exe"). Você pode ler as seções abaixo de linux ou Windows intitulado "binários de fpc" ou os primeiros parágrafos nas seções em instalar Lazarus em linux ou Windows; a maioria da informação restantes podem ser ignoradas seguramente. <br />
<br />
Para os que querem participar no desenvolvimento do compilador ou da IDE, ou para quem quer ter as ferramentas com atualizações em dia, uma instalação de arquivos de fonte é necessária, e muito do resto desta informação é pertinente. <br />
Lazarus provê duas partes principais: <br />
<br />
<br />
Lazarus provê duas partes principais: <br />
* LCL - Biblioteca de Componentes do Lazarus ( Lazarus Component Library ) <br />
* IDE - ferramenta de RAD <br />
<br />
Estes são em troca dependentes de <br />
* FPC - o compilador de freePascal ( freePascal compiler ) <br />
* FCL - a Biblioteca de Componentes FreePascal Componente biblioteca (FreePascal Component Library ), contendo a maioria dos componentes de não-gráficos usado pelo Lazarus.<br />
<br />
===Lazarus System Requirements===<br />
<br />
# FreePascal compiler, packages, and sources. (*important*: of the same version/date)<br />
# A supported Widget tool-kit<br />
#:;Win32: : The native Win32 API can be used<br />
#:;Linux/xxxBSD: GTK+ 1.2.x : Most Linux distributions and *BSDs already install the GTK+ 1.2.x libraries. You can also find them at http://www.gtk.org. <br> You'll also want gdk-pixbuf, 0.13 or newer (preferably 0.18 or newer), which is also found in most recent distributions from the past 2 years. The source is available from ftp://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/<br />
#:;Mac OS X: GTK+ 1.2.x : You need the apple developer tools, X11 and GTK1.2. See below Installing under Mac OS X.<br />
#:;GTK+ 2.x: WARNING : The GTK2 interface is not yet complete and is only for testing purposes. <br> It's found in most recent distributions. For the source see http://www.gtk.org.<br />
<br />
The FAQ - Frequently Asked Questions file is available at http://www.lazarus.freepascal.org . Some of the questions can be found in the local file 'FAQ'.<br />
<br />
The following sections will describe how to get FreePascal and how to install lazarus properly.<br />
<br />
==Installing The Free Pascal Compiler==<br />
<br />
There is an extensive discussion of how to install and build Free Pascal compilers available here http://www.stack.nl/~marcov/buildfaq.pdf - it may be a little too detailed for some users, but is very comprehensive.<br />
<br />
Lazarus requires fpc (FreePascal) version 1.9.x and it requires both the compiled fpc libs (binaries) and the fpc sources and of the same version. fpc 1.0.6 is too buggy and fpc 1.0.10 has problems opening forms created with fpc 1.9.x. FreePascal version 2.0.0 has now been released, and is the preferred compiler (fpc-2.0.0).<br />
<br />
===Installing Free Pascal under Linux===<br />
<br />
====FPC Binaries====<br />
<br />
The latest release of FreePascal, version 2.0.1, can be obtained from the FreePascal website (http://www.freepascal.org/download.html, then choose a mirror) or from sourceforge (http://sourceforge.net/projects/lazarus). <br />
<br />
At the lazarus downloads section (http://www.lazarus.freepascal.org ) you can get the RPM of the Free Pascal compiler (compiler / linux) and its packages. If you don't have an RPM-based distribution, you can download and install the tarballs from http://www.freepascal.org. If you want to compile the binaries for yourself, see the BSD section.<br />
<br />
Instructions: <br />
<br />
Download lastest files from http://sourceforge.net/project/showfiles.php?group_id=89339.<br />
As example:<br />
:* fpc-2.0.1-050923.i386.rpm<br />
:* fpcsrc-2.0.1-050923.i386.rpm<br />
:* lazarus-0.9.10-0.i386.rpm<br><br />
and install them with:<br />
:* rpm -Uvh fpc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh fpcsrc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh lazarus-0.9.10-0.i386.rpm<br><br />
<br />
Daily snapshot Debian packages can be downloaded from http://cYcnus.de/deb/. At present this contains only the compiled fpc components, but not the sources, which would be needed for most Lazarus programming.<br />
<br />
====FPC Sources====<br />
<br />
Together with the release of version 2.0, FPC no longer uses CVS, but has migrated to Subversion (SVN). For now, there is no CVS mirror yet, so you have to use SVN to get the FPC sources.<br />
<br />
===== Download Daily Source Snapshot of Development Tree (version 2.1.x) =====<br />
You can download today's development (v 2.1.x) sources in the form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.1.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v21/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
===== Download Daily Source Snapshot of Release Tree (version 2.0.x) =====<br />
You can download today's development (v 2.0.x) sources that will lead to the next stable release in form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.0.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v20/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
<br />
===== Connect to Source Repository with SVN (replaces section on connection to CVS) =====<br />
As an alternative to the daily zip files of the SVN sources, the SVN repository has been made accessible for everyone, with read-only access. This means that you can directly access the code, and you will have really the last-minute sources available. It is also a method which requires less bandwidth once you have done the first download (checkout in SVN lingo).<br />
===== Development snapshots =====<br />
How to do this? <br />
(You need to have SVN installed, of course. Look [http://subversion.tigris.org/ here] for instructions on how to do that.)<br />
<br />
Change Directory (cd) to the parent directory of your development area, eg <br />
<br />
[]$ cd /home/username/FreePascal<br />
<br />
To retrieve the full source repository, all publicly available modules, type<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc<br />
<br />
Normally, you should perform this step just once.<br />
<br />
To update the sources which were downloaded (checkout) above<br />
<br />
[]$svn update fpc<br />
<br />
<br />
===== Fixes to 2.0.x =====<br />
<br />
The fixes need a separate directory, create a separate directory 'fixes', enter it, and repeat the above checkout command with the URL http://svn.freepascal.org/svn/fpc/branches/fixes_2_0:<br />
<br />
[]$ cd mysvn/fixes<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_0 fpc<br />
<br />
and to update:<br />
<br />
[]$ svn update fpc<br />
<br />
The sources of docs are in a separate repository called fpcdocs, so the command to get them is<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs<br />
<br />
If you want to learn more about subversion, read this excellent [http://svnbook.red-bean.com/ Subversion book] which is also available online in different formats for free.<br />
<br />
For the curious: You have only read-only access, so don't try to commit anything :-)<br />
<br />
For more information, see the [http://www.freepascal.org/develop.html FreePascal] website<br />
<br />
===Installing Free Pascal under Windows===<br />
<br />
====FPC Binaries for Windows====<br />
<br />
By far the easiest way to get a working installation of Free Pascal is to download the current binary Windows release of Lazarus from the SourceForge repository - the release contains the current versions of the FreePascal compiler and the FreePascal libraries as well as the lazarus IDE. If you want to install from sources, read on!<br />
<br />
You can get the installer zip for fpc 2.0.0 at Free Pascal's download section http://www.freepascal.org/download.html, then choose a mirror). <br />
Installing from the sources -- see the next section to know how to get them -- is not for novices, since you need a starting compiler as well.<br />
<br />
====FPC Sources for Windows====<br />
<<<< See section above under [[#FPC Sources|FPC Sources]] for Linux, where the use of SVN is described >>>><br />
<br />
The easiest way to get the Free Pascal sources is via CVS; see the next section for more on that. You can also download the package as a whole -- see http://www.freepascal.org/develop.html for the daily snapshot of the 2.1.x release tree.<br />
<br />
Windows FPC Sources via CVS ()<br />
<br />
You will need to have a CVS client such as TortoiseCVS or WinCVS installed in order to perform the steps below. The exact commands vary between CVS clients; the ones given below are to be used under CVS home's client, which is available for download here.<br />
<br />
First create a directory in which you'd like to put the sources. Any normal user can do this. Create a directory for fpc (e.g. C:\Source), then do the following at the command prompt:<br />
C:\Source> set CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
C:\Source> cvs login // password is 'cvs' without the commas<br />
C:\source> cvs -z3 co fpc // This will create a directory fpc, which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
C:\> cd Source\FPC<br />
C:\Source\FPC> cvs -z3 update -dP<br />
''ToDo: Write me.''<br />
<br />
See: http://www.freepascal.org/down-win32.html . You can find a list of mirrors at http://www.freepascal.org/sdown.html. Download FPC as one big file, unzip it and run the install.exe. <br />
<br />
Extending your PATH variable to the fpc directory:<br />
<br />
* Win98: Edit autoexec.bat and add the line: PATH=%PATH%;C:\pp\bin\bin\win32<br />
* WinXP/2k: My Computer (Right Click) -> Properties -> Advanced (Page) -> Enviroment Variables -> System Variables -> Edit "PATH", Add "C:\pp\bin\bin\win32" there.<br />
<br />
Then restart windows.<br />
<br />
''ToDo: Explain how to download fpc sources and build the compiler''<br />
<br />
===Installing Free Pascal under BSD/manually===<br />
<br />
Effectively, you need<br />
<br />
A file with all sources, or two (fpc and lazarus)<br />
<br />
1. e.g. for fpc ftp://ftp.freepascal.org/fpc/dist/Linux/separate/sources.tar preferably an export (no CVS/ dirs). The above file misses this.<br />
2. Lazarus source snapshot.<br />
* _any_ starting compiler from the 1.9 branch) You can do a check by parsing the output of ppc386 -i if it is 1.9.3 .. 2.0.x it is ok.<br />
* - dependant packages. (for FreeBSD that is gtk12, glib12 and gdk_pixbuf and GNU make, iconv and gettext)<br />
<br />
FPC build:<br />
<br />
1. (fetch) necessary files (FPC source, starting compiler)<br />
2. (extract) Then de-tgz in work directory,<br />
3. (build) enter work/fpc/ and run<br />
<br />
$MAKE all OPT='-gl -O3p3' PP=/path/to/startingcompiler-name-ppc386<br />
(/path/to/ can be omitted when ppc386 is in the path)<br />
($MAKE is make on linux and gmake on BSD)<br />
<br />
4. (install) then, again in work/fpc, run<br />
<br />
$MAKE install PP=compiler/ppc386 PREFIX=$THEPREFIX<br />
(THEPREFIX= usually is /usr/lcoal, but e.g. on NetBSD it is /usr/pkg for ports)<br />
Create a symlink:<br />
ln -s $THEPREFIX/lib/fpc/2.0.1/ppc386 $THEPREFIX/bin/ppc386<br />
install sourceinstall PREFIX=$THEPREFIX<br />
<br />
5. (configure) run compiler/utils/samplecfg $THEPREFIX/lib/fpc/2.0.1 $ETCDIR<br />
6. (optional, test), see if ppc386 -i gives output, else give a warning that user need to add $PREFIX/bin to his current path. Try to compiler a program with -viwn, and see if that gives errors.<br />
Notes:<br />
<br />
* If you need fpcmake package lists, you need to generate or supply them yourself, (in the port, or in an extra archive) either way, do a dummy install to /tmp/pack and determine the files installed with find . >ll<br />
<br />
* $THEPREFIX and $ETCDIR should be user configurable. Otherwise local installs aren't possible.<br />
<br />
* BSDHIER=1 on all make commands forces BSD hierarchy conventions.<br />
<br />
===Installing Free Pascal under Mac OS X===<br />
<br />
You need the Apple Developer-tools, X11, gtk1.2:<br />
<br />
Downloading packages and installing them properly can be a time consuming task. Therefore there are various package managers. One of them is fink:<br />
: Download fink from http://fink.sourceforge.net/download/index.php?phpLang=en; follow the install instructions.<br />
<br />
Developer-tools: Are included on the original OSX installation-CDs, or download at ADC (free registration required)<br />
: http://developer.apple.com/.<br />
<br />
Apple X11: On a fresh system: choose "Customize" in the install-dialogue, check "X11".<br />
<br />
On an already installed system: download at<br />
: http://www.apple.com/downloads/macosx/apple/x11formacosx.html<br />
<br />
In the Terminal, run<br />
sudo fink install gdk-pixbuf gtk+ gtk+-data gtk+-shlibs gtk-doc gtkglarea gtk-engines<br />
The X11-Application is in /Applications/Utilities/X11.<br />
<br />
Hint: Most X11 programs, including lazarus expect to receive focus, when the users clicks on a window. Under MacOSX this is deactivated. You can activate it for all X11 applications by typing in the terminal:<br />
defaults write com.apple.x11 wm_click_through -bool true<br />
<br />
;Free Pascal Compiler:<br />
Then download and install the Free Pascal Compiler (at least 1.9.5 from 16th August 2004) from<br />
: https://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
When compiling gtk-related software, you need to add two lines to the fpc.cfg file, to enable use of libraries<br />
-Fl/sw/lib<br />
-Fl/usr/X11R6/lib<br />
<br />
<br />
For lazarus you need the fpc sources as well (obsolete: use svn):<br />
Create a directory, where you would like to put the sources. You don't need to be root to do this. Any normal user can do this. <br />
First create a directory for fpc <br />
: (e.g. /Users/username/freepascal) <br />
then open a terminal and do the following:<br />
[]$ bash<br />
[]$ export CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
[]$ cvs login<br />
password is 'cvs' without the 'quotes'<br />
[]$ cvs -z3 co fpc<br />
This will create a directory called 'fpc', which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
[]$ cd /Users/username/freepascal/fpc<br />
[]$ cvs -z3 update -dP<br />
<br />
==Installing Lazarus==<br />
<br />
===Installing Lazarus under Linux===<br />
====Installing using rpms====<br />
The easiest way to get a current working installation of Lazarus is to download the RPMs for FreePascal and Lazarus from the SourceForge repository.<br />
<br />
You need to download the selected version of<br />
* the compiler (eg fpc-1.9.5-041207.i386.rpm)<br />
* the pascal source library (eg fpcsrc-1.9.5-041207.i386.rpm)<br />
* the Lazarus package (eg lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm).<br />
<br />
You then issue the following commands (you need to have root privileges - use su or sudo)<br />
rpm -Uvh fpc-1.9.5-041207.i386.rpm<br />
rpm -Uvh fpcsrc-1.9.5-041207.i386.rpm<br />
rpm -Uvh lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm<br />
<br />
====Installing from source====<br />
If you prefer to install from source and compile the files yourself, follow these instructions. Because the whole lazarus stuff is installed into one directory, uninstall is very easy and you don't need to be root to install lazarus. You can get tgz files for fpc, fpcsrc and lazarus from the downloads section or you can download it directly via svn.<br />
<br />
=====Downloading Lazarus SVN=====<br />
<br />
The lazarus repository has moved from cvs to svn (Subversion). SVN provides an easy way to update your sources by only downloading the changes. This is the recommended way and saves you a lot of time. A connection to the internet is needed for this: you don't need to be root. Lazarus does not need any special permissions, neither during installation nor at runtime.<br />
<br />
With the move we also changed the directory layout of the lazarus sources. The main difference<br />
is that all ide sources are moved from the root to a separate ide subdir. As anybody might understand, this has an impact on the Makefiles, the searchpaths etc. We are in progress of fixing things, so if something doesn't work, please let us know.<br />
<br />
;Now the most important thing.... getting the sources:<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk/ lazarus<br />
(or any other dir where you want to place your sources)<br />
<br />
On subsequent occasions, to update simply type<br />
<br />
[]$ svn update lazarus<br />
<br />
For more information on Subversion, see:<br />
http://subversion.tigris.org/<br />
<br />
Note: the CVS is still accessable, but it frozen. This means<br />
that no new updates are comitted.<br />
<br />
=====Compiling and running=====<br />
Whether you checkout from cvs or svn, the next step is: <br />
<br />
;compile lazarus:<br />
[]$ cd lazarus<br />
[]$ make (gmake on BSD)<br />
<br />
<br />
If fpc is installed correctly, the compilation should work without problems. If not, see FAQ.<br />
<br />
;Start lazarus<br />
[]$ ./lazarus<br />
<br />
The IDE should start. If you started lazarus in a terminal, you can see some notes about missing settings. This is normal at first start. The IDE automatically tries to find out where the freepascal compiler and its sources are installed by searching in the most common directories.<br />
<br />
;Check the paths:<br />
: Use the IDE menu to go to<br />
:: Environment -> Environment Options -> Files<br />
<br />
The 'FPC Source directory' should point to your fpc source directory. This directory normally ends with /fpc/ or /fpcsrc/ (e.g. /usr/src/fpcsrc or /home/username/freepascal/fpc) and contains directories like 'compiler', 'docs', 'fcl', 'rtl' and 'packages'.<br />
<br />
''ToDo: explain the other paths''<br />
<br />
;Hint:<br />
To update lazarus you can use<br />
[]$ svn update lazarus<br />
then for either update pathway:<br />
[]$ make clean all (gmake on BSD)<br />
This will rebuild lazarus and create an IDE without lazarus packages. To link your installed packages do '''after''' the above:<br />
[]$ make idepkg<br />
<br />
====Installing Lazarus under Debian GNU/Linux====<br />
<br />
There are preliminary Debian packages for lazarus available for download. Make sure you read /usr/share/doc/lazarus/README.Debian carefully before you start using it. Feedback is needed and appreciated; please send your comments to Carlos Laviola <claviola@debian.org>.<br />
<br />
====Another (?easier) way to install Lazarus under Debian====<br />
Added by [[User:Kirkpatc]].<br />
<br />
;Simple Lazarus Installation in Debian<br />
(assume new Debian installation, without development libraries loaded)<br />
<br />
From sourceforge repository, download latest fpc, fpclib and lazarus releases; follow links from http://lazarus.freepascal.org, click the "downloads" button on the left, then click on "binaries" then "linux" then "Current Lazarus RPM". This will bring you to <br />
: http://sourceforge.net/project/showfiles.php?group_id=89339<br />
then download the following files (or more recent, if available)<br />
* fpc-2.0.0-0.i586.rpm<br />
* fpcsrc-2.0.0-0.i386.rpm<br />
* lazarus-0.9.8-fpc_2.0.0_0.i386.rpm<br />
cd to the directory where these files are stored, then become root (su) and type:<br />
<br />
alien fpc* //this will convert both the fpc and fpcsrc files to debian format<br />
alien laz*<br />
then install the generated Debian (.deb) packages by (as root):<br />
<br />
dpkg -i fpc*.deb laz*.deb<br />
or use kpackage or a similar utility to install the generated fpc, fpcsrc and lazarus .deb files.<br />
<br />
Note, if you do not have alien type:<br />
<br />
apt-get install alien<br />
<br />
You need to produce a configuration file, which will reside in /etc/fpc.cfg. Still as root, cd to the main fpc directory /usr/lib/fpc/2.0.0 and then type<br />
sh ./samplecfg /usr/lib/fpc/2.0.0 /etc<br />
Check the contents of your new configuration file (cat /etc/fpc.cfg) and make any changes you want using vi or another text editor. Also make sure that there are no old configuration files in for example your home directory (~/.fpc.cfg).<br />
<br />
You need to install the development packages of the GTK and pixbuf libraries, so<br />
apt-get install libgtk2.0-dev<br />
apt-get install libgdk-pixbuf-dev<br />
Then you should be ready to start programming!<br />
<br />
===Installing Lazarus under Mac OS X===<br />
<br />
Works pretty much the same as under Linux. But you need to install first the apple developer tools and X11.<br />
<br />
Snapshots are available at http://www.de.freepascal.org/lazarus/.<br />
<br />
If you want to experiment and develop the carbon widgetset interface, look at [[Installing Carbon on OSX]].<br />
<br />
===Installing Lazarus under Windows===<br />
<br />
The current releases of the Windows Lazarus binary packages install very easily, and should work 'out-of-the-box'. <br />
<br />
It is even possible to install the whole Lazarus/FPC package on a portable USB drive (capacity at least 256 MB), for use in environments where you are not allowed to install software on your Windows workstation or where you haven't got administrator privileges. You do have to be a little careful about adjusting the paths in the compiler and environment options and the fpc.cfg file. It may also be necessary to keep the directory for test compilation on your portable drive. << DOES ANYONE KNOW HOW TO SET UP RELATIVE PATHS IN THESE TAGS AND FILES, SO THAT THE ADDRESSING WORKS WHEN YOU MOVE THE USB DEVICE TO ANOTHER MACHINE WHERE IT HAS A DIFFERENT DRIVE LETTER? >><br />
<br />
The binary package is available for Linux and Windows from<br />
<br />
http://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
Download the latest release (currently Lazarus-0.9.6-20050225-win32.exe) and launch the application. You will be taken through a typical Windows installation, in which the FPC compiler and source libraries are installed within the same directory structure as Lazarus, and the IDE should launch and operate without significant problems, provided you have uninstalled any previous version of Lazarus and/or FPC (often found in the C:\pp directory).<br />
<br />
You can also get a Lazarus Snapshot for Windows at: http://www.de.freepascal.org/lazarus/<br />
<br />
====Installing from source====<br />
If you prefer to install from sources, then follow these instructions (Thanks to Joe for the initial Step-by-step description)<br />
<br />
You have to download the lazarus source:<br />
: http://www.de.freepascal.org/lazarus/<br />
<br />
Then unzip it to c:\lazarus for example. You have to install at least fpc-2.0.0, but a fpc-2.0.1 or fpc 2.1.1 snapshot is also possible. It compiles for me, and lazarus.exe works. The path to my fpc is: c:\pp\bin\win32. In this directory you can find a lot of exe (make, grep, ppc386, and so on).<br />
<br />
Open a command line. Start->Run...>command or choose MS-DOS icon.<br />
<br />
Type:<br />
cd c:\lazarus<br />
set path=c:\pp\bin\win32;c:\lazarus //of course change the first to<br />
//the path of yours<br />
windres -i lazarus.rc -o lazarus.res<br />
make<br />
<br />
If you are lucky then you can type: lazarus.exe. The source editor, dialogs and the property editor work, but not perfectly... Look and you will see.<br />
<br />
You can compile examples also:<br />
<br />
cd examples<br />
make<br />
<br />
If you extracted lazarus to another drive, eg.: d:\lazarus. It can happen that you need the gnu utility to make it. If you have it, you can take its path to set path=...;<gmakepath> but it is simpler not to choose drive d:\<br />
<br />
That's all.<br />
<br />
=== Additional experiences and advice on installing FPC and Lazarus ===<br />
On linux, getting Lazarus to work can be complicated. If you have already installed earlier versions of FPC and/or Lazarus, you have to take great care that the PATHS are adjusted so that only your new versions are called.<br />
<br />
Pitfalls that I have experienced in various attempts with SuSE linux include:<br />
<br />
The rpm versions often install FPC in /bin or /usr/bin, with the libraries in /lib or /usr/lib.<br />
<br />
If you perform a make install on a source version or use a .tar.gz, the compiler is usually installed in /usr/local/bin with the libraries in /usr/local/lib.<br />
<br />
So if earlier versions have been installed from rpm, make sure all links are changed to reflect the directory structure of your new compiler. The place to make the changes is in /etc/fpc.cfg ; make sure there are no remnant configuration files in your home directory or in your FPC download directory. Typically they are found in ~/.fpc.cfg<br />
<br />
Make sure the links in /etc/fpc.cfg point to the correct versions of the libraries (particularly if you have older versions still lurking around).<br />
<br />
In /usr/local/bin or /usr/bin there is a file called fpc ; this is the executable that is called when you invoke the compiler. One of the first things it does is to open ppc386 in the same directory. This has to be the same version as the fpc file, or can be a link pointing to the true ppc386 in some other directory (such as a library directory, or the fpc directory in your own development space); be sure to update your link if you install a newer version of the compiler.<br />
<br />
Try running the compiler from the command line using one of the simple example programs or one which you wrote yourself.<br />
<br />
Turning to Lazarus:<br />
<br />
If you use a downloaded snapshot (.tar.gz) or get the source from CVS, enter your lazarus directory and type<br />
<br />
make<br />
./lazarus <br />
<br />
and hopefully the IDE should load. There may be a message saying it can't find the sources; if so, go to the menu at the top and select Environment -> Environment options and insert the name of the directory where you expect to find your lazarus files (eg ~/FreePascal/lazarus), your compiler (eg /usr/local/bin/ppc386), the FreePascal source directory (eg /usr/local/lib/fpc/$version/fpc or a directory in your own space eg ~/FreePascal/fpc). Then close the dialog and start programming.<br />
<br />
You may find further problems when you start programming or compiling; most of these will be related to PATH selection.<br />
<br />
Many of the difficulties are dealt with in the Lazarus FAQ, found either on this WiKi site, or a more complete list on the main Lazarus site<br />
<br />
http://www.lazarus.freepascal.org/modules.php?op=modload&name=FAQ&file=index<br />
<br />
From the top menu select Run -> Compiler Options (or Project -> Compiler Options in more recent releases of Lazarus) and select the Paths tab on the resulting dialog. There are several boxes for entry of paths for Unit files, Include files, Other source files, Libraries etc. For each of these, it is worth pressing the ... (ellipsis) button on the right, and you will be given a blank window for inserting path information, and a lower window giving some suggestions. Select as many as you like (or ALL!) and press the ADD button to transfer the selections to the upper window. When your selection is complete, press OK and move on to the next box. If you know of other paths which need to be followed, press the Browse button associated with each box, and insert the additional paths.<br />
<br />
When you think you have got your paths right, try to compile your application. If there are further path-related errors ('can't find unit .......') then go back and check your paths, both in /etc/fpc.cfg and in your Run -> Compiler Options dialog (or Project -> Compiler Options depending on your version).<br />
<br />
Once you have got the environment and PATHS correct, it is worth saving the settings to a file, otherwise you will have to go through this process for each new project. In the Run -> Compiler options dialog there is a Load/Save button; select this and then save the setings to the filename of your choice: mine is ~/FreePascal/default.cfg. Then each time I start a new project, I can go to the Run -> Compiler Options dialog (or Project -> Compiler Options), select Load/Save, and load my default.cfg file to the new project. You can, of course, modify the options for each new project if you so desire.<br />
<br />
===Installing Lazarus under BSD===<br />
<br />
Please write me!<br />
<br />
==Original contributors and changes==<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=InstallingLazarus version].<br />
* Initially imported and formatted. [[User:Tom | VlxAdmin]] 9/22/2003<br />
* Changed Joe's part for Windows to require fpc 1.0.10. [[User:Vincent | Vincent]] 9/25/2003<br />
* Updated "What is required for lazarus". AndrewJohnson 10/1/2003<br />
* Finished formatted the InstallingLazarus page [[User:Tom | VlxAdmin]] 2/22/2004<br />
* Posted some notes about Installing FPC and Lazarus: mostly reflecting experiences in trying to get the PATHS right in Linux. 3/11/2004 [[User:Kirkpatc]]<br />
* Copied the contents of my note into the main InstallingLazarus section, edited it slightly. I don't know how to remove the original note. 3/12/2004 [[User:Kirkpatc]]<br />
* Removed the original note. Tidied the wiki and formatting a bit. [[User:Tom | VlxAdmin]]<br />
* Corrected a couple of typos - 3/12/2004 [[User:Kirkpatc]]<br />
* Added link for daily snapshot deb packages - 3/27/2004 [[User:Vincent | Vincent]]<br />
* Fixed links in GettingLazarus (downloading binaries) and several other pages. 22 July 2004 [[User:Kirkpatc]]<br />
* Added link for lazarus deb packages - 19 August 2004 VincentSnijders<br />
* Added a short note on installing in Debian - 23 Nov 2004 [[User:Kirkpatc]]<br />
* Considerable re-write and re-organization of installation section - 11 Dec 2004 [[User:Kirkpatc]]<br />
* Fixed broken link - 9 Oct 2005 [[User:Avantman42]]</div>Fititnthttps://wiki.freepascal.org/index.php?title=Installing_Lazarus/pt&diff=3797Installing Lazarus/pt2005-11-20T18:16:06Z<p>Fititnt: </p>
<hr />
<div>{{Installing Lazarus}}<br />
<br />
==Overview==<br />
Para pessoas que simplesmente querem instalar Lazarus e começar a usá-lo para programar, a maneira mais fásil é instalar uma versão recente, razoavelmente estável, de um binário (como um pacote linux ". rpm" ou um Windows ". exe"). Você pode ler as seções abaixo de linux ou Windons intitulado "binaririos de fpc" ou os primeiros parágrafos nas seções em instalar Lazarus em linux ou Windows; a maioria da informação restantes podem ser ignoradas seguramente.<br />
<br />
For those who want to participate in the development of the compiler or the IDE, or for those who want the most up-to-date tools, an installation from source files is necessary, and much of the rest of this information is relevant.<br />
<br />
Lazarus provides two main parts:<br />
* LCL - the Lazarus Component Library<br />
* IDE - the RAD tool<br />
<br />
These in turn are dependent on<br />
* FPC - the freePascal compiler<br />
* FCL - the FreePascal Component library, containing most of the non-graphic components used by Lazarus<br />
<br />
===Lazarus System Requirements===<br />
<br />
# FreePascal compiler, packages, and sources. (*important*: of the same version/date)<br />
# A supported Widget tool-kit<br />
#:;Win32: : The native Win32 API can be used<br />
#:;Linux/xxxBSD: GTK+ 1.2.x : Most Linux distributions and *BSDs already install the GTK+ 1.2.x libraries. You can also find them at http://www.gtk.org. <br> You'll also want gdk-pixbuf, 0.13 or newer (preferably 0.18 or newer), which is also found in most recent distributions from the past 2 years. The source is available from ftp://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/<br />
#:;Mac OS X: GTK+ 1.2.x : You need the apple developer tools, X11 and GTK1.2. See below Installing under Mac OS X.<br />
#:;GTK+ 2.x: WARNING : The GTK2 interface is not yet complete and is only for testing purposes. <br> It's found in most recent distributions. For the source see http://www.gtk.org.<br />
<br />
The FAQ - Frequently Asked Questions file is available at http://www.lazarus.freepascal.org . Some of the questions can be found in the local file 'FAQ'.<br />
<br />
The following sections will describe how to get FreePascal and how to install lazarus properly.<br />
<br />
==Installing The Free Pascal Compiler==<br />
<br />
There is an extensive discussion of how to install and build Free Pascal compilers available here http://www.stack.nl/~marcov/buildfaq.pdf - it may be a little too detailed for some users, but is very comprehensive.<br />
<br />
Lazarus requires fpc (FreePascal) version 1.9.x and it requires both the compiled fpc libs (binaries) and the fpc sources and of the same version. fpc 1.0.6 is too buggy and fpc 1.0.10 has problems opening forms created with fpc 1.9.x. FreePascal version 2.0.0 has now been released, and is the preferred compiler (fpc-2.0.0).<br />
<br />
===Installing Free Pascal under Linux===<br />
<br />
====FPC Binaries====<br />
<br />
The latest release of FreePascal, version 2.0.1, can be obtained from the FreePascal website (http://www.freepascal.org/download.html, then choose a mirror) or from sourceforge (http://sourceforge.net/projects/lazarus). <br />
<br />
At the lazarus downloads section (http://www.lazarus.freepascal.org ) you can get the RPM of the Free Pascal compiler (compiler / linux) and its packages. If you don't have an RPM-based distribution, you can download and install the tarballs from http://www.freepascal.org. If you want to compile the binaries for yourself, see the BSD section.<br />
<br />
Instructions: <br />
<br />
Download lastest files from http://sourceforge.net/project/showfiles.php?group_id=89339.<br />
As example:<br />
:* fpc-2.0.1-050923.i386.rpm<br />
:* fpcsrc-2.0.1-050923.i386.rpm<br />
:* lazarus-0.9.10-0.i386.rpm<br><br />
and install them with:<br />
:* rpm -Uvh fpc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh fpcsrc-2.0.1-050923.i386.rpm<br />
:* rpm -Uvh lazarus-0.9.10-0.i386.rpm<br><br />
<br />
Daily snapshot Debian packages can be downloaded from http://cYcnus.de/deb/. At present this contains only the compiled fpc components, but not the sources, which would be needed for most Lazarus programming.<br />
<br />
====FPC Sources====<br />
<br />
Together with the release of version 2.0, FPC no longer uses CVS, but has migrated to Subversion (SVN). For now, there is no CVS mirror yet, so you have to use SVN to get the FPC sources.<br />
<br />
===== Download Daily Source Snapshot of Development Tree (version 2.1.x) =====<br />
You can download today's development (v 2.1.x) sources in the form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.1.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v21/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
===== Download Daily Source Snapshot of Release Tree (version 2.0.x) =====<br />
You can download today's development (v 2.0.x) sources that will lead to the next stable release in form of a packed snapshot from the SVN source repository: these snapshots are updated on a daily basis, and reflect the state of the source repository. The files are kept at the site which has the SVN archive.<br />
Entire public sources archive of v2.0.x: [ftp://ftp.freepascal.org/pub/fpc/snapshot/v20/source/fpc.zip fpc.zip] (24 MB)<br />
<br />
<br />
===== Connect to Source Repository with SVN (replaces section on connection to CVS) =====<br />
As an alternative to the daily zip files of the SVN sources, the SVN repository has been made accessible for everyone, with read-only access. This means that you can directly access the code, and you will have really the last-minute sources available. It is also a method which requires less bandwidth once you have done the first download (checkout in SVN lingo).<br />
===== Development snapshots =====<br />
How to do this? <br />
(You need to have SVN installed, of course. Look [http://subversion.tigris.org/ here] for instructions on how to do that.)<br />
<br />
Change Directory (cd) to the parent directory of your development area, eg <br />
<br />
[]$ cd /home/username/FreePascal<br />
<br />
To retrieve the full source repository, all publicly available modules, type<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc<br />
<br />
Normally, you should perform this step just once.<br />
<br />
To update the sources which were downloaded (checkout) above<br />
<br />
[]$svn update fpc<br />
<br />
<br />
===== Fixes to 2.0.x =====<br />
<br />
The fixes need a separate directory, create a separate directory 'fixes', enter it, and repeat the above checkout command with the URL http://svn.freepascal.org/svn/fpc/branches/fixes_2_0:<br />
<br />
[]$ cd mysvn/fixes<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpc/branches/fixes_2_0 fpc<br />
<br />
and to update:<br />
<br />
[]$ svn update fpc<br />
<br />
The sources of docs are in a separate repository called fpcdocs, so the command to get them is<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs<br />
<br />
If you want to learn more about subversion, read this excellent [http://svnbook.red-bean.com/ Subversion book] which is also available online in different formats for free.<br />
<br />
For the curious: You have only read-only access, so don't try to commit anything :-)<br />
<br />
For more information, see the [http://www.freepascal.org/develop.html FreePascal] website<br />
<br />
===Installing Free Pascal under Windows===<br />
<br />
====FPC Binaries for Windows====<br />
<br />
By far the easiest way to get a working installation of Free Pascal is to download the current binary Windows release of Lazarus from the SourceForge repository - the release contains the current versions of the FreePascal compiler and the FreePascal libraries as well as the lazarus IDE. If you want to install from sources, read on!<br />
<br />
You can get the installer zip for fpc 2.0.0 at Free Pascal's download section http://www.freepascal.org/download.html, then choose a mirror). <br />
Installing from the sources -- see the next section to know how to get them -- is not for novices, since you need a starting compiler as well.<br />
<br />
====FPC Sources for Windows====<br />
<<<< See section above under [[#FPC Sources|FPC Sources]] for Linux, where the use of SVN is described >>>><br />
<br />
The easiest way to get the Free Pascal sources is via CVS; see the next section for more on that. You can also download the package as a whole -- see http://www.freepascal.org/develop.html for the daily snapshot of the 2.1.x release tree.<br />
<br />
Windows FPC Sources via CVS ()<br />
<br />
You will need to have a CVS client such as TortoiseCVS or WinCVS installed in order to perform the steps below. The exact commands vary between CVS clients; the ones given below are to be used under CVS home's client, which is available for download here.<br />
<br />
First create a directory in which you'd like to put the sources. Any normal user can do this. Create a directory for fpc (e.g. C:\Source), then do the following at the command prompt:<br />
C:\Source> set CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
C:\Source> cvs login // password is 'cvs' without the commas<br />
C:\source> cvs -z3 co fpc // This will create a directory fpc, which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
C:\> cd Source\FPC<br />
C:\Source\FPC> cvs -z3 update -dP<br />
''ToDo: Write me.''<br />
<br />
See: http://www.freepascal.org/down-win32.html . You can find a list of mirrors at http://www.freepascal.org/sdown.html. Download FPC as one big file, unzip it and run the install.exe. <br />
<br />
Extending your PATH variable to the fpc directory:<br />
<br />
* Win98: Edit autoexec.bat and add the line: PATH=%PATH%;C:\pp\bin\bin\win32<br />
* WinXP/2k: My Computer (Right Click) -> Properties -> Advanced (Page) -> Enviroment Variables -> System Variables -> Edit "PATH", Add "C:\pp\bin\bin\win32" there.<br />
<br />
Then restart windows.<br />
<br />
''ToDo: Explain how to download fpc sources and build the compiler''<br />
<br />
===Installing Free Pascal under BSD/manually===<br />
<br />
Effectively, you need<br />
<br />
A file with all sources, or two (fpc and lazarus)<br />
<br />
1. e.g. for fpc ftp://ftp.freepascal.org/fpc/dist/Linux/separate/sources.tar preferably an export (no CVS/ dirs). The above file misses this.<br />
2. Lazarus source snapshot.<br />
* _any_ starting compiler from the 1.9 branch) You can do a check by parsing the output of ppc386 -i if it is 1.9.3 .. 2.0.x it is ok.<br />
* - dependant packages. (for FreeBSD that is gtk12, glib12 and gdk_pixbuf and GNU make, iconv and gettext)<br />
<br />
FPC build:<br />
<br />
1. (fetch) necessary files (FPC source, starting compiler)<br />
2. (extract) Then de-tgz in work directory,<br />
3. (build) enter work/fpc/ and run<br />
<br />
$MAKE all OPT='-gl -O3p3' PP=/path/to/startingcompiler-name-ppc386<br />
(/path/to/ can be omitted when ppc386 is in the path)<br />
($MAKE is make on linux and gmake on BSD)<br />
<br />
4. (install) then, again in work/fpc, run<br />
<br />
$MAKE install PP=compiler/ppc386 PREFIX=$THEPREFIX<br />
(THEPREFIX= usually is /usr/lcoal, but e.g. on NetBSD it is /usr/pkg for ports)<br />
Create a symlink:<br />
ln -s $THEPREFIX/lib/fpc/2.0.1/ppc386 $THEPREFIX/bin/ppc386<br />
install sourceinstall PREFIX=$THEPREFIX<br />
<br />
5. (configure) run compiler/utils/samplecfg $THEPREFIX/lib/fpc/2.0.1 $ETCDIR<br />
6. (optional, test), see if ppc386 -i gives output, else give a warning that user need to add $PREFIX/bin to his current path. Try to compiler a program with -viwn, and see if that gives errors.<br />
Notes:<br />
<br />
* If you need fpcmake package lists, you need to generate or supply them yourself, (in the port, or in an extra archive) either way, do a dummy install to /tmp/pack and determine the files installed with find . >ll<br />
<br />
* $THEPREFIX and $ETCDIR should be user configurable. Otherwise local installs aren't possible.<br />
<br />
* BSDHIER=1 on all make commands forces BSD hierarchy conventions.<br />
<br />
===Installing Free Pascal under Mac OS X===<br />
<br />
You need the Apple Developer-tools, X11, gtk1.2:<br />
<br />
Downloading packages and installing them properly can be a time consuming task. Therefore there are various package managers. One of them is fink:<br />
: Download fink from http://fink.sourceforge.net/download/index.php?phpLang=en; follow the install instructions.<br />
<br />
Developer-tools: Are included on the original OSX installation-CDs, or download at ADC (free registration required)<br />
: http://developer.apple.com/.<br />
<br />
Apple X11: On a fresh system: choose "Customize" in the install-dialogue, check "X11".<br />
<br />
On an already installed system: download at<br />
: http://www.apple.com/downloads/macosx/apple/x11formacosx.html<br />
<br />
In the Terminal, run<br />
sudo fink install gdk-pixbuf gtk+ gtk+-data gtk+-shlibs gtk-doc gtkglarea gtk-engines<br />
The X11-Application is in /Applications/Utilities/X11.<br />
<br />
Hint: Most X11 programs, including lazarus expect to receive focus, when the users clicks on a window. Under MacOSX this is deactivated. You can activate it for all X11 applications by typing in the terminal:<br />
defaults write com.apple.x11 wm_click_through -bool true<br />
<br />
;Free Pascal Compiler:<br />
Then download and install the Free Pascal Compiler (at least 1.9.5 from 16th August 2004) from<br />
: https://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
When compiling gtk-related software, you need to add two lines to the fpc.cfg file, to enable use of libraries<br />
-Fl/sw/lib<br />
-Fl/usr/X11R6/lib<br />
<br />
<br />
For lazarus you need the fpc sources as well (obsolete: use svn):<br />
Create a directory, where you would like to put the sources. You don't need to be root to do this. Any normal user can do this. <br />
First create a directory for fpc <br />
: (e.g. /Users/username/freepascal) <br />
then open a terminal and do the following:<br />
[]$ bash<br />
[]$ export CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS<br />
[]$ cvs login<br />
password is 'cvs' without the 'quotes'<br />
[]$ cvs -z3 co fpc<br />
This will create a directory called 'fpc', which can be later used in the IDE.<br />
Hint: To download/update the latest changes you can simply do<br />
[]$ cd /Users/username/freepascal/fpc<br />
[]$ cvs -z3 update -dP<br />
<br />
==Installing Lazarus==<br />
<br />
===Installing Lazarus under Linux===<br />
====Installing using rpms====<br />
The easiest way to get a current working installation of Lazarus is to download the RPMs for FreePascal and Lazarus from the SourceForge repository.<br />
<br />
You need to download the selected version of<br />
* the compiler (eg fpc-1.9.5-041207.i386.rpm)<br />
* the pascal source library (eg fpcsrc-1.9.5-041207.i386.rpm)<br />
* the Lazarus package (eg lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm).<br />
<br />
You then issue the following commands (you need to have root privileges - use su or sudo)<br />
rpm -Uvh fpc-1.9.5-041207.i386.rpm<br />
rpm -Uvh fpcsrc-1.9.5-041207.i386.rpm<br />
rpm -Uvh lazarus-0.9.2.4-fpc_1.9.5_041207.i386.rpm<br />
<br />
====Installing from source====<br />
If you prefer to install from source and compile the files yourself, follow these instructions. Because the whole lazarus stuff is installed into one directory, uninstall is very easy and you don't need to be root to install lazarus. You can get tgz files for fpc, fpcsrc and lazarus from the downloads section or you can download it directly via svn.<br />
<br />
=====Downloading Lazarus SVN=====<br />
<br />
The lazarus repository has moved from cvs to svn (Subversion). SVN provides an easy way to update your sources by only downloading the changes. This is the recommended way and saves you a lot of time. A connection to the internet is needed for this: you don't need to be root. Lazarus does not need any special permissions, neither during installation nor at runtime.<br />
<br />
With the move we also changed the directory layout of the lazarus sources. The main difference<br />
is that all ide sources are moved from the root to a separate ide subdir. As anybody might understand, this has an impact on the Makefiles, the searchpaths etc. We are in progress of fixing things, so if something doesn't work, please let us know.<br />
<br />
;Now the most important thing.... getting the sources:<br />
<br />
[]$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk/ lazarus<br />
(or any other dir where you want to place your sources)<br />
<br />
On subsequent occasions, to update simply type<br />
<br />
[]$ svn update lazarus<br />
<br />
For more information on Subversion, see:<br />
http://subversion.tigris.org/<br />
<br />
Note: the CVS is still accessable, but it frozen. This means<br />
that no new updates are comitted.<br />
<br />
=====Compiling and running=====<br />
Whether you checkout from cvs or svn, the next step is: <br />
<br />
;compile lazarus:<br />
[]$ cd lazarus<br />
[]$ make (gmake on BSD)<br />
<br />
<br />
If fpc is installed correctly, the compilation should work without problems. If not, see FAQ.<br />
<br />
;Start lazarus<br />
[]$ ./lazarus<br />
<br />
The IDE should start. If you started lazarus in a terminal, you can see some notes about missing settings. This is normal at first start. The IDE automatically tries to find out where the freepascal compiler and its sources are installed by searching in the most common directories.<br />
<br />
;Check the paths:<br />
: Use the IDE menu to go to<br />
:: Environment -> Environment Options -> Files<br />
<br />
The 'FPC Source directory' should point to your fpc source directory. This directory normally ends with /fpc/ or /fpcsrc/ (e.g. /usr/src/fpcsrc or /home/username/freepascal/fpc) and contains directories like 'compiler', 'docs', 'fcl', 'rtl' and 'packages'.<br />
<br />
''ToDo: explain the other paths''<br />
<br />
;Hint:<br />
To update lazarus you can use<br />
[]$ svn update lazarus<br />
then for either update pathway:<br />
[]$ make clean all (gmake on BSD)<br />
This will rebuild lazarus and create an IDE without lazarus packages. To link your installed packages do '''after''' the above:<br />
[]$ make idepkg<br />
<br />
====Installing Lazarus under Debian GNU/Linux====<br />
<br />
There are preliminary Debian packages for lazarus available for download. Make sure you read /usr/share/doc/lazarus/README.Debian carefully before you start using it. Feedback is needed and appreciated; please send your comments to Carlos Laviola <claviola@debian.org>.<br />
<br />
====Another (?easier) way to install Lazarus under Debian====<br />
Added by [[User:Kirkpatc]].<br />
<br />
;Simple Lazarus Installation in Debian<br />
(assume new Debian installation, without development libraries loaded)<br />
<br />
From sourceforge repository, download latest fpc, fpclib and lazarus releases; follow links from http://lazarus.freepascal.org, click the "downloads" button on the left, then click on "binaries" then "linux" then "Current Lazarus RPM". This will bring you to <br />
: http://sourceforge.net/project/showfiles.php?group_id=89339<br />
then download the following files (or more recent, if available)<br />
* fpc-2.0.0-0.i586.rpm<br />
* fpcsrc-2.0.0-0.i386.rpm<br />
* lazarus-0.9.8-fpc_2.0.0_0.i386.rpm<br />
cd to the directory where these files are stored, then become root (su) and type:<br />
<br />
alien fpc* //this will convert both the fpc and fpcsrc files to debian format<br />
alien laz*<br />
then install the generated Debian (.deb) packages by (as root):<br />
<br />
dpkg -i fpc*.deb laz*.deb<br />
or use kpackage or a similar utility to install the generated fpc, fpcsrc and lazarus .deb files.<br />
<br />
Note, if you do not have alien type:<br />
<br />
apt-get install alien<br />
<br />
You need to produce a configuration file, which will reside in /etc/fpc.cfg. Still as root, cd to the main fpc directory /usr/lib/fpc/2.0.0 and then type<br />
sh ./samplecfg /usr/lib/fpc/2.0.0 /etc<br />
Check the contents of your new configuration file (cat /etc/fpc.cfg) and make any changes you want using vi or another text editor. Also make sure that there are no old configuration files in for example your home directory (~/.fpc.cfg).<br />
<br />
You need to install the development packages of the GTK and pixbuf libraries, so<br />
apt-get install libgtk2.0-dev<br />
apt-get install libgdk-pixbuf-dev<br />
Then you should be ready to start programming!<br />
<br />
===Installing Lazarus under Mac OS X===<br />
<br />
Works pretty much the same as under Linux. But you need to install first the apple developer tools and X11.<br />
<br />
Snapshots are available at http://www.de.freepascal.org/lazarus/.<br />
<br />
If you want to experiment and develop the carbon widgetset interface, look at [[Installing Carbon on OSX]].<br />
<br />
===Installing Lazarus under Windows===<br />
<br />
The current releases of the Windows Lazarus binary packages install very easily, and should work 'out-of-the-box'. <br />
<br />
It is even possible to install the whole Lazarus/FPC package on a portable USB drive (capacity at least 256 MB), for use in environments where you are not allowed to install software on your Windows workstation or where you haven't got administrator privileges. You do have to be a little careful about adjusting the paths in the compiler and environment options and the fpc.cfg file. It may also be necessary to keep the directory for test compilation on your portable drive. << DOES ANYONE KNOW HOW TO SET UP RELATIVE PATHS IN THESE TAGS AND FILES, SO THAT THE ADDRESSING WORKS WHEN YOU MOVE THE USB DEVICE TO ANOTHER MACHINE WHERE IT HAS A DIFFERENT DRIVE LETTER? >><br />
<br />
The binary package is available for Linux and Windows from<br />
<br />
http://sourceforge.net/project/showfiles.php?group_id=89339<br />
<br />
Download the latest release (currently Lazarus-0.9.6-20050225-win32.exe) and launch the application. You will be taken through a typical Windows installation, in which the FPC compiler and source libraries are installed within the same directory structure as Lazarus, and the IDE should launch and operate without significant problems, provided you have uninstalled any previous version of Lazarus and/or FPC (often found in the C:\pp directory).<br />
<br />
You can also get a Lazarus Snapshot for Windows at: http://www.de.freepascal.org/lazarus/<br />
<br />
====Installing from source====<br />
If you prefer to install from sources, then follow these instructions (Thanks to Joe for the initial Step-by-step description)<br />
<br />
You have to download the lazarus source:<br />
: http://www.de.freepascal.org/lazarus/<br />
<br />
Then unzip it to c:\lazarus for example. You have to install at least fpc-2.0.0, but a fpc-2.0.1 or fpc 2.1.1 snapshot is also possible. It compiles for me, and lazarus.exe works. The path to my fpc is: c:\pp\bin\win32. In this directory you can find a lot of exe (make, grep, ppc386, and so on).<br />
<br />
Open a command line. Start->Run...>command or choose MS-DOS icon.<br />
<br />
Type:<br />
cd c:\lazarus<br />
set path=c:\pp\bin\win32;c:\lazarus //of course change the first to<br />
//the path of yours<br />
windres -i lazarus.rc -o lazarus.res<br />
make<br />
<br />
If you are lucky then you can type: lazarus.exe. The source editor, dialogs and the property editor work, but not perfectly... Look and you will see.<br />
<br />
You can compile examples also:<br />
<br />
cd examples<br />
make<br />
<br />
If you extracted lazarus to another drive, eg.: d:\lazarus. It can happen that you need the gnu utility to make it. If you have it, you can take its path to set path=...;<gmakepath> but it is simpler not to choose drive d:\<br />
<br />
That's all.<br />
<br />
=== Additional experiences and advice on installing FPC and Lazarus ===<br />
On linux, getting Lazarus to work can be complicated. If you have already installed earlier versions of FPC and/or Lazarus, you have to take great care that the PATHS are adjusted so that only your new versions are called.<br />
<br />
Pitfalls that I have experienced in various attempts with SuSE linux include:<br />
<br />
The rpm versions often install FPC in /bin or /usr/bin, with the libraries in /lib or /usr/lib.<br />
<br />
If you perform a make install on a source version or use a .tar.gz, the compiler is usually installed in /usr/local/bin with the libraries in /usr/local/lib.<br />
<br />
So if earlier versions have been installed from rpm, make sure all links are changed to reflect the directory structure of your new compiler. The place to make the changes is in /etc/fpc.cfg ; make sure there are no remnant configuration files in your home directory or in your FPC download directory. Typically they are found in ~/.fpc.cfg<br />
<br />
Make sure the links in /etc/fpc.cfg point to the correct versions of the libraries (particularly if you have older versions still lurking around).<br />
<br />
In /usr/local/bin or /usr/bin there is a file called fpc ; this is the executable that is called when you invoke the compiler. One of the first things it does is to open ppc386 in the same directory. This has to be the same version as the fpc file, or can be a link pointing to the true ppc386 in some other directory (such as a library directory, or the fpc directory in your own development space); be sure to update your link if you install a newer version of the compiler.<br />
<br />
Try running the compiler from the command line using one of the simple example programs or one which you wrote yourself.<br />
<br />
Turning to Lazarus:<br />
<br />
If you use a downloaded snapshot (.tar.gz) or get the source from CVS, enter your lazarus directory and type<br />
<br />
make<br />
./lazarus <br />
<br />
and hopefully the IDE should load. There may be a message saying it can't find the sources; if so, go to the menu at the top and select Environment -> Environment options and insert the name of the directory where you expect to find your lazarus files (eg ~/FreePascal/lazarus), your compiler (eg /usr/local/bin/ppc386), the FreePascal source directory (eg /usr/local/lib/fpc/$version/fpc or a directory in your own space eg ~/FreePascal/fpc). Then close the dialog and start programming.<br />
<br />
You may find further problems when you start programming or compiling; most of these will be related to PATH selection.<br />
<br />
Many of the difficulties are dealt with in the Lazarus FAQ, found either on this WiKi site, or a more complete list on the main Lazarus site<br />
<br />
http://www.lazarus.freepascal.org/modules.php?op=modload&name=FAQ&file=index<br />
<br />
From the top menu select Run -> Compiler Options (or Project -> Compiler Options in more recent releases of Lazarus) and select the Paths tab on the resulting dialog. There are several boxes for entry of paths for Unit files, Include files, Other source files, Libraries etc. For each of these, it is worth pressing the ... (ellipsis) button on the right, and you will be given a blank window for inserting path information, and a lower window giving some suggestions. Select as many as you like (or ALL!) and press the ADD button to transfer the selections to the upper window. When your selection is complete, press OK and move on to the next box. If you know of other paths which need to be followed, press the Browse button associated with each box, and insert the additional paths.<br />
<br />
When you think you have got your paths right, try to compile your application. If there are further path-related errors ('can't find unit .......') then go back and check your paths, both in /etc/fpc.cfg and in your Run -> Compiler Options dialog (or Project -> Compiler Options depending on your version).<br />
<br />
Once you have got the environment and PATHS correct, it is worth saving the settings to a file, otherwise you will have to go through this process for each new project. In the Run -> Compiler options dialog there is a Load/Save button; select this and then save the setings to the filename of your choice: mine is ~/FreePascal/default.cfg. Then each time I start a new project, I can go to the Run -> Compiler Options dialog (or Project -> Compiler Options), select Load/Save, and load my default.cfg file to the new project. You can, of course, modify the options for each new project if you so desire.<br />
<br />
===Installing Lazarus under BSD===<br />
<br />
Please write me!<br />
<br />
==Original contributors and changes==<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=InstallingLazarus version].<br />
* Initially imported and formatted. [[User:Tom | VlxAdmin]] 9/22/2003<br />
* Changed Joe's part for Windows to require fpc 1.0.10. [[User:Vincent | Vincent]] 9/25/2003<br />
* Updated "What is required for lazarus". AndrewJohnson 10/1/2003<br />
* Finished formatted the InstallingLazarus page [[User:Tom | VlxAdmin]] 2/22/2004<br />
* Posted some notes about Installing FPC and Lazarus: mostly reflecting experiences in trying to get the PATHS right in Linux. 3/11/2004 [[User:Kirkpatc]]<br />
* Copied the contents of my note into the main InstallingLazarus section, edited it slightly. I don't know how to remove the original note. 3/12/2004 [[User:Kirkpatc]]<br />
* Removed the original note. Tidied the wiki and formatting a bit. [[User:Tom | VlxAdmin]]<br />
* Corrected a couple of typos - 3/12/2004 [[User:Kirkpatc]]<br />
* Added link for daily snapshot deb packages - 3/27/2004 [[User:Vincent | Vincent]]<br />
* Fixed links in GettingLazarus (downloading binaries) and several other pages. 22 July 2004 [[User:Kirkpatc]]<br />
* Added link for lazarus deb packages - 19 August 2004 VincentSnijders<br />
* Added a short note on installing in Debian - 23 Nov 2004 [[User:Kirkpatc]]<br />
* Considerable re-write and re-organization of installation section - 11 Dec 2004 [[User:Kirkpatc]]<br />
* Fixed broken link - 9 Oct 2005 [[User:Avantman42]]</div>Fititnt