https://wiki.freepascal.org/api.php?action=feedcontributions&user=Oranke&feedformat=atomFree Pascal wiki - User contributions [en]2024-03-29T13:55:32ZUser contributionsMediaWiki 1.35.6https://wiki.freepascal.org/index.php?title=Lazarus_Documentation/ko&diff=34924Lazarus Documentation/ko2009-04-09T04:45:14Z<p>Oranke: /* 라자루스와 파스칼 튜토리얼 */</p>
<hr />
<div>{{Lazarus Documentation}}<br />
<br />
==라자루스와 파스칼 튜토리얼==<br />
*[[Overview of Free Pascal and Lazarus/ko|프리파스칼과 라자루스 살펴보기]] - 간략한 소개글 입니다.<br />
*[[Lazarus Tutorial/ko|라자루스 튜토리얼]] - 라자루스 IDE에 대해 자세히 다루고 있는 초보자를 위한 설명서 입니다.<br />
*[[Lazarus IDE Tools/ko|라자루스 IDE 툴]] - 코드 자동완성을 비롯한 기타 IDE의 내용들을 다루는 중급자용 설명서 입니다.<br />
*[[Lazarus Database Tutorial|라자루스 데이터베이스 튜토리얼]] - 데이터베이스 개발에 라자루스를 사용하기 위한 소개서 입니다.<br />
*[[Developing with Graphics|그래픽 개발]] - 그래픽 프로그래밍을 위한 기본적인 예제들 입니다.<br />
*[[Pascal Tutorial]] - [http://www.taoyue.com/ Tao Yue's] [http://www.taoyue.com/tutorials/pascal/ Pascal Tutorial] (reposted with permission).<br />
*[[Object Oriented Programming with FreePascal and Lazarus|프리파스칼과 라자루스를 사용한 객체 지향 프로그래밍]] - 파스칼 이상의 파스칼<br />
*[[Console Mode Pascal|콘솔 모드 파스칼]] - 라자루스 IDE를 사용해 텍스트 모드에서 구동되는 프로그램 만들기 입니다.<br />
*[[Executing External Programs|외부 프로그램 실행]] - 외부 프로그램을 실행시키는 방법에 대한 간단한 설명서 입니다.<br />
*[[TXMLPropStorage]] - Using TXMLPropStorage to save user preferences.<br />
*[[Hardware Access/ko|하드웨어 제어]] - ISA, PCI카드, 패러랠, 시리얼, USB 디바이스 등의 하드웨어 접근법 입니다.<br />
*[[Networking|네트워킹]] - Tutorials about TCP/IP protocol, creating secure network programs, WebServices, etc.<br />
*[[XML Tutorial|XML 튜토리얼]] - XML 파일 읽고 쓰기에 대한 내용 입니다.<br />
*[[Multithreaded Application Tutorial|멀티쓰레드 어플리케이션 튜토리얼]] - 프리파스칼과 라자루스를 사용한 멀티쓰레드 어플리케이션 제작법 입니다.<br />
*[[Streaming components|스트리밍 컴포넌트]] - 스트림에 컴포넌트를 저장하고, 다시 읽어들여 생성하는 방법 입니다.<br />
*[[OpenGL Tutorial/ko|OpenGL 튜토리얼]] - GLUT 라이브러리를 라자루스에서 사용하는 방법 입니다.<br />
*[[Creating bindings for C libraries|C 라이브러리와 연결]] - C 헤더파일을 (.h) 파스칼 유니트로 변환하는 방법에 대해 설명합니다.<br />
*[[Lazarus/FPC Libraries]] - 동적 라이브러리 (.so, .dll, .dylib) 를 만들고 또 그것을 사용하는 방법에 대해 설명합니다.<br />
*[[Translations / i18n / localizations for programs]] - 프로그램과 패키지를 로컬라이즈 하는 방법을 다룹니다.<br />
*[[Daemons and Services]] - 윈도의 서비스, 또는 리눅스의 데몬을 만드는 법에 대해 이야기 합니다.<br />
*[[Office Automation]] - 오피스 소프트웨어를 제어해 스프레트쉬트, 텍스트문서, 프리젠테이션 등을 생성하는 방법에 대해 다룹니다. <br />
*[[Lazarus Inline Assembler|라자루스 인라인 어셈블러]] - 입문서 입니다.<br />
*[[VirtualTreeview Example for Lazarus]] - 라자루스의 VirtualTreeview 사용법 입니다. <br />
*[http://es.wikibooks.org/wiki/Programaci%C3%B3n_en_Pascal Programando en Pascal] - Spanish tutorial focused on FPC/Lazarus, hosted in Wikibooks.<br />
<br />
==라자루스 사용자 가이드==<br />
*[[Lazarus Faq/ko|라자루스 FAQ]] - 리눅스 및 윈도 유저를 위한 일반적인 정보들 입니다..<br />
*[[Lazarus DB Faq|라자루스 DB FAQ]] - 라자루스에서 DB를 다룰 때 만나는 문제들에 대한 FAQ 입니다.<br />
*[[Databases in Lazarus|라자루스와 데이터베이스]] - 라자루스에서 데이터베이스를 사용하는 것에 대한 간략한 안내 입니다.<br />
*[[Code Examples|예제 모음]] - 라자루스 예제 모음 입니다.<br />
*[[Feature_Ideas|Wishlist/Wanted Features]] - Features that you would like to see in Lazarus<br />
*[[How do I create a bug report]] - You think you found a bug in Lazarus, how can you report it?<br />
<br />
===설치하기=== <br />
*[[Installing Lazarus/ko|라자루스 설치]] - 설치 방법에 대한 안내 입니다.<br />
*[[Getting Lazarus|라자루스 구하기]] - 라자루스의 릴리즈버전, 또는 SVN을 통한 개발버전을 얻는 방법에 대한 안내 입니다. <br />
*[[Multiple Lazarus|여러 버전의 라자루스]] - 한 대의 컴퓨터에 여러 버전의 라자루스를 설치하는 방법에 대한 안내 입니다.<br />
<br />
===IDE===<br />
*[[IDE tricks]] - Tips, tricks and hidden features<br />
*[[Lazarus IDE]] - The IDE windows<br />
*[[Lazarus IDE Shortcuts]] - The key mapping and shortcuts.<br />
*[[Lazarus Packages]] - A guide for creating a package under Lazarus<br />
*[[Install Packages]] - A small guide to install packages<br />
*[[Extending the IDE]] - How to add functionality to the Lazarus IDE<br />
*[[Adding Kylix Help]] - How to use the Borland Help files within the IDE editor.<br />
*[[Using Lazarus for other computer languages]] - How to use the IDE for C, Java, etc.<br />
*[[IDE Development]] - Various pages about current development of the IDE.<br />
<br />
===LCL===<br />
*[[doc:lcl/|LCL documentation]] - On line help for LCL (work in progress).<br />
*[[The LCL in various platforms]] - A brief discussion about LCL features which behave differently in different platforms.<br />
*[[Autosize / Layout]] - How to design forms that work on all platforms.<br />
*[[Main Loop Hooks]] - How to handle multiple event sources<br />
*[[Asynchronous Calls]] - How to queue methods for later execution<br />
*[[File size and smartlinking]] - How to smartlink applications and create smaller executables.<br />
*[[Accessing the Interfaces directly]] - Example how to access the LCL widgetsets<br />
*[[Add Help to Your Application]] - How to create a Online Help for your application<br />
*[[Anchor Sides]] - Description of Anchor Sides Feature<br />
*[[LCL Tips]] - Tips and tricks<br />
*[[LCL Defines]] - Choosing the right options to recompile LCL<br />
<br />
===Developing===<br />
*[[The Power of Proper Planning and Practices]] - common-sense programming best practices for the Free Pascal and Lazarus developer<br />
*[[Multiplatform Programming Guide]] - How to develop cross-platform applications and how to port from one platform to another<br />
*[[Using Pascal Libraries with .NET and Mono]] - yes, you can use your Free Pascal code with .NET and Mono<br />
*[[Deploying Your Application]] - How to create an installer for your application<br />
*[[Cross compiling]] - Creating executables of one platform, on another.<br />
*[[Remote Debugging]] - How to debug your Lazarus application from another machine.<br />
*[[Application Icon]] - Setting the application icon<br />
<br />
===플랫폼 별 유용한 팁===<br />
*[[OS X Programming Tips/ko|OS X Programming Tips]] - Lazarus 설치, 유용한 툴, Unix 명령어, 그외...<br />
*[[WinCE Programming Tips]] - Using the telephone API, sending SMSes, and more...<br />
<br />
===함께 하면 유용한 도구들===<br />
*[[Lazarus Documentation Editor]] - Using "lazde" to create documentation<br />
*[[LazDoc]] - An integrated editor for documentation files<br />
*[[FPDoc Updater]] - A GUI tool for updating FPDoc files<br />
*[[lazbuild]] - Compiling projects and packages without the IDE<br />
*[[LazSVNPkg]] - Lazarus SVN IDE Plugin<br />
<br />
===델파이 사용자를 위한 안내===<br />
*[[Lazarus Components|라자루스 컴포넌트]] - 라자루스와 터보델파이 컴포넌트들의 차이점에 대한 정보 입니다. <br />
*[[Lazarus For Delphi Users|델파이 사용자와 라자루스]] - 라자루스를 시작하려는 델파이 사용자를 위한 정보들 입니다.<br />
*[[Code Conversion Guide|코드 변환 가이드]] - 델파이와 카일릭스용 코드 및 컴포넌트를 라자루스에서 사용하는 방법에 대해 다룹니다.<br />
<br />
==라자루스 개발자 가이드==<br />
*[[Lazarus Development Process|라자루스 개발 프로세스]] - 로드맵, 아이디어, 그리고 현재.<br />
*[[How To Help Developing Lazarus|라자루스 개발을 돕는 법]] - 라자루스의 성능 개선을 위해 도움을 주려는 새로운 개발자가 참고할만한 내용들<br />
*[[Version Numbering|버전 번호 붙이기]] - 라자루스의 버전 번호의 차이점에 대한 설명 <br />
*[[Creating A Patch| 패치 만들기]] - 개선된 기능을 라자루스에 적용하기 위해 패치를 만드는 방법<br />
*[[Creating a Backtrace with GDB|GBD용 백트레이스 생성]] - 디버깅을 위해 백트레이스를 만드는 방법<br />
*[[Nomenclature/ko|이름 붙이기]] - 메소드나 프로퍼티에 이름 붙이는 방법에 대한 설명<br />
*[[DesignGuidelines/ko|디자인 가이드 라인]] - 라자루스 소스 코드 변경시 준수해야 할 규칙<br />
*[[GUI design]] - Notes on guidelines when designing the lazarus GUI<br />
*[[Roadmap]] - An idea of the current status of the various parts of Lazarus<br />
*[[Road To 1.0]] - What needs to be done for Lazarus 1.0 and To Do lists<br />
*[[Moderating the bug tracker]] - Guidelines for lazarus developers and moderators for using the [http://www.freepascal.org/mantis/ bug tracker].<br />
*[[Codetools]] - How the codetools are integrated into the IDE<br />
*[[Creating IDE Help]] - How to extend the IDE documentation<br />
*[[Unit not found - How to find units]] - How to setup the IDE and source files<br />
*[[Bounties]] - Need a particular new feature soon? Set a price here. <br />
<br />
===LCL - 라자루스 컴포넌트 라이브러리===<br />
*[[LCL Messages]] - Guide related to LCL Messages<br />
*[[LCL Internals]] - Some info about the inner workings of the LCL<br />
*[[LCL Key Handling]] - Help! A key press, what now?<br />
*[[LCL Internals - Resizing, Moving]] - How the LCL communicates with the LCL interface to resize, move controls<br />
*[[LCL Unicode Support]] - Road to Unicode enabled Lazarus<br />
*[[LCL Documentation Roadmap]] - Which units have to be documented<br />
*[[LCL Bindings]] - Bindings to use LCL on other languages<br />
<br />
===Interfaces===<br />
*[[Lazarus known issues (things that will never be fixed)]] - A list of interface compatibility issues<br />
*[[Win32/64 Interface]] - The winapi interface for Windows 95/98/Me/2K/XP/Vista, but not CE<br />
*[[GTK1 Interface]] - The gtk1.2 for Unixes, Mac OS X, Windows<br />
*[[GTK2 Interface]] - The gtk2 for Unixes, Mac OS X, Windows<br />
*[[Carbon Interface]] - The Carbon Interface for Mac OS X<br />
*[[Qt Interface]] - The Qt 4 Interface for Unixes, Mac OS X and linux-based PDAs<br />
*[[Windows CE Interface]] - For Pocket PC and Smartphones<br />
*[[fpGUI Interface]] - A widgetset completely written in Object Pascal<br />
*[[Cocoa Interface]] - The Cocoa Interface for Mac OS X<br />
<br />
===Translations===<br />
* [[Getting translation strings right]] A few notes for programmers on how to create and use translateable strings in your application. Quickly discusses general things about creating strings, offers a few hints on implementation issues and points out some things to consider when using English as base language in particular.<br />
* '''Localization Notes:'''<br />
:* [[German localization notes|German]] - Notes and guidelines for translating the Lazarus IDE to German, including a small dictionary to look up often used translations.<br />
:* [[Portuguese-Brazilian Localization Notes|Portuguese-Brazilian]] - Small dictionary containing common translations of terms used in the Lazarus IDE for the Portuguese-Brazilian translation.<br />
:* [[Russian localization notes|Russian]] - Notes and guidelines for translating the Lazarus IDE to Russian.<br />
<!-- *[[TO-DO]] Remaining Tasks --><br />
* [[Help:Add language bar | Add language bar]] explains how you can add a list of translations to the top of a wiki page.<br />
<br />
==Additional Components Documentation==<br />
*[[Pascal Script]] and [[Pascal Script Examples]] - How to use the pascal script components in Lazarus<br />
*[[OpenGL]] - How to use OpenGL in Lazarus<br />
*[[KOL-CE]] - Free Pascal/Lazarus port of KOL&MCK library. How to create very compact applications for Win32/WinCE in Lazarus.<br />
<br />
==Free Pascal Compiler Documentation==<br />
In addition to [http://lazarus-ccr.sourceforge.net/fpcdoc/ this site], the latest version of the documentation can also be found online and in a variety of downloadable formats on the main [http://www.freepascal.org/docs.html Free Pascal Compiler site].<br />
There is now also a WiKi site for FreePascal [http://www.freepascal.org/wiki/index.php/Main_Page] very similar in style to this one, to allow developers to submit documentation in addition to the official FPC documents below.<br />
<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/user/user.html User's guide]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/prog/prog.html Programmer's guide]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/ref/ref.html Reference guide for the system unit, and supported Pascal constructs]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/rtl/index.html Run-Time Library reference manual]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/fcl/index.html Free Component Library reference manual]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/fpdoc/fpdoc.html Free Pascal documentation tool manual]<br />
*[[Build messages]]<br />
<br />
==Lazarus related blogs and websites==<br />
'''Blogs'''<br />
*[[Adventures of a Newbie]] - A blog of a newbie getting started with some tutorial information in a running log.<br />
*[http://lazarusroad.blogspot.com/ On the road with Lazarus/Freepascal] - A blog dedicated to register my experiences while programming with Lazarus and Freepascal (by Luiz Américo)<br />
*[http://port2laz.blogspot.com/ Porting to Lazarus] - This blog describes the porting of a medium-sized application (~100 kloc) from D7 with CLX to Lazarus (by Alexsander da Rosa)<br />
*[http://living-lazarus.blogspot.com/ Living Lazarus] - One mans exploration into the possibilities of an open source RAD (by [[User:Wibblytim|Wibblytim]]).<br />
*[http://beeography.wordpress.com/tag/object-pascal/ Bee.ography] just (another) Bee’s buzz!<br />
*[http://donaldshimoda.blogspot.com/ Parallel Pascal Worlds] Donald Shimoda.<br />
<br />
'''Websites'''<br />
*[[swainbrain pascal wiki]] - unique free pascal tutorials and info [http://mercury.it.swin.edu.au/swinbrain/index.php/Pascal#Pascal_Development_Tools swainbrain]</div>Orankehttps://wiki.freepascal.org/index.php?title=History/ko&diff=34922History/ko2009-04-09T04:42:16Z<p>Oranke: </p>
<hr />
<div>{{History}}<br />
<br />
라자루스 프로젝트는 메디고(Megido)에 그 뿌리를 두고 있다. 구글 그룹과 다른 메일링 리스트에서 원래 델파이의 클론을 만드는 오프소스 프로젝트였던 메디고를 재설정할 수 있다. 델파이의 클론의 오픈소스는 Sybil는 오픈소스로 시작하여 Sybil이 되었고 이제는 OS/2의 델파이 클론이 되었으나 디자이너는 좀 제약이 있었다. 메디고는 1998년에 시작되어 제한 사항이 있는 것과Sybil 클론에 기초를 둔 것에 대한 관심과 집중의 부족 때문에 1999년 어디에선가 사장되었다.<br />
<br />
그래서, 라자루스는 1999년 2월 시작 되었다. 이것은 1차적으로 3명에 의해 기초가 세워졌다: Cliff Baeseman, Shane Miller, 및 Michael A. Hess. 세명의 창시자 중에서 Michael A. Hess만이 지금까지 프로젝트에 관여하고 있다.<br />
모든 세명은 메디고 프로젝트에 참여하기를 원했다. 불행히도 그들은 각자 라자루스 프로젝트를 시작했다.<br />
<br />
팀에서 두번째로 오래된 멤버는 [[User:Marc|Marc Weustink]]이다. 그는 1999년 8월 프로젝트에 참여했다. Marc는 리눅스 솔루션에서의 델파이를 기대하였으며(볼랜드에서는 당시 아무것도 없었다) 또한 흥미를 가지고 있었다. 그러므로 일반적으로 리눅스는 라자루스 프로젝트와 관계를 맺게 되었다. Marc가 합류 할 때, 라자루스는 텅빈 툴바나 하드코딩된 몇몇 gtk 메뉴 아이템밖에 없었다. 에디터는 여전히 구상중이었다. Marc는 여전히 그가 좋아하던 서브프로젝트가 있는 디버거 인터페이스 부분에서 중요 기여자였다(TODO: more?)<br />
<br />
그의 뒤를 따른 것은 2000년 부터 스텝으로 참여한 [[User:Mattias2|Mattias Gaertner]] 이다. <br />
Following him is [[User:Mattias2|Mattias Gaertner]] who got involved in Sept. 2000. With Mattias on board of the team the project made a huge step forward. Mattias ported synedit, and coded large pieces of the codetools and the designer. <br />
<br />
그의 참여에 의해 라자루스는 모양을 갖추기 시작했고 이후 3년 동안 패키지 시스템을 비롯한 많은 IDE 기능이 라자루스에 추가되었다.<br />
With these additions, Lazarus started to get its face. Three years later he added the package system and many other IDE features. <br />
<br />
<br />
[[User:Neli|Micha Nelissen]] started contributing in June 2003, mainly sending patches for the win32 interface. He used Borland C++ Builder, but wanted to look into more platforms as well. Due to Borland adding their own proprietary <br />
<br />
extensions to C++ to support their VCL, the odds of BCB applications to ever going to be portable were slim. A change of language was not really a problem so after some looking around, he thought Lazarus seemed most promising. At that time Lazarus was based on gtk for both win32 and linux. On Linux it worked very well, but on win32 it was buggy. Users <br />
<br />
of Lazarus asked more and more for a native win32 interface and Micha jumped in to help writing a native win32 interface.<br />
<br />
[[User:Vincent|Vincent Snijders]] was given a link to Lazarus and FPC during the summer of 1999, when he had just bought his linux computer and started his thesis, which involved mathematical simulations written in Delphi. He followed the project and tried mainly to get Lazarus running on Windows. After graduation in 2003 he got more time for Lazarus and started to contribute patches for Lazarus. His main focus is getting Lazarus on Windows as good as on Linux and the [[Lazarus Snapshots Downloads|Lazarus snapshots]].<br />
<br />
[[User:Sekelsenmat|Felipe Monteiro de Carvalho]] started looking at Lazarus in 2005 when it was still in the version 0.9.6. Felipe expected to use it as a substitute for Delphi, specially in Linux. Some initial attempts to use it faced a number of problems, but he didn't give up working with it, as he saw a huge potential in it, and decided to keep working on it, with the goal of having it a fully functional cross-platform alternative to Delphi for his projects <br />
<br />
(what he believes was already achieved). The contribution was initially only reporting bugs and writing documentation, but eventually went into coding as well. During this time he started many new interfaces, including Qt 4, WinCE, fpGUI and Cocoa. His current focus is the TTrayIcon component, the PasCocoa bindings, the Windows CE Interface, writing articles for the Toolbox Magazine and writing the Lazarus Book.<br />
<br />
[todo: others]</div>Orankehttps://wiki.freepascal.org/index.php?title=History/ko&diff=34921History/ko2009-04-09T04:41:24Z<p>Oranke: </p>
<hr />
<div>{{History}}<br />
<br />
라자루스 프로젝트는 메디고(Megido)에 그 뿌리를 두고 있다. 구글 그룹과 다른 메일링 리스트에서 원래 델파이의 클론을 만드는 오프소스 프로젝트였던 메디고를 재설정할 수 있다. 델파이의 클론의 오픈소스는 Sybil는 오픈소스로 시작하여 Sybil이 되었고 이제는 OS/2의 델파이 클론이 되었으나 디자이너는 좀 제약이 있었다. 메디고는 1998년에 시작되어 제한 사항이 있는 것과Sybil 클론에 기초를 둔 것에 대한 관심과 집중의 부족 때문에 1999년 어디에선가 사장되었다.<br />
<br />
그래서, 라자루스는 1999년 2월 시작 되었다. 이것은 1차적으로 3명에 의해 기초가 세워졌다: Cliff Baeseman, Shane Miller, 및 Michael A. Hess. 세명의 창시자 중에서 Michael A. Hess만이 지금까지 프로젝트에 관여하고 있다.<br />
모든 세명은 메디고 프로젝트에 참여하기를 원했다. 불행히도 그들은 각자 라자루스 프로젝트를 시작했다.<br />
<br />
팀에서 두번째로 오래된 멤버는 [[User:Marc|Marc Weustink]]이다. 그는 1999년 8월 프로젝트에 참여했다. Marc는 리눅스 솔루션에서의 델파이를 기대하였으며(볼랜드에서는 당시 아무것도 없었다) 또한 흥미를 가지고 있었다. 그러므로 일반적으로 리눅스는 라자루스 프로젝트와 관계를 맺게 되었다. Marc가 합류 할 때, 라자루스는 텅빈 툴바나 하드코딩된 몇몇 gtk 메뉴 아이템밖에 없었다. 에디터는 여전히 구상중이었다. Marc는 여전히 그가 좋아하던 서브프로젝트가 있는 디버거 인터페이스 부분에서 중요 기여자였다(TODO: more?)<br />
<br />
그의 뒤를 따른 것은 2000년 부터 스텝으로 참여한 [[User:Mattias2|Mattias Gaertner]] 이다. <br />
Following him is [[User:Mattias2|Mattias Gaertner]] who got involved in Sept. 2000. With Mattias on board of the team the project made a huge step forward. Mattias ported synedit, and coded large pieces of the codetools and the designer. <br />
<br />
그의 참여에 의해 라자루스는 모양을 갖추기 시작했고 이후 3년 동안 패키지 시스템을 비롯한 많은 IDE 기능을 라자루스에 추가되었다.<br />
With these additions, Lazarus started to get its face. Three years later he added the package system and many other IDE features. <br />
<br />
<br />
[[User:Neli|Micha Nelissen]] started contributing in June 2003, mainly sending patches for the win32 interface. He used Borland C++ Builder, but wanted to look into more platforms as well. Due to Borland adding their own proprietary <br />
<br />
extensions to C++ to support their VCL, the odds of BCB applications to ever going to be portable were slim. A change of language was not really a problem so after some looking around, he thought Lazarus seemed most promising. At that time Lazarus was based on gtk for both win32 and linux. On Linux it worked very well, but on win32 it was buggy. Users <br />
<br />
of Lazarus asked more and more for a native win32 interface and Micha jumped in to help writing a native win32 interface.<br />
<br />
[[User:Vincent|Vincent Snijders]] was given a link to Lazarus and FPC during the summer of 1999, when he had just bought his linux computer and started his thesis, which involved mathematical simulations written in Delphi. He followed the project and tried mainly to get Lazarus running on Windows. After graduation in 2003 he got more time for Lazarus and started to contribute patches for Lazarus. His main focus is getting Lazarus on Windows as good as on Linux and the [[Lazarus Snapshots Downloads|Lazarus snapshots]].<br />
<br />
[[User:Sekelsenmat|Felipe Monteiro de Carvalho]] started looking at Lazarus in 2005 when it was still in the version 0.9.6. Felipe expected to use it as a substitute for Delphi, specially in Linux. Some initial attempts to use it faced a number of problems, but he didn't give up working with it, as he saw a huge potential in it, and decided to keep working on it, with the goal of having it a fully functional cross-platform alternative to Delphi for his projects <br />
<br />
(what he believes was already achieved). The contribution was initially only reporting bugs and writing documentation, but eventually went into coding as well. During this time he started many new interfaces, including Qt 4, WinCE, fpGUI and Cocoa. His current focus is the TTrayIcon component, the PasCocoa bindings, the Windows CE Interface, writing articles for the Toolbox Magazine and writing the Lazarus Book.<br />
<br />
[todo: others]</div>Orankehttps://wiki.freepascal.org/index.php?title=FPC_documentation/ko&diff=33407FPC documentation/ko2009-01-26T10:39:00Z<p>Oranke: /* 기타 정보 */</p>
<hr />
<div>{{FPC documentation}}<br />
<br />
<br />
이 페이지는 FPC와 관련되어, 공식 문서와 차이가 나거나 아직 포함되지 않은 내용들을 모아두고 있습니다.<br />
<br />
== 메인 컴포넌트 ==<br />
<br />
[[FPC|프리파스칼 컴파일러 (FPC)]] <br />
<br />
[[RTL|런타임 라이브러리 (RTL)]]<br />
<br />
[[FCL|프리 컴포넌트 라이브러리 (FCL)]]<br />
<br />
[[Packages Base]], [[Packages Extra]] 는 이제 [[Package List]]로 합쳐 관리합니다. <br />
<br />
[[Free Vision]]<br />
<br />
[[Textmode IDE]]<br />
<br />
[[Utilities]] ([[Fpcmake]], [[H2Pas]], [[PPUDump]], [[PPUMove]], [[PTop]])<br />
<br />
[[Contributed Units]]<br />
<br />
[[FPMake]]<br />
<br />
== 기타 정보 ==<br />
<br />
[[Platform list| 플랫폼 리스트]]<br />
<br />
[[Pascal Bindings| 파스칼 바인딩]]<br />
<br />
[[Road map| 로드맵]]<br />
<br />
[[Building the VCL with FPC| FPC로 VCL를 빌드하기]]<br />
<br />
[[Building the CLX with FPC| FPC로 CLX를 빌드하기]]<br />
<br />
[[Making the FPC libraries shared| 공유할 수 있는 FPC라이브러리 만들기]]<br />
<br />
[[General Pascal and software Development remarks| 일반적인 파스칼과 소프트웨어 개발에 대한 언급]]<br />
<br />
[[To Do lists| 해야할 일]] ("어떻게 제가 도울 수 있을까요"에 대한 답을 포함하여)<br />
<br />
[[Releasing|배포와 관련된 문서]]<br />
<br />
[[Compiler development articles| 컴파일러 개발 문서]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Main_Page/ko&diff=32846Main Page/ko2008-12-24T07:39:58Z<p>Oranke: /* 개요 */</p>
<hr />
<div>__NOTOC__<br />
{{Main Page}}<br />
<br />
=라자루스와 프리파스칼 위키에 오신 것을 환영합니다=<br />
<br />
<br />
==개요==<br />
<br />
이 위키는, FPC, Lazarus, 그리고 [[Related projects/ko|관련된 프로젝트]]의 정보를 모으는 것을 목적으로 하고 있습니다.<br />
<br />
FPC는 이미 몇가지 포멧으로 잘 문서화 되어 있습니다만, [[FPC development/ko|FPC의 개발이나 조직에 관한 정보]] 그리고 [[FPC_documentation/ko|아직 정리되지 않은 문서]]들은 이 위키에 모아두고 있습니다.<br />
<br />
또한 라자루스는 필연적으로 유저들에게 배포된 문서와는 약간의 차이가 있을 수 밖에 없으므로, 누구나 참여해 편집할 수 있는 이 "open document", 또는 "wiki"가 만들어지게 되었습니다. <br />
<br />
이 위키는 브라우저를 통해 쉽게 내용을 변경하거나 추가할 수 있습니다. 사용법을 익히시려면 [http://www.chat11.com/30_Second_Quick_Wiki_Tutorial 30분 속성 위키 설명서] 또는 [http://en.wikipedia.org/wiki/Wikipedia:Tutorial 위키페디아 설명서]를 참고하세요. 연습을 위해 [[Sand Box|모래상자]]가 제공됩니다. 위키 사용에 문제가 있다면 [http://sourceforge.net/users/vlx/ 관리자]에게 알려주시거나 [http://sourceforge.net/projects/lazarus-ccr Lazarus-CCR] 에 버그를 올려주세요. 그 외에 남기고 싶은 제안은 [[Site Feedback|사이트 피드백]] 페이지를 이용하세요.<br />
<br />
라자루스의 <b>개발 이력</b>은 [[History/ko|이 곳]]을 참고하세요.<br />
<br />
==프리 파스칼 문서==<br />
;[[FPC documentation/ko|FPC 개발자 문서]]<br />
:개발자 및 기타 메시지 등을 다른 언어로 번역 해 주실 프리파스칼 컴파일러에 대한 공헌자들을 위한 문서 입니다.<br />
<br />
==라자루스 문서==<br />
;[[Lazarus Documentation/ko|라자루스 문서]]<br />
:모든 라자루스 IDE (프리파스칼 컴파일러 메뉴얼 포함) 에 대한 문서와 [[Lazarus_Documentation/ko#Lazarus_and_Pascal_Tutorials|튜토리얼]]은 [[Lazarus Documentation/ko|라자루스 문서]] 페이지에 있습니다. 많은 페이지가 "작업중"인 상태로 당신의 참여를 간절히 바라고 있습니다. 물론 새로운 페이지를 만들어 멋진 내용을 추가 해 주셔도 좋습니다.<br />
<br />
==다운로드==<br />
사용 가능한 컴포넌트와 패키지들은 [http://sourceforge.net/project/showfiles.php?group_id=92177 Lazarus-CCR 소스포지 파일 영역]에서 찾으실 수 있습니다. 프리파스칼 컴파일러와 라자루스의 현재 테스트버전은 [http://sourceforge.net/project/showfiles.php?group_id=89339 라자루스 소스포지 사이트]에서 찾으실 수 있습니다. 이 패키지에 대한 추가적인 문서는 [[Components and Code examples|컴포넌트와 코드 예제]] 페이지에 있습니다. 컴파일러와 많은 사람들에 의해 보내진 수 많은 코드들은 [http://www.freepascal.org/download.var 프리 파스클 컴파일러 다운로드 미러]와 [http://lazarus.freepascal.org 라자루스 IDE 웹사이트]에서 찾으실 수 있습니다. 라자루스 스냅샷은 [[Lazarus Snapshots Downloads | 이 곳]]에서 다운받으실 수 있습니다.<br />
<br />
==메일링 리스트==<br />
초보, 숙련자 누구나 Lazarus-ccr [http://lists.sourceforge.net/lists/listinfo/lazarus-ccr-announce 공지], 그리고 [http://lists.sourceforge.net/lists/listinfo/lazarus-ccr-general 일반] 메일링 리스트에 가입하세요.<br />
<br />
또한, [http://www.lazarus.freepascal.org/modules.php?op=modload&name=StaticPage&file=index&sURL=maill 라자루스] IDE 메일링 리스트와 [http://www.freepascal.org/maillist.html 프리파스칼] 개발자 또는 공지사항 메일링 리스트도 많은 도움이 될 것 입니다.<br />
<br />
==누가 무슨 작업을 하고 있나?==<br />
만약 당신이 현재 어떤 컴포넌트, 또는 라이브러리를 컨버팅 중이거나 그럴 필요를 느낀다면, 그 내용을 [[Current conversion projects|현재 변환중인 프로젝트]] 페이지에 올려주세요. 그렇게 함으로써 동일한 프로젝트를 두 사람 이상이 중복해 작업하는 일을 막을 수 있을 것입니다.<br />
<br />
==레퍼런스, 링크 그리고 리소스==<br />
<br />
===라자루스 IDE===<br />
라자루스 IDE에 대한 새 소식이나 정보는 [http://lazarus.freepascal.org 라자루스 IDE 웹사이트]에서 찾을 수 있습니다. 아이디어, 수정사항, 그리고 이후 개발계획은 [[Lazarus Development Process|라자루스 개발 프로세스]] 페이지를 참고하세요. 라자루스 IDE와 프리파스칼 컴파일러에 대한 다운로드도 그 곳에서 할 수 있습니다. 또한 [http://sourceforge.net/project/showfiles.php?group_id=89339 라자루스 파일 영역]에서 다운로드 가능한 컴파일러와 IDE의 최종 패키지를 얻을 수 있습니다..<br />
<br />
====라자루스 프로젝트의 활성화====<br />
<br />
[[Projects using Lazarus|라자루스 적용 프로젝트]] 페이지는 라자루스와 연관된 많은 자료에 대한 웹사이트와 다운로드 링크를 제공합니다. <br />
<br />
[[Lazarus Application Gallery/ko|라자루스 어플리케이션 갤러리]]에서는 라자루스로 만들어진 어플리케이션의 스크린샷을 구경할 수 있습니다.<br />
<br />
====유용한 링크====<br />
[[Page Of Code Sites|코드 사이트 모음]] 페이지에서 델파이/카일릭스와 관련된 사이트들의 정보를 얻을 수 있습니다. 혹시라도 이 페이지에 없는 멋진 사이트를 알고 계시다면, 언제든지 추가 해 주세요.<br />
<br />
====특화된 검색엔진====<br />
새로운 기술과 문제 해결을 위해 온라인을 기반으로한 유용한 검색과 지식엔진이 있습니다. <br />
Tamarack 연합은 볼랜드 유즈넷의 문서들의 검색을 위해 특별히 빠른 [http://www.tamaracka.com/search.htm 검색엔진]을 운영합니다.<br />
Mer Systems Inc.는 유사한 [http://www.mers.com/searchsite.html 검색엔진]을 제공하고 있습니다.<br />
사이트 검색 능력을 진행하는 또 다른 정보소스는 Earl F. Glynnd의 컴퓨터랩과 레퍼런스 [http://www.efg2.com/ 라이브러리]입니다.<br />
<br />
====마케팅 사례 연구====<br />
[[Marketing_Case_Studies|라자루스 사용자들을 위한 기회]]로 라자루스가 왜 선택받은 IDE인지를 설명합니다.<br />
<br />
<br />
<br />
====FPC/라자루스 컨테스트와 전시회 출품====<br />
FPC/Lazarus는 독일 뮌헨의 [[Systems 2005]], [[Systems 2006]]과 [[Systems 2007]]에 부스를 만들어 출품 되었습니다. 이러한 전시회의 경험을 바탕으로한 [[Preparing a booth on a trade show|정보]]수집은 앞으로 전시회의 부스 준비를 돕기위해 만들어졌습니다.<br />
라자루스와 관련 프로젝트들은 그밖의 여러 컨테스트에 참여하고 있고 [[Contests|위키 페이지]]는 앞으로의 컨테스트 자료를위해 준비되고 있습니다.<br />
<br />
=Translations=<br />
<br />
* [[Main Page/ar | عربي (Arabic)]]<br />
* [[Main Page/es | Español (Spanish)]]<br />
* [[Main Page/de | Deutsch (German)]]<br />
* [[Main Page/fr | Français (French)]]<br />
* [[Main Page/id | Bahasa Indonesia (Indonesian)]]<br />
* [[Main Page/it | Italiano (Italian)]]<br />
* [[Main Page/ja | Japanese (Japanese)]]<br />
* [[Main Page/ko | Korean (한국어)]]<br />
* [[Main Page/nl | Nederlands (Dutch)]]<br />
* [[Main Page/pl | Polski (Polish)]]<br />
* [[Main Page/pt | Português (Portuguese)]]<br />
* [[Main Page/ru | Русский (Russian)]]<br />
* [[Main Page/sk | Slovensky (Slovak)]]<br />
* [[Main Page/fi | Suomi (Finnish)]]<br />
* [[Main Page/uk | Українська (Ukrainian)]]<br />
* [[Main Page/zh_CN | Chinese 中文(简体)]]<br />
* [[Main Page/zh_TW | Chinese 中文(正體)]]<br />
* [[Main Page/vn | Vietnamese (Việt Nam)]]<br />
<br />
=예전의 위키=<br />
이 페이지들은 예전의 위키포맷에서 변환되어져 왔습니다. 전의 위키페이지는 [http://lazarus-ccr.sourceforge.net/index.php?wiki=FrontPage 여기]에서 찾을 수 있습니다.<br />
<br />
원본 제공 [[User:VlxAdmin]].</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Faq/ko&diff=32436Lazarus Faq/ko2008-12-01T13:39:42Z<p>Oranke: /* Why is the linking so slow on Windows? */</p>
<hr />
<div>{{Lazarus Faq}}<br />
<br />
이 문서는 원래 www.lazarus.freepascal.org 에 있던 것 입니다. 관리 및 확장 면에서 위키가 훨씬 더 유용하기 때문에 이 곳으로 복사되었습니다. <br />
<br />
== 일반적인 이야기 ==<br />
<br />
=== 더 많은 FAQ를 볼 수 있는 곳은 어디인가요? ===<br />
See the [http://www.lazarus.freepascal.org official website]. There is another FAQ as well.<br />
<br />
===도대체 실행파일의 크기가 왜 이렇게 큰 겁니까?===<br />
실행파일의 크기가 큰 이유는 GDB (GNU Debugger) 를 사용하기 위한 많은 정보들을 포함하고 있기 때문입니다. <br />
<br />
컴파일러에 이 디버깅 정보를 제거하기 위한 옵션 (-Xs) 이 있습니다만, 버전 2.0.2 이전의 컴파일러는 이 기능에 버그가 있기 때문에 제대로 동작하지 않습니다. 이 버그는 현재 개발버전에서는 수정되었습니다. <br />
<br />
"strip" 이라는 이름의 프로그램을 사용하면 실행파일로 부터 디버그 심볼을 삭제할 수 있습니다. 이 프로그램은 lazarus\pp\bin\i386-win32\ 에 있습니다. <br />
<br />
커맨드 라인에서 간단하게 "strip --strip-all <대상 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
실행파일을 좀 더 작게 만들려면, [http://upx.sourceforge.net/ UPX] 가 좋은 해법이 될 것입니다. UPX는 정말 멋진 실행파일 압축기 로서, 압축 해제에 추가적인 메모리가 필요없는 알고리즘을 사용합니다. (역자 주: 이 압축 알고리즘은 [http://www.oberhumer.com/opensource/lzo/ LZO] 라고 불리며, 오래 전 셀빅의 카마수트라 라는 어플에서 사용되었...^^) 또한 상당히 빠른 압축 해제 속도를 가지고 있습니다. (펜티엄 133에서 초당 10 MB 정도)<br />
<br />
커맨드 라인에서 간단하게 "upx <압축할 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
라자루스로 만든 간단한 GUI 어플리케이션의 경우 strip과 upx를 사용한 후 크기는 다음과 같습니다. <br />
* 리눅스 상에서는 ~ 700kb <br />
* 윈도우 상에서는 ~ 420kb<br />
<br />
그렇다고 UPX가 꼭 좋은 것은 아닙니다. UPX에 대한 좀 더 자세한 이야기는 [[Size Matters|크기문제]]에 대한 페이지를 참고하세요.<br />
<br />
또 한가지 주목해야 할 사실은, 라자루스의 "hello world" 프로그램은 그 자체로 이미 다음에 나열된 많은 기능들을 포함하고 있다는 것 입니다.<br />
<br />
* XML 제어 라이브러리<br />
* png, xpm, bmp 그리고 ico 파일을 다루는 이미지 라이브러리<br />
* 라자루스 컴포넌트 라이브러리의 위젯 대부분<br />
* 프리 파스칼 런타일 라이브러리 전체<br />
<br />
큰 크기의 실행파일 이면에는, 사실 이렇게 실제 어플리케이션이 필요로 하는 대부분의 기능들이 이미 들어 있습니다. <br />
<br />
라자루스 실행파일의 크기는 처음에는 매우 크지만 아주 조금씩 늘어나게 되는데, 이는 프리파스칼 컴파일러와 라자루스가 폼을 다루는 방식 때문 입니다. C++ 프로젝트의 경우 (뭐 다른 언어들도 마찬가지 입니다만) "hello world" 프로그램은 처음에는 매우 작지만 조금만 복잡한 기능을 추가하면, 그 크기가 급격하게 늘어나게 됩니다. <br />
<br />
[[Image:Lazarus_vs_cpp.png]]<br />
<br />
=== 윈도 환경에서 링킹이 오래 걸리는 이유는? ===<br />
<br />
이 문제는 FPC 2.2 와 라자루스 0.9.24 부터 해결되었습니다. 업데이트 하세요. 이후 설명은 이전 버전에 대한 것 입니다.<br />
<br />
Generally speaking, compilation on Windows takes more time then other platforms because the GNU Linker utilized by Free Pascal is slow on this platform. This problem only affects Windows, and is only bad on relatively old computers (less then 1Ghz) and computers with little RAM (128MB or less).<br />
<br />
Also, if you smartlink LCL the linking will be much slower. A study about this is located here: [[File size and smartlinking]]<br />
<br />
A internal linker was developed, and is ready, but will only be available when Free Pascal 2.2 is released (of course it's also available via subversion). It decreases the linking time dramatically.<br />
<br />
'''Note''': In 2.1.1 Windows uses an internal linker for win32/64/ce which speeds the process up a bit. A Lazarus recompile then eats about 280MB.<br />
<br />
=== Do I need ppc386.cfg or fpc.cfg? ===<br />
<br />
You only need fpc.cfg. This way the compiler knows where to find the libraries.<br />
<br />
=== How do I compile lazarus? ===<br />
<br />
Do something like this:<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
=== How do I build other projects based upon the LCL ===<br />
<br />
If you can't use the IDE to build your applications, use lazbuild. This is a command line version of the IDE to build lazarus projects and packages.<br />
If you want to build LCL applications without the IDE and without the lazbuild, add the following lines to the end of your ''fpc.cfg''<br />
<br />
# searchpath for other toolkits (Linux)<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{YourToolKit}<br />
<br />
# searchpath for other toolkits (Windows)<br />
-Fu/{YourLazarusDirectory}/components/units/{YourToolKit}<br />
<br />
:Where {YourToolKit} may be ''gtk2'', ''gnome'', ''qt'' or ''win32'' and run:<br />
::ppc386 your.project.pp<br />
<br />
'''Hint:''' Don't forget to install the development packages for your toolkit otherwise you might a receive something like: [[Linker message: cannot find -l]].<br />
<br />
=== What version of FPC is required? ===<br />
<br />
2.0.4 for MacOSX and 2.2.2 for all other systems. Warning: The 2.2.0 has a bug under MacOSX with case sensitive filenames.<br />
You can also use the svn version of fpc 2.2.3 and 2.3.x.<br />
<br />
=== I can't compile Lazarus ===<br />
<br />
# Check if the compiler has the correct version<br />
# Check if the (fpc)libraries are from the same version.<br />
# Check if you have a fpc.cfg and no old ppc386.cfg<br />
# Check also the OS-dependent FAQs<br />
<br />
=== When I try to compile a project, I have an error ===<br />
==== "Cannot find Unit interfaces". How can I solve this?====<br />
It means the compiler can not find the file 'interfaces.ppu' '''or''' it means it found one, but it is wrong or outdated.<br />
<br />
This unit can be found in {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu. For example: /home/username/lazarus/lcl/units/i386-linux/gtk/interfaces.ppu.<br />
<br />
Make sure, it is only there. If you have multiple versions of interfaces.ppu, then you probably have a wrong configuration (for instance you added a lcl directory to a search path). Remove all interfaces.ppu, but the one in the directory above.<br />
<br />
If you selected a different widgetset than you used to build lazarus, you need to build the LCL for this widgetset. <br />
<br />
If it is there, but you get this error, you are using a different compiler / rtl for compiling your project than you used for compiling your Lazarus IDE. You can do one of the following<br />
* Rebuild the LCL (or Lazarus completely) with the compiler selected in the Environmnent Options. You can do this with Tools -> Build Lazarus. Before doing this, check the current settings in Tools -> Configure Build Lazarus.<br />
* Change the compiler in the Environment Options to the one you used to compile Lazarus. Look carefully also in the Environment Options to see if you are using the correct paths for the Lazarus Directory and the FPC sources directory. Check that there is only one version of the compiler configuration file fpc.cfg - it should reside in /etc/ for Linux/Unix systems or in the same directory as the fpc compiler for Windows systems. Try to run "fpc -vt bogus" to check which fpc.cfg is being used in your system. Rogue copies often creep in if you have updated your compiler to a new version; they may be found in your home directory or in the same directory as the one in which you built your new compiler. DELETE THESE!!<br />
* You may also try to change the widgetset currently selected for the project. For example, the sample project "objectinspector" that comes with Lazarus is set to gtk by default. Compiling this project will surely give you "Can't find unit interfaces" in Windows platform. Changing widgetset to default(Win32) in Project | Compiler Options... | LCL Widget Type (various) should fix this issue.<br />
<br />
=== When I try to compile delphi projects under lazarus, I have an error ===<br />
==== at the line :{$R *.DFM} How can I solve this problem ? ====<br />
<br />
Lazarus (or better Linux) doesn't know about resources, so you can't use them in the way Delphi/Win32 does. However Lazarus uses a method pretty compatible with this. You can still use your Delphi layouts (.dfm files) if you use the following steps:<br />
<br />
*You need a textual version of the .dfm files. D5 and higher are doing this as default. If you have older files: ALT-F12 to see the layout as text and paste/copy. When you have a text .dfm file, just copy it to a .lfm file.<br />
*Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm<br />
*Add the following initialization section to<br />
<br />
initialization<br />
{$I yourform.lrs}<br />
<br />
Please keep in mind that not all properties in the dfm are supported yet by<br />
lazarus, so you might get a crash.<br />
<br />
==== 'Identifier not found LazarusResources'. ====<br />
<br />
When creating a form Lazarus automaticaly add some extra units to the uses section of your form unit. During the conversion of a delphi unit to a Lazarus unit this does not happen. So you need to add LResources to the Uses section of your form unit.<br />
<br />
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===<br />
<br />
Make sure, in the Project -> Project Inspector, that your project depends on the package 'LCL' and that you have installed the FPC sources.<br />
<br />
Lazarus is the IDE and the visual components library LCL.<br />
All other stuff, like IO, Database, FCL and RTL are provided by FPC.<br />
The IDE needs the paths to all sources.<br />
<br />
The FPC source path can be set via:<br />
Environment -> Environment Options -> Files -> FPC source directory<br />
<br />
===How to embed a small file in the executable, without the need of a separate file? How to embed a resource?===<br />
<br />
For example:<br />
/your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...<br />
will create sound.lrs from sound1.wav and sound2.wav.<br />
<br />
Then include it *behind* the form lrs file:<br />
<br />
...<br />
initialization<br />
{$i unit1.lrs} // this is main resource file (first)<br />
{$i sound.lrs} // user defined resource file<br />
<br />
end.<br />
In your program you can then use:<br />
Sound1AsString:=LazarusResources.Find('sound1').Value;<br />
<br />
=== How can I see debug output? ===<br />
<br />
The LCL has in the LCLProc unit two procedures to write debug output. They are named: <br />
* '''DebugLn:''' which works about the same as WriteLn, but accepts only strings.<br />
* '''DbgOut:''' which works about the same as Write, but accepts only strings.<br />
<br />
In normal circumstances the output is written to stdout. If stdout is closed, (for example when the application is {$AppType Gui} or compiled with -WG on Windows), no output is written.<br />
<br />
Debug output can also be written to file. The initialization code of the LCLProc unit checks Lazarus.exe's command line parameters for '--debug-log=<file>'. On finding this parameter any subsequent debug output is sent to <file>.<br />
<br />
If no '--debug-log' command line parameter has been given, it next checks if an operating system environment variable xxx_debuglog exists, where xxx is the program file name without extension. For Lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses the file specified in the lazarus_debuglog environment variable as file to receive debug output. Example: if you do:<br />
set lazarus_debuglog=c:\lazarus\debug.txt<br />
debug output will be written to c:\lazarus\debug.txt.<br />
<br />
Since this is implemented in lclproc, every application using lclproc, can use this output facility.<br />
<br />
;Debuging Lazarus : Most useful for Windows: If you want output on a console, add {$APPTYPE console} to lazarus.pp ; Then rebuild Lazarus.<br />
<br />
=== What is the meaning of the various file extensions used by Lazarus? ===<br />
<br />
The [[Lazarus Tutorial#The Lazarus files]] explains some extensions by an example.<br />
Here is a brief list:<br />
<br />
; <code>*.lpi</code> : Lazarus Project Information file (stored in XML; contains project-specific settings)<br />
; <code>*.lpr</code> : Lazarus Program file; contains Pascal source of main program<br />
; <code>*.lfm</code> : Lazarus Form file; contains configuration information for all objects on a form (stored in a Lazarus-specific textual format; the actions are described by Pascal source code in a corresponding <code>*.pas</code> file)<br />
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code (typically for a form stored in a corresponding <code>*.lfm</code> file)<br />
; <code>*.lrs</code> : Lazarus Resource file (this is a generated file; not to be confused with a Windows resource file). <br />
: This file can be created with lazres tool (in directory Lazarus/Tools) using commandline: lazres myfile.lrs myfile.lfm<br />
; <code>*.ppu</code> : Compiled unit<br />
; <code>*.lpk</code> : Lazarus package information file. (stored in XML; contains package-specific settings)<br />
<br />
=== I have fixed/improved lazarus. How can I add my changes to the official lazarus source? ===<br />
Create a patch and send it to the developers. For details see [[Creating A Patch]].<br />
=== When I do ''var mytext: text;'' to declare a text file, I get "Unit1.pas(32,15) Error: Error in type definition". How can I fix this?===<br />
The TControl class has a [[doc:lcl/controls/tcontrol.text.html|Text]] property. In a method of a form, that has higher visibility, the [[doc:rtl/system/text.html|Text]] type from the system unit. You can use the [[doc:rtl/system/textfile.html|TextFile]] type, which is just an alias for the Text type or you can add the unit to the type definition.<br />
var<br />
MyTextFile: TextFile;<br />
MyText: System.Text;<br />
A similar name clash exists with assigning and closing a text file. TForm has a ''assign'' and a [[doc:lcl/forms/tcustomform.close.html|Close]] method. You can use [[doc:rtl/objpas/assignfile.html|AssignFile]] and [[doc:rtl/objpas/closefile.html|CloseFile]] or add the unit name ''System''.<br />
<br />
=== I get an error when using Printer.BeginDoc ===<br />
<br />
The unit Printers must be added to the uses section.<br />
<br />
The Printer4Lazarus package must be added to your project requirement in the IDE under:<br />
Project|Project Inspector|Add|New Requirement|Package Name:<br />
<br />
If the package Printer4Lazarus package is not in the list when opening the dropdown box it must be installed. The package is part of the Lazarus installation and can be found in:<br />
[lazarus installed directory]\components\printers<br />
<br />
If you used the default installation directories [lazarus installed directory] is:<br />
*Windows: c:\lazarus <br />
*Linux: /usr/lib/lazarus<br />
<br />
The same solution also applies to the exception you can get when referencing Printer.Printers<br />
<br />
=== Why are TForm.ClientWidth/ClientHeight the same as TForm.Width/Height ===<br />
<br />
The TForm.Width/Height do no include the frame, because there was no way to retrieve the frame size on all platforms. Without a reliable way, the LCL would move the forms around on the screen or resize them endlessly.<br />
<br />
Eventually when there is a reliable way to get the size and position of a window with its frame on all platforms, then it will be changed. To keep compatibility with older LCL forms, a version number and some extra methods will be added.<br />
<br />
=== I created a Patch to dock the IDE Messages form on the "Source Code Editor" form (at bottom) ===<br />
<br />
Such patches will not be applied, because they only implement a small part of the needed docking. The goal is to create a complete dock manager and use that. A complete dock manager can dock all IDE windows and it allows to let the user define how to dock. For example dock the messages window above or below the source editor or ... or not at all. For instance:<br />
<br />
<pre><br />
+-------------------++--+<br />
|menu || |<br />
+-------------------+| |<br />
+--++---------------+| |<br />
|PI|| Source Editor ||CE|<br />
+--+| || |<br />
+--+| || |<br />
| |+---------------++--+<br />
|OI|+-------------------+<br />
| ||messages |<br />
+--++-------------------+<br />
</pre><br />
<br />
The dock manager can store the layout and restore it on next load. Preferably the dock manager can dock in pages too. The dock manager does not need to use drag and drop.<br />
All patches implementing docking without a dock manager makes it harder to implement a real dock manager and will be rejected.<br />
<br />
=== How can I become a developer lazarus and access management in the SVN and bug-tracker? ===<br />
<br />
First of all: you must learn about Lazarus, to prove your knowledge and skill.<br />
Start by reading the [[Lazarus_Documentation|wiki articles]], read the Lazarus source code, giving a look at the [http://www.lazarus.freepascal.org/mantis Lazarus Bug-Tracker], fix some bugs, and if you think you are ready, contact the developers on the [http://www.mail-archive.com/lazarus@miraclec.com mailing list].<br />
<br />
== Where is ... defined ==<br />
<br />
=== Virtual key constants ===<br />
Virtual key constants are defined in LCLType. Add LCLtype to your <b>uses</b>.<br />
<br />
== Using the IDE ==<br />
<br />
=== How can I use "identifier completion"? ===<br />
You can invoke identifier completion by pressing [ctrl][space].<br />
Under the menu item ''Environment -> Editor Options -> Code Tools -> Automatic Features'' you can set how quick this should happen automatically.<br />
<br />
== Linux ==<br />
<br />
=== How can I debug on Linux without the IDE? ===<br />
<br />
First of all you need a debugger. gdb is the standard debugger under linux and<br />
there are several GUI-frontends available. One common frontend is ddd, which is<br />
part of most common distributions. To compile lazarus/lcl with debug-information<br />
you should then use the following commands to start a debug session:<br />
<br />
$ make clean; make OPT=-dDEBUG<br />
$ ddd lazarus<br />
<br />
Be warned however, that ddd is not as comfortable as e.g. the Lazarus debugger.<br />
Specially if it comes to view the contents of a variable you have to take into<br />
account that ddd/gdb are case sensitive whereas Pascal is case-insensitive.<br />
Therefore you have to type all variable names in uppercase to see their<br />
contents. For more information take a look into the fpc-manuals.<br />
<br />
=== I can debug now but ddd does not find my sources or complains that they contain no code. Whats that? ===<br />
<br />
This is a path-related problem with either gdb or ddd. You can aviod this by<br />
<br />
* Use the "Change directory" command from the ddd menu and choose the directory where the sources are located. The drawback of this method is that you now can't use the source of the program you started with (e.g. lazarus). Thus it may be neccessary to change the directory multiple times.<br />
* In ddd goto [Edit] [gdb-settings] and set the search-path<br />
* Create a $(HOME)/.gdbinit file like:<br />
directory /your/path/to/lazarus<br />
directory /your/path/to/lazarus/lcl<br />
directory /your/path/to/lazarus/lcl/include<br />
<br />
=== I receive an error during the linking that states /usr/bin/ld can't find -l<some lib> ===<br />
<br />
; '''Package Based Distributions''' : You need to install the package that provides the lib<somelib>.so or lib<somelib>.a files. Dynamic libs under linux have the extension .so, while static libs have the extension .a. On some Linux distro's you have installed the package (rpm, deb) <packagename> which provides <some lib>, but you also need the development package (rpm, deb), normally called <packagename>-dev, which contains the .a (static lib) and/or the .so (dynamic lib). <br />
: Some distributions have commands to find which package contains a file:<br />
: '''Mandriva'''<br />
<br />
[]$ urpmf lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -devel<br />
<br />
: '''Debian'''<br />
<br />
:install the apt-file utility (apt-get install apt-file) then<br />
<br />
[]$ apt-file search lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -dev<br />
<br />
<br />
<br />
; '''Source Based Distributions and Manual Compilation (LFS)''' : Make sure that there is a lib<somelib>.a in the path, and that it contains the right version. To let the linker find the dynamic library, create a symlink called lib<some lib>.so to lib<some lib><version>-x,y.so if necessary (and/or for static lib; lib<some lib>.a to lib<some lib><version>-x,y.a).<br />
<br />
; '''FreeBSD''' : As source based distro's, and also make sure you have -Fl/usr/local/lib in your fpc.cfg and/or Lazarus library path. Keep in mind that GTK1.2 has "gtk12" as package name under FreeBSD. (same for glib) NOTE: This has changed as of late. Newest ports have gtk-12 and glib-12 as well. You might stumble on this problem, since FPC requires the "-less" ones, you will need to symlink them like this:<br />
<br />
[]# cd /usr/local/lib && ln -s libglib-12.so libglib12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgtk-12.so libgtk12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgdk-12.so libgdk12.so<br />
<br />
; '''NetBSD''' : As source based distro's, and also make sure you have -Fl/usr/pkg/lib in your fpc.cfg and/or Lazarus library path<br />
<br />
=== How can I convert a kylix 2 project into a lazarus project? ===<br />
<br />
Nearly the same way as converting a Kylix project into a Delphi/VCL project.<br />
<br />
The LCL (Lazarus Component Library) tries to be compatible to Delphis VCL.<br />
Kylix CLX tries to be QT compatible.<br />
Here are some general hints:<br />
<br />
* Rename all used CLX Q-units like QForms, QControls, QGraphics, ... into their VCL counterparts: Forms, Controls, Graphics, ...<br />
* Add LResources to the uses section of every form source<br />
* Rename or copy all .xfm files to .lfm files.<br />
* Rename or copy .dpr file to .lpr file.<br />
* Add "Interfaces" to the uses section in the .lpr file.<br />
* Remove {$R *.res} directive<br />
* Remove {$R *.xfm} directive<br />
* Add {$mode objfpc}{$H+} or {$mode delphi}{$H+} directive to .pas and .lpr files<br />
* Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):<br />
initialization<br />
{$I unit1.lrs}<br />
:The .lrs files can be created via the lazres tool in: (lazarusdir)/tools/lazres.<br />
:For example: ./lazres unit1.lrs unit1.lfm<br />
<br />
* Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.<br />
<br />
* To make it more platform independant, reduce unit libc (which is deprecated) references and substitute with native FPC units like baseunix/unix as much as possible. This will be necessary to support other targets than linux/x86 (including OS X, FreeBSD and Linux/x86_64)<br />
<br />
=== When compiling lazarus the compiler can not find a unit. e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB ===<br />
<br />
1. Check a clean rebuild: do a 'make clean all'<br />
<br />
2. Check if the compiler has the correct version (2.0.4 or higher)<br />
<br />
3. Check if the compiler is using the right config file. The normal installation creates /etc/fpc.cfg. But fpc also searches for ~/.ppc386.cfg, ~/.fpc.cfg, /etc/ppc386.cfg and it uses only the first it finds.<br />
<br />
:'''Hint:''' You can see which config file is used with 'ppc386 -vt bogus'<br />
:Remove any ppc386.cfg as it is really obsolete.<br />
<br />
4. Check if the config file (/etc/fpc.cfg) contains the right paths to your fpc libs. There must be three lines like this:<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*<br />
:The first part of these paths (/usr/lib/fpc) depends on your system. On some systems this can be for example /usr/local/lib/fpc/... .<br />
:'''Hint:''' You can see your searchpaths with 'ppc386 -vt bogus'<br />
<br />
5. Check that the config file (/etc/fpc.cfg) does not contain search paths to the lcl source files (.pp, .pas):<br />
forbidden: -Fu(lazarus_source_directory)/lcl<br />
forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk<br />
:If you want to add the lcl for all your fpc projects, make sure that the two paths look like the following and are placed after the above fpc lib paths:<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk<br />
<br />
6. Check if the missing unit (glib.ppu) exists in your fpc lib directory. For example the gtk.ppu can be found in /usr/lib/fpc/$fpcversion/units/i386-linux/gtk/. If it does not exists, the fpc lib is corrupt and should be reinstalled.<br />
<br />
7. Check if the sources are in a NFS mounted directory. In some cases the NFS updates created files incorrectly. Please, try to move the sources into a non NFS directory and compile there.<br />
<br />
8. If you are still not succeeded try to use samplecfg script as follows:<br />
<br />
''#'' cd /usr/lib/fpc/''version''/<br />
<br />
''#'' sudo ./samplecfg /usr/lib/fpc/''\$version'' /etc<br />
<br />
Note! Do not put - / - after etc because if you do that the system will create a file - /etc/fpc.cfg/fpc.cfg. In fact we want that samplecfg make a file - /etc/fpc.cfg - not the folder /etc/fpc.cfg.<br />
<br />
=== I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS ===<br />
<br />
Probably you are using a newer fpc package, than that used for building the<br />
lazarus binaries. The best solution is to download the sources and compile<br />
lazarus manually. You can download the source snapshot or get the source<br />
via svn:<br />
<br />
$ bash<br />
$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
Make sure that lazarus get the new source directory:<br />
Environment->General Options->Files->Lazarus Directory Top<br />
<br />
===Lazarus compiles, but linking fails with: libgdk-pixbuf not found===<br />
Install the gdk-pixbuf library for gtk1.x:<br />
<br />
Where to find the gdk-pixbuf library:<br />
<br />
RPMs:<br />
http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=<br />
<br />
Debian packages:<br />
libgdk-pixbuf-dev<br />
<br />
Sources:<br />
ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/<br />
<br />
===I have SuSE and I get /usr/bin/ld: cannot find -lgtk Error: Error while linking===<br />
SuSE installs the gtk devel libs under /opt/gnome/lib (or /opt/gnome/lib64 for 64 bits), which is not in<br />
the standard lib path. Simply add it to your /etc/fpc.cfg.<br />
(-Fl/opt/gnome/lib).<br />
<br />
===Lazarus crashes with runtime error 211 after I installed a component===<br />
After I installed a component, Lazarus crashes with the following message:<br />
Threading has been used before cthreads was initialized.<br />
Make cthreads one of the first units in your uses clause.<br />
Runtime error 211 at $0066E188<br />
How can I fix this?<br />
<br />
Your freshly installed component is using threads. FPC on *nix doesn't automatically include threading support, but it must be intialized. This initialization is done in the cthreads unit. Every application using the component needs to add this unit to the uses clause of the main program. Lazarus itself is no exception. This can be done in two ways:<br />
<br />
1) Open the package. In the package editor click on ''Options''. Under page ''Usage'' add to the ''custom'' options '''-dUseCThreads'''. Then rebuild the IDE. This way the cthreads unit will be automatically used by the IDE under unix and the cthreads are initialized.<br />
<br />
2) In order to avoid modifying package, a fpc compiler option could be used directly. Open menu Tools->Configure "build Lazarus". Configure "build Lazarus" dialog will be shown, in field "Options:" type -Facthreads and then press "OK" button. The next step is to install the package. Lazarus will be built with option -Facthreads which means that it will treat main program as if unit cthreads where first in uses clause. <br />
<br />
''Hint:'' Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.<br />
<br />
See also [[Multithreaded_Application_Tutorial#Units_needed_for_a_multithreaded_application]]<br />
<br />
===When I run a program with threads I get runtime error 232===<br />
The complete error message is:<br />
This binary has no thread support compiled in.<br />
Recompile the application with a thread-driver in the program uses<br />
clause before other units using thread.<br />
Runtime error 232<br />
'''Solution''': Add cthreads as first unit to the uses clause of your main program, usually the .lpr-file.<br />
<br />
===I have Ubuntu Breezy and my fonts in Lazarus IDE look too big===<br />
If Lazarus is compiled with Gtk1.2, the settings in Gnome Preferences/Font don't have any effect as<br />
they are related to Gtk2.<br />
You could try this solution:<br />
Create a file named .gtkrc.mine in your home directory (if it's not already there) and add<br />
these lines to it:<br />
<br />
<pre><br />
style "default-text" {<br />
fontset = "-*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\<br />
-*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"<br />
}<br />
<br />
class "GtkWidget" style "default-text"<br />
</pre><br />
<br />
If this is not enough try and create also a .gtkrc symlink to .gtkrc.mine . It worked in this way under Xubuntu 7.10.<br />
<br />
===How can my gtk programs use custom rc files?===<br />
<br />
Option a)<br />
Name the rc file ''yourprogram.gtkrc'' and put it in the same directory where the executable is.<br />
<br />
Option b)<br />
Use unit ''GtkInt'' and call ''GTKWidgetSet.SetRCFilename('your_preferred_rc_file');''<br />
Best done before ''Application.Initialize'' in the .lpr file with ''{$IFDEF LCLGtk}''.<br />
<br />
===I have Ubuntu and I cannot compile for Gtk2 due to missing libraries===<br />
Ubuntu has a problem with not creating all the symbolic links that you'll need even when the libraries are installed. Make sure that all missing libraries when trying to link for Gtk2 have their appropriate links. For instance, you might need to do:<br />
<br />
<pre><br />
cd /usr/lib<br />
sudo ln -s libgdk-x11-2.0.so.0 libgtk-x11-2.0.so<br />
</pre><br />
<br />
Make sure that the [whatever].so symbolic links are created and point to the actual libraries.<br />
<br />
===How can I compile a program for Gtk2?===<br />
<br />
At the moment, the Gtk2 compiled IDE is a little unstable, but you can compile software for Gtk2 using the Gtk1 IDE.<br />
<br />
To start with recompile LCL for Gtk2. Go to the menu "Tools"->"Configure Build Lazarus" and set LCL to clean+build and everything else to none.<br />
<br />
Now click Ok and go to the menu "Tools"->"Build Lazarus"<br />
<br />
Now you can compile your software with Gtk2 going on the Compiler options and changing the widgetset to Gtk2.<br />
<br />
===I get this message: "[WARNING] ** Multibyte character encodings (like UTF8) are not supported at the moment."===<br />
<br />
Since revision 10535 (0.9.21) this message doesn't exist anymore. <br />
Previously it was used to warn that a UTF-8 encoding was used. The internal keyhandling routines for the gtk1 widgetset couldn't handle such encoding for keypresses, with the result that keypresses with for instance accented chars were not or wrong detected.<br />
<br />
(original text for older versions of lazarus)<br><br />
<strike><br />
This warning message indicates that your locale enconding is set to utf-8. If you are using Gtk 1 this can be a serious problem and prevent the correct working of Lazarus or software created with Lazarus.<br />
<br />
To work around this, just change your locale to a non utf-8 before executing the program on the command line, like this:<br />
<br />
<pre><br />
export LC_CTYPE="pt_BR"<br />
export LANG="pt_BR"<br />
export LANGUAGE="pt_BR"<br />
./lazarus<br />
</pre><br />
<br />
Substitute pt_BR with the locale for your country. You can create a script to automate this.<br />
</strike><br />
<br />
== Windows ==<br />
<br />
=== When I cycle the compiler, I get:The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time. ===<br />
<br />
In the compiler directory there is an OS2 scriptfile named make.cmd. Different versions of Windows also see this as a script file, so remove it since what is needed for OS2 becomes a hindrance on Windows.<br />
<br />
=== When I cycle the compiler, I get: make[3]: ./ppc1.exe: Command not found ===<br />
<br />
I don't know why but somehow make has lost its path. Try to cycle with a<br />
basedir set like: make cycle BASEDIR=your_fpc_source_dir_herecompiler<br />
<br />
=== When I try to make Lazarus I get:===<br />
====make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2 ====<br />
You need to upgrade your make.<br />
<br />
====makefile:27: *** You need the GNU utils package to use this Makefile. Stop.====<br />
Make sure you didn't install FPC in a path with spaces in the name. The<br />
Makefile doesn't support it.<br />
<br />
<br />
<br />
===How can I give my program an XP look like lazarus has?===<br />
Project -> Project Options -> Check 'Use manifest to enables themes'.<br />
<br />
===When I run Windows program created in Lazarus it starts with a DOS window===<br />
Specify the -WG argument (Windows GUI) on the command line of the compiler or in the Lazarus IDE check the Windows GUI check box on the compiler options dialog box (Project menu -> Compiler Options -> Linking -> target OS Specific options.<br />
<br />
== Mac OS X ==<br />
<br />
=== Why does compiling a project fail with 'unknown section attribute: no_dead_strip'?===<br />
<br />
Dead code stripping is not supported by the assembler and linker before Xcode 1.5 (available for Mac OS X 10.3.9). Disable the compiler options <br />
<br />
*Code > Unit style > Smart linkable (-CX) <br />
*and Linking > Link Style > Link smart (-XX)<br />
<br />
== Licensing ==<br />
<br />
=== Can I make commercial applications with Lazarus ? ===<br />
<br />
Yes, the LCL is licensed under the LGPL with an exception, which allows you to link to it statically without releasing the source of your application. Modifications and enhancements to the LCL must be distributed with source. Lazarus, the IDE, is licensed under the GPL.<br />
<br />
=== Can I make commercial plug-ins for Lazarus ? ===<br />
<br />
Yes, the IDEIntf part of the IDE is licensed under the LGPL with the same exception, so that shared data structures in this part will not force you to license your plug-in or design-time package under the GPL. You are free to choose a plug-in of any license; we don't want to limit your choice. Therefore non-GPL compatible plug-ins are allowed. Note that it's not allowed to distribute a precompiled Lazarus with these non-GPL-compatible plugins included statically; however, we do not see this as a severe limitation, since recompiling Lazarus is easy.<br />
<br />
== Contributors and Comments ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq version].</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Faq/ko&diff=32435Lazarus Faq/ko2008-12-01T13:36:58Z<p>Oranke: /* 도대체 실행파일의 크기가 왜 이렇게 큰 겁니까? */</p>
<hr />
<div>{{Lazarus Faq}}<br />
<br />
이 문서는 원래 www.lazarus.freepascal.org 에 있던 것 입니다. 관리 및 확장 면에서 위키가 훨씬 더 유용하기 때문에 이 곳으로 복사되었습니다. <br />
<br />
== 일반적인 이야기 ==<br />
<br />
=== 더 많은 FAQ를 볼 수 있는 곳은 어디인가요? ===<br />
See the [http://www.lazarus.freepascal.org official website]. There is another FAQ as well.<br />
<br />
===도대체 실행파일의 크기가 왜 이렇게 큰 겁니까?===<br />
실행파일의 크기가 큰 이유는 GDB (GNU Debugger) 를 사용하기 위한 많은 정보들을 포함하고 있기 때문입니다. <br />
<br />
컴파일러에 이 디버깅 정보를 제거하기 위한 옵션 (-Xs) 이 있습니다만, 버전 2.0.2 이전의 컴파일러는 이 기능에 버그가 있기 때문에 제대로 동작하지 않습니다. 이 버그는 현재 개발버전에서는 수정되었습니다. <br />
<br />
"strip" 이라는 이름의 프로그램을 사용하면 실행파일로 부터 디버그 심볼을 삭제할 수 있습니다. 이 프로그램은 lazarus\pp\bin\i386-win32\ 에 있습니다. <br />
<br />
커맨드 라인에서 간단하게 "strip --strip-all <대상 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
실행파일을 좀 더 작게 만들려면, [http://upx.sourceforge.net/ UPX] 가 좋은 해법이 될 것입니다. UPX는 정말 멋진 실행파일 압축기 로서, 압축 해제에 추가적인 메모리가 필요없는 알고리즘을 사용합니다. (역자 주: 이 압축 알고리즘은 [http://www.oberhumer.com/opensource/lzo/ LZO] 라고 불리며, 오래 전 셀빅의 카마수트라 라는 어플에서 사용되었...^^) 또한 상당히 빠른 압축 해제 속도를 가지고 있습니다. (펜티엄 133에서 초당 10 MB 정도)<br />
<br />
커맨드 라인에서 간단하게 "upx <압축할 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
라자루스로 만든 간단한 GUI 어플리케이션의 경우 strip과 upx를 사용한 후 크기는 다음과 같습니다. <br />
* 리눅스 상에서는 ~ 700kb <br />
* 윈도우 상에서는 ~ 420kb<br />
<br />
그렇다고 UPX가 꼭 좋은 것은 아닙니다. UPX에 대한 좀 더 자세한 이야기는 [[Size Matters|크기문제]]에 대한 페이지를 참고하세요.<br />
<br />
또 한가지 주목해야 할 사실은, 라자루스의 "hello world" 프로그램은 그 자체로 이미 다음에 나열된 많은 기능들을 포함하고 있다는 것 입니다.<br />
<br />
* XML 제어 라이브러리<br />
* png, xpm, bmp 그리고 ico 파일을 다루는 이미지 라이브러리<br />
* 라자루스 컴포넌트 라이브러리의 위젯 대부분<br />
* 프리 파스칼 런타일 라이브러리 전체<br />
<br />
큰 크기의 실행파일 이면에는, 사실 이렇게 실제 어플리케이션이 필요로 하는 대부분의 기능들이 이미 들어 있습니다. <br />
<br />
라자루스 실행파일의 크기는 처음에는 매우 크지만 아주 조금씩 늘어나게 되는데, 이는 프리파스칼 컴파일러와 라자루스가 폼을 다루는 방식 때문 입니다. C++ 프로젝트의 경우 (뭐 다른 언어들도 마찬가지 입니다만) "hello world" 프로그램은 처음에는 매우 작지만 조금만 복잡한 기능을 추가하면, 그 크기가 급격하게 늘어나게 됩니다. <br />
<br />
[[Image:Lazarus_vs_cpp.png]]<br />
<br />
=== Why is the linking so slow on Windows? ===<br />
<br />
This problem is over from FPC 2.2 and Lazarus 0.9.24. Please update your Lazarus. For older versions read text below.<br />
<br />
Generally speaking, compilation on Windows takes more time then other platforms because the GNU Linker utilized by Free Pascal is slow on this platform. This problem only affects Windows, and is only bad on relatively old computers (less then 1Ghz) and computers with little RAM (128MB or less).<br />
<br />
Also, if you smartlink LCL the linking will be much slower. A study about this is located here: [[File size and smartlinking]]<br />
<br />
A internal linker was developed, and is ready, but will only be available when Free Pascal 2.2 is released (of course it's also available via subversion). It decreases the linking time dramatically.<br />
<br />
'''Note''': In 2.1.1 Windows uses an internal linker for win32/64/ce which speeds the process up a bit. A Lazarus recompile then eats about 280MB.<br />
<br />
=== Do I need ppc386.cfg or fpc.cfg? ===<br />
<br />
You only need fpc.cfg. This way the compiler knows where to find the libraries.<br />
<br />
=== How do I compile lazarus? ===<br />
<br />
Do something like this:<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
=== How do I build other projects based upon the LCL ===<br />
<br />
If you can't use the IDE to build your applications, use lazbuild. This is a command line version of the IDE to build lazarus projects and packages.<br />
If you want to build LCL applications without the IDE and without the lazbuild, add the following lines to the end of your ''fpc.cfg''<br />
<br />
# searchpath for other toolkits (Linux)<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{YourToolKit}<br />
<br />
# searchpath for other toolkits (Windows)<br />
-Fu/{YourLazarusDirectory}/components/units/{YourToolKit}<br />
<br />
:Where {YourToolKit} may be ''gtk2'', ''gnome'', ''qt'' or ''win32'' and run:<br />
::ppc386 your.project.pp<br />
<br />
'''Hint:''' Don't forget to install the development packages for your toolkit otherwise you might a receive something like: [[Linker message: cannot find -l]].<br />
<br />
=== What version of FPC is required? ===<br />
<br />
2.0.4 for MacOSX and 2.2.2 for all other systems. Warning: The 2.2.0 has a bug under MacOSX with case sensitive filenames.<br />
You can also use the svn version of fpc 2.2.3 and 2.3.x.<br />
<br />
=== I can't compile Lazarus ===<br />
<br />
# Check if the compiler has the correct version<br />
# Check if the (fpc)libraries are from the same version.<br />
# Check if you have a fpc.cfg and no old ppc386.cfg<br />
# Check also the OS-dependent FAQs<br />
<br />
=== When I try to compile a project, I have an error ===<br />
==== "Cannot find Unit interfaces". How can I solve this?====<br />
It means the compiler can not find the file 'interfaces.ppu' '''or''' it means it found one, but it is wrong or outdated.<br />
<br />
This unit can be found in {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu. For example: /home/username/lazarus/lcl/units/i386-linux/gtk/interfaces.ppu.<br />
<br />
Make sure, it is only there. If you have multiple versions of interfaces.ppu, then you probably have a wrong configuration (for instance you added a lcl directory to a search path). Remove all interfaces.ppu, but the one in the directory above.<br />
<br />
If you selected a different widgetset than you used to build lazarus, you need to build the LCL for this widgetset. <br />
<br />
If it is there, but you get this error, you are using a different compiler / rtl for compiling your project than you used for compiling your Lazarus IDE. You can do one of the following<br />
* Rebuild the LCL (or Lazarus completely) with the compiler selected in the Environmnent Options. You can do this with Tools -> Build Lazarus. Before doing this, check the current settings in Tools -> Configure Build Lazarus.<br />
* Change the compiler in the Environment Options to the one you used to compile Lazarus. Look carefully also in the Environment Options to see if you are using the correct paths for the Lazarus Directory and the FPC sources directory. Check that there is only one version of the compiler configuration file fpc.cfg - it should reside in /etc/ for Linux/Unix systems or in the same directory as the fpc compiler for Windows systems. Try to run "fpc -vt bogus" to check which fpc.cfg is being used in your system. Rogue copies often creep in if you have updated your compiler to a new version; they may be found in your home directory or in the same directory as the one in which you built your new compiler. DELETE THESE!!<br />
* You may also try to change the widgetset currently selected for the project. For example, the sample project "objectinspector" that comes with Lazarus is set to gtk by default. Compiling this project will surely give you "Can't find unit interfaces" in Windows platform. Changing widgetset to default(Win32) in Project | Compiler Options... | LCL Widget Type (various) should fix this issue.<br />
<br />
=== When I try to compile delphi projects under lazarus, I have an error ===<br />
==== at the line :{$R *.DFM} How can I solve this problem ? ====<br />
<br />
Lazarus (or better Linux) doesn't know about resources, so you can't use them in the way Delphi/Win32 does. However Lazarus uses a method pretty compatible with this. You can still use your Delphi layouts (.dfm files) if you use the following steps:<br />
<br />
*You need a textual version of the .dfm files. D5 and higher are doing this as default. If you have older files: ALT-F12 to see the layout as text and paste/copy. When you have a text .dfm file, just copy it to a .lfm file.<br />
*Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm<br />
*Add the following initialization section to<br />
<br />
initialization<br />
{$I yourform.lrs}<br />
<br />
Please keep in mind that not all properties in the dfm are supported yet by<br />
lazarus, so you might get a crash.<br />
<br />
==== 'Identifier not found LazarusResources'. ====<br />
<br />
When creating a form Lazarus automaticaly add some extra units to the uses section of your form unit. During the conversion of a delphi unit to a Lazarus unit this does not happen. So you need to add LResources to the Uses section of your form unit.<br />
<br />
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===<br />
<br />
Make sure, in the Project -> Project Inspector, that your project depends on the package 'LCL' and that you have installed the FPC sources.<br />
<br />
Lazarus is the IDE and the visual components library LCL.<br />
All other stuff, like IO, Database, FCL and RTL are provided by FPC.<br />
The IDE needs the paths to all sources.<br />
<br />
The FPC source path can be set via:<br />
Environment -> Environment Options -> Files -> FPC source directory<br />
<br />
===How to embed a small file in the executable, without the need of a separate file? How to embed a resource?===<br />
<br />
For example:<br />
/your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...<br />
will create sound.lrs from sound1.wav and sound2.wav.<br />
<br />
Then include it *behind* the form lrs file:<br />
<br />
...<br />
initialization<br />
{$i unit1.lrs} // this is main resource file (first)<br />
{$i sound.lrs} // user defined resource file<br />
<br />
end.<br />
In your program you can then use:<br />
Sound1AsString:=LazarusResources.Find('sound1').Value;<br />
<br />
=== How can I see debug output? ===<br />
<br />
The LCL has in the LCLProc unit two procedures to write debug output. They are named: <br />
* '''DebugLn:''' which works about the same as WriteLn, but accepts only strings.<br />
* '''DbgOut:''' which works about the same as Write, but accepts only strings.<br />
<br />
In normal circumstances the output is written to stdout. If stdout is closed, (for example when the application is {$AppType Gui} or compiled with -WG on Windows), no output is written.<br />
<br />
Debug output can also be written to file. The initialization code of the LCLProc unit checks Lazarus.exe's command line parameters for '--debug-log=<file>'. On finding this parameter any subsequent debug output is sent to <file>.<br />
<br />
If no '--debug-log' command line parameter has been given, it next checks if an operating system environment variable xxx_debuglog exists, where xxx is the program file name without extension. For Lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses the file specified in the lazarus_debuglog environment variable as file to receive debug output. Example: if you do:<br />
set lazarus_debuglog=c:\lazarus\debug.txt<br />
debug output will be written to c:\lazarus\debug.txt.<br />
<br />
Since this is implemented in lclproc, every application using lclproc, can use this output facility.<br />
<br />
;Debuging Lazarus : Most useful for Windows: If you want output on a console, add {$APPTYPE console} to lazarus.pp ; Then rebuild Lazarus.<br />
<br />
=== What is the meaning of the various file extensions used by Lazarus? ===<br />
<br />
The [[Lazarus Tutorial#The Lazarus files]] explains some extensions by an example.<br />
Here is a brief list:<br />
<br />
; <code>*.lpi</code> : Lazarus Project Information file (stored in XML; contains project-specific settings)<br />
; <code>*.lpr</code> : Lazarus Program file; contains Pascal source of main program<br />
; <code>*.lfm</code> : Lazarus Form file; contains configuration information for all objects on a form (stored in a Lazarus-specific textual format; the actions are described by Pascal source code in a corresponding <code>*.pas</code> file)<br />
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code (typically for a form stored in a corresponding <code>*.lfm</code> file)<br />
; <code>*.lrs</code> : Lazarus Resource file (this is a generated file; not to be confused with a Windows resource file). <br />
: This file can be created with lazres tool (in directory Lazarus/Tools) using commandline: lazres myfile.lrs myfile.lfm<br />
; <code>*.ppu</code> : Compiled unit<br />
; <code>*.lpk</code> : Lazarus package information file. (stored in XML; contains package-specific settings)<br />
<br />
=== I have fixed/improved lazarus. How can I add my changes to the official lazarus source? ===<br />
Create a patch and send it to the developers. For details see [[Creating A Patch]].<br />
=== When I do ''var mytext: text;'' to declare a text file, I get "Unit1.pas(32,15) Error: Error in type definition". How can I fix this?===<br />
The TControl class has a [[doc:lcl/controls/tcontrol.text.html|Text]] property. In a method of a form, that has higher visibility, the [[doc:rtl/system/text.html|Text]] type from the system unit. You can use the [[doc:rtl/system/textfile.html|TextFile]] type, which is just an alias for the Text type or you can add the unit to the type definition.<br />
var<br />
MyTextFile: TextFile;<br />
MyText: System.Text;<br />
A similar name clash exists with assigning and closing a text file. TForm has a ''assign'' and a [[doc:lcl/forms/tcustomform.close.html|Close]] method. You can use [[doc:rtl/objpas/assignfile.html|AssignFile]] and [[doc:rtl/objpas/closefile.html|CloseFile]] or add the unit name ''System''.<br />
<br />
=== I get an error when using Printer.BeginDoc ===<br />
<br />
The unit Printers must be added to the uses section.<br />
<br />
The Printer4Lazarus package must be added to your project requirement in the IDE under:<br />
Project|Project Inspector|Add|New Requirement|Package Name:<br />
<br />
If the package Printer4Lazarus package is not in the list when opening the dropdown box it must be installed. The package is part of the Lazarus installation and can be found in:<br />
[lazarus installed directory]\components\printers<br />
<br />
If you used the default installation directories [lazarus installed directory] is:<br />
*Windows: c:\lazarus <br />
*Linux: /usr/lib/lazarus<br />
<br />
The same solution also applies to the exception you can get when referencing Printer.Printers<br />
<br />
=== Why are TForm.ClientWidth/ClientHeight the same as TForm.Width/Height ===<br />
<br />
The TForm.Width/Height do no include the frame, because there was no way to retrieve the frame size on all platforms. Without a reliable way, the LCL would move the forms around on the screen or resize them endlessly.<br />
<br />
Eventually when there is a reliable way to get the size and position of a window with its frame on all platforms, then it will be changed. To keep compatibility with older LCL forms, a version number and some extra methods will be added.<br />
<br />
=== I created a Patch to dock the IDE Messages form on the "Source Code Editor" form (at bottom) ===<br />
<br />
Such patches will not be applied, because they only implement a small part of the needed docking. The goal is to create a complete dock manager and use that. A complete dock manager can dock all IDE windows and it allows to let the user define how to dock. For example dock the messages window above or below the source editor or ... or not at all. For instance:<br />
<br />
<pre><br />
+-------------------++--+<br />
|menu || |<br />
+-------------------+| |<br />
+--++---------------+| |<br />
|PI|| Source Editor ||CE|<br />
+--+| || |<br />
+--+| || |<br />
| |+---------------++--+<br />
|OI|+-------------------+<br />
| ||messages |<br />
+--++-------------------+<br />
</pre><br />
<br />
The dock manager can store the layout and restore it on next load. Preferably the dock manager can dock in pages too. The dock manager does not need to use drag and drop.<br />
All patches implementing docking without a dock manager makes it harder to implement a real dock manager and will be rejected.<br />
<br />
=== How can I become a developer lazarus and access management in the SVN and bug-tracker? ===<br />
<br />
First of all: you must learn about Lazarus, to prove your knowledge and skill.<br />
Start by reading the [[Lazarus_Documentation|wiki articles]], read the Lazarus source code, giving a look at the [http://www.lazarus.freepascal.org/mantis Lazarus Bug-Tracker], fix some bugs, and if you think you are ready, contact the developers on the [http://www.mail-archive.com/lazarus@miraclec.com mailing list].<br />
<br />
== Where is ... defined ==<br />
<br />
=== Virtual key constants ===<br />
Virtual key constants are defined in LCLType. Add LCLtype to your <b>uses</b>.<br />
<br />
== Using the IDE ==<br />
<br />
=== How can I use "identifier completion"? ===<br />
You can invoke identifier completion by pressing [ctrl][space].<br />
Under the menu item ''Environment -> Editor Options -> Code Tools -> Automatic Features'' you can set how quick this should happen automatically.<br />
<br />
== Linux ==<br />
<br />
=== How can I debug on Linux without the IDE? ===<br />
<br />
First of all you need a debugger. gdb is the standard debugger under linux and<br />
there are several GUI-frontends available. One common frontend is ddd, which is<br />
part of most common distributions. To compile lazarus/lcl with debug-information<br />
you should then use the following commands to start a debug session:<br />
<br />
$ make clean; make OPT=-dDEBUG<br />
$ ddd lazarus<br />
<br />
Be warned however, that ddd is not as comfortable as e.g. the Lazarus debugger.<br />
Specially if it comes to view the contents of a variable you have to take into<br />
account that ddd/gdb are case sensitive whereas Pascal is case-insensitive.<br />
Therefore you have to type all variable names in uppercase to see their<br />
contents. For more information take a look into the fpc-manuals.<br />
<br />
=== I can debug now but ddd does not find my sources or complains that they contain no code. Whats that? ===<br />
<br />
This is a path-related problem with either gdb or ddd. You can aviod this by<br />
<br />
* Use the "Change directory" command from the ddd menu and choose the directory where the sources are located. The drawback of this method is that you now can't use the source of the program you started with (e.g. lazarus). Thus it may be neccessary to change the directory multiple times.<br />
* In ddd goto [Edit] [gdb-settings] and set the search-path<br />
* Create a $(HOME)/.gdbinit file like:<br />
directory /your/path/to/lazarus<br />
directory /your/path/to/lazarus/lcl<br />
directory /your/path/to/lazarus/lcl/include<br />
<br />
=== I receive an error during the linking that states /usr/bin/ld can't find -l<some lib> ===<br />
<br />
; '''Package Based Distributions''' : You need to install the package that provides the lib<somelib>.so or lib<somelib>.a files. Dynamic libs under linux have the extension .so, while static libs have the extension .a. On some Linux distro's you have installed the package (rpm, deb) <packagename> which provides <some lib>, but you also need the development package (rpm, deb), normally called <packagename>-dev, which contains the .a (static lib) and/or the .so (dynamic lib). <br />
: Some distributions have commands to find which package contains a file:<br />
: '''Mandriva'''<br />
<br />
[]$ urpmf lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -devel<br />
<br />
: '''Debian'''<br />
<br />
:install the apt-file utility (apt-get install apt-file) then<br />
<br />
[]$ apt-file search lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -dev<br />
<br />
<br />
<br />
; '''Source Based Distributions and Manual Compilation (LFS)''' : Make sure that there is a lib<somelib>.a in the path, and that it contains the right version. To let the linker find the dynamic library, create a symlink called lib<some lib>.so to lib<some lib><version>-x,y.so if necessary (and/or for static lib; lib<some lib>.a to lib<some lib><version>-x,y.a).<br />
<br />
; '''FreeBSD''' : As source based distro's, and also make sure you have -Fl/usr/local/lib in your fpc.cfg and/or Lazarus library path. Keep in mind that GTK1.2 has "gtk12" as package name under FreeBSD. (same for glib) NOTE: This has changed as of late. Newest ports have gtk-12 and glib-12 as well. You might stumble on this problem, since FPC requires the "-less" ones, you will need to symlink them like this:<br />
<br />
[]# cd /usr/local/lib && ln -s libglib-12.so libglib12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgtk-12.so libgtk12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgdk-12.so libgdk12.so<br />
<br />
; '''NetBSD''' : As source based distro's, and also make sure you have -Fl/usr/pkg/lib in your fpc.cfg and/or Lazarus library path<br />
<br />
=== How can I convert a kylix 2 project into a lazarus project? ===<br />
<br />
Nearly the same way as converting a Kylix project into a Delphi/VCL project.<br />
<br />
The LCL (Lazarus Component Library) tries to be compatible to Delphis VCL.<br />
Kylix CLX tries to be QT compatible.<br />
Here are some general hints:<br />
<br />
* Rename all used CLX Q-units like QForms, QControls, QGraphics, ... into their VCL counterparts: Forms, Controls, Graphics, ...<br />
* Add LResources to the uses section of every form source<br />
* Rename or copy all .xfm files to .lfm files.<br />
* Rename or copy .dpr file to .lpr file.<br />
* Add "Interfaces" to the uses section in the .lpr file.<br />
* Remove {$R *.res} directive<br />
* Remove {$R *.xfm} directive<br />
* Add {$mode objfpc}{$H+} or {$mode delphi}{$H+} directive to .pas and .lpr files<br />
* Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):<br />
initialization<br />
{$I unit1.lrs}<br />
:The .lrs files can be created via the lazres tool in: (lazarusdir)/tools/lazres.<br />
:For example: ./lazres unit1.lrs unit1.lfm<br />
<br />
* Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.<br />
<br />
* To make it more platform independant, reduce unit libc (which is deprecated) references and substitute with native FPC units like baseunix/unix as much as possible. This will be necessary to support other targets than linux/x86 (including OS X, FreeBSD and Linux/x86_64)<br />
<br />
=== When compiling lazarus the compiler can not find a unit. e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB ===<br />
<br />
1. Check a clean rebuild: do a 'make clean all'<br />
<br />
2. Check if the compiler has the correct version (2.0.4 or higher)<br />
<br />
3. Check if the compiler is using the right config file. The normal installation creates /etc/fpc.cfg. But fpc also searches for ~/.ppc386.cfg, ~/.fpc.cfg, /etc/ppc386.cfg and it uses only the first it finds.<br />
<br />
:'''Hint:''' You can see which config file is used with 'ppc386 -vt bogus'<br />
:Remove any ppc386.cfg as it is really obsolete.<br />
<br />
4. Check if the config file (/etc/fpc.cfg) contains the right paths to your fpc libs. There must be three lines like this:<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*<br />
:The first part of these paths (/usr/lib/fpc) depends on your system. On some systems this can be for example /usr/local/lib/fpc/... .<br />
:'''Hint:''' You can see your searchpaths with 'ppc386 -vt bogus'<br />
<br />
5. Check that the config file (/etc/fpc.cfg) does not contain search paths to the lcl source files (.pp, .pas):<br />
forbidden: -Fu(lazarus_source_directory)/lcl<br />
forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk<br />
:If you want to add the lcl for all your fpc projects, make sure that the two paths look like the following and are placed after the above fpc lib paths:<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk<br />
<br />
6. Check if the missing unit (glib.ppu) exists in your fpc lib directory. For example the gtk.ppu can be found in /usr/lib/fpc/$fpcversion/units/i386-linux/gtk/. If it does not exists, the fpc lib is corrupt and should be reinstalled.<br />
<br />
7. Check if the sources are in a NFS mounted directory. In some cases the NFS updates created files incorrectly. Please, try to move the sources into a non NFS directory and compile there.<br />
<br />
8. If you are still not succeeded try to use samplecfg script as follows:<br />
<br />
''#'' cd /usr/lib/fpc/''version''/<br />
<br />
''#'' sudo ./samplecfg /usr/lib/fpc/''\$version'' /etc<br />
<br />
Note! Do not put - / - after etc because if you do that the system will create a file - /etc/fpc.cfg/fpc.cfg. In fact we want that samplecfg make a file - /etc/fpc.cfg - not the folder /etc/fpc.cfg.<br />
<br />
=== I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS ===<br />
<br />
Probably you are using a newer fpc package, than that used for building the<br />
lazarus binaries. The best solution is to download the sources and compile<br />
lazarus manually. You can download the source snapshot or get the source<br />
via svn:<br />
<br />
$ bash<br />
$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
Make sure that lazarus get the new source directory:<br />
Environment->General Options->Files->Lazarus Directory Top<br />
<br />
===Lazarus compiles, but linking fails with: libgdk-pixbuf not found===<br />
Install the gdk-pixbuf library for gtk1.x:<br />
<br />
Where to find the gdk-pixbuf library:<br />
<br />
RPMs:<br />
http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=<br />
<br />
Debian packages:<br />
libgdk-pixbuf-dev<br />
<br />
Sources:<br />
ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/<br />
<br />
===I have SuSE and I get /usr/bin/ld: cannot find -lgtk Error: Error while linking===<br />
SuSE installs the gtk devel libs under /opt/gnome/lib (or /opt/gnome/lib64 for 64 bits), which is not in<br />
the standard lib path. Simply add it to your /etc/fpc.cfg.<br />
(-Fl/opt/gnome/lib).<br />
<br />
===Lazarus crashes with runtime error 211 after I installed a component===<br />
After I installed a component, Lazarus crashes with the following message:<br />
Threading has been used before cthreads was initialized.<br />
Make cthreads one of the first units in your uses clause.<br />
Runtime error 211 at $0066E188<br />
How can I fix this?<br />
<br />
Your freshly installed component is using threads. FPC on *nix doesn't automatically include threading support, but it must be intialized. This initialization is done in the cthreads unit. Every application using the component needs to add this unit to the uses clause of the main program. Lazarus itself is no exception. This can be done in two ways:<br />
<br />
1) Open the package. In the package editor click on ''Options''. Under page ''Usage'' add to the ''custom'' options '''-dUseCThreads'''. Then rebuild the IDE. This way the cthreads unit will be automatically used by the IDE under unix and the cthreads are initialized.<br />
<br />
2) In order to avoid modifying package, a fpc compiler option could be used directly. Open menu Tools->Configure "build Lazarus". Configure "build Lazarus" dialog will be shown, in field "Options:" type -Facthreads and then press "OK" button. The next step is to install the package. Lazarus will be built with option -Facthreads which means that it will treat main program as if unit cthreads where first in uses clause. <br />
<br />
''Hint:'' Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.<br />
<br />
See also [[Multithreaded_Application_Tutorial#Units_needed_for_a_multithreaded_application]]<br />
<br />
===When I run a program with threads I get runtime error 232===<br />
The complete error message is:<br />
This binary has no thread support compiled in.<br />
Recompile the application with a thread-driver in the program uses<br />
clause before other units using thread.<br />
Runtime error 232<br />
'''Solution''': Add cthreads as first unit to the uses clause of your main program, usually the .lpr-file.<br />
<br />
===I have Ubuntu Breezy and my fonts in Lazarus IDE look too big===<br />
If Lazarus is compiled with Gtk1.2, the settings in Gnome Preferences/Font don't have any effect as<br />
they are related to Gtk2.<br />
You could try this solution:<br />
Create a file named .gtkrc.mine in your home directory (if it's not already there) and add<br />
these lines to it:<br />
<br />
<pre><br />
style "default-text" {<br />
fontset = "-*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\<br />
-*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"<br />
}<br />
<br />
class "GtkWidget" style "default-text"<br />
</pre><br />
<br />
If this is not enough try and create also a .gtkrc symlink to .gtkrc.mine . It worked in this way under Xubuntu 7.10.<br />
<br />
===How can my gtk programs use custom rc files?===<br />
<br />
Option a)<br />
Name the rc file ''yourprogram.gtkrc'' and put it in the same directory where the executable is.<br />
<br />
Option b)<br />
Use unit ''GtkInt'' and call ''GTKWidgetSet.SetRCFilename('your_preferred_rc_file');''<br />
Best done before ''Application.Initialize'' in the .lpr file with ''{$IFDEF LCLGtk}''.<br />
<br />
===I have Ubuntu and I cannot compile for Gtk2 due to missing libraries===<br />
Ubuntu has a problem with not creating all the symbolic links that you'll need even when the libraries are installed. Make sure that all missing libraries when trying to link for Gtk2 have their appropriate links. For instance, you might need to do:<br />
<br />
<pre><br />
cd /usr/lib<br />
sudo ln -s libgdk-x11-2.0.so.0 libgtk-x11-2.0.so<br />
</pre><br />
<br />
Make sure that the [whatever].so symbolic links are created and point to the actual libraries.<br />
<br />
===How can I compile a program for Gtk2?===<br />
<br />
At the moment, the Gtk2 compiled IDE is a little unstable, but you can compile software for Gtk2 using the Gtk1 IDE.<br />
<br />
To start with recompile LCL for Gtk2. Go to the menu "Tools"->"Configure Build Lazarus" and set LCL to clean+build and everything else to none.<br />
<br />
Now click Ok and go to the menu "Tools"->"Build Lazarus"<br />
<br />
Now you can compile your software with Gtk2 going on the Compiler options and changing the widgetset to Gtk2.<br />
<br />
===I get this message: "[WARNING] ** Multibyte character encodings (like UTF8) are not supported at the moment."===<br />
<br />
Since revision 10535 (0.9.21) this message doesn't exist anymore. <br />
Previously it was used to warn that a UTF-8 encoding was used. The internal keyhandling routines for the gtk1 widgetset couldn't handle such encoding for keypresses, with the result that keypresses with for instance accented chars were not or wrong detected.<br />
<br />
(original text for older versions of lazarus)<br><br />
<strike><br />
This warning message indicates that your locale enconding is set to utf-8. If you are using Gtk 1 this can be a serious problem and prevent the correct working of Lazarus or software created with Lazarus.<br />
<br />
To work around this, just change your locale to a non utf-8 before executing the program on the command line, like this:<br />
<br />
<pre><br />
export LC_CTYPE="pt_BR"<br />
export LANG="pt_BR"<br />
export LANGUAGE="pt_BR"<br />
./lazarus<br />
</pre><br />
<br />
Substitute pt_BR with the locale for your country. You can create a script to automate this.<br />
</strike><br />
<br />
== Windows ==<br />
<br />
=== When I cycle the compiler, I get:The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time. ===<br />
<br />
In the compiler directory there is an OS2 scriptfile named make.cmd. Different versions of Windows also see this as a script file, so remove it since what is needed for OS2 becomes a hindrance on Windows.<br />
<br />
=== When I cycle the compiler, I get: make[3]: ./ppc1.exe: Command not found ===<br />
<br />
I don't know why but somehow make has lost its path. Try to cycle with a<br />
basedir set like: make cycle BASEDIR=your_fpc_source_dir_herecompiler<br />
<br />
=== When I try to make Lazarus I get:===<br />
====make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2 ====<br />
You need to upgrade your make.<br />
<br />
====makefile:27: *** You need the GNU utils package to use this Makefile. Stop.====<br />
Make sure you didn't install FPC in a path with spaces in the name. The<br />
Makefile doesn't support it.<br />
<br />
<br />
<br />
===How can I give my program an XP look like lazarus has?===<br />
Project -> Project Options -> Check 'Use manifest to enables themes'.<br />
<br />
===When I run Windows program created in Lazarus it starts with a DOS window===<br />
Specify the -WG argument (Windows GUI) on the command line of the compiler or in the Lazarus IDE check the Windows GUI check box on the compiler options dialog box (Project menu -> Compiler Options -> Linking -> target OS Specific options.<br />
<br />
== Mac OS X ==<br />
<br />
=== Why does compiling a project fail with 'unknown section attribute: no_dead_strip'?===<br />
<br />
Dead code stripping is not supported by the assembler and linker before Xcode 1.5 (available for Mac OS X 10.3.9). Disable the compiler options <br />
<br />
*Code > Unit style > Smart linkable (-CX) <br />
*and Linking > Link Style > Link smart (-XX)<br />
<br />
== Licensing ==<br />
<br />
=== Can I make commercial applications with Lazarus ? ===<br />
<br />
Yes, the LCL is licensed under the LGPL with an exception, which allows you to link to it statically without releasing the source of your application. Modifications and enhancements to the LCL must be distributed with source. Lazarus, the IDE, is licensed under the GPL.<br />
<br />
=== Can I make commercial plug-ins for Lazarus ? ===<br />
<br />
Yes, the IDEIntf part of the IDE is licensed under the LGPL with the same exception, so that shared data structures in this part will not force you to license your plug-in or design-time package under the GPL. You are free to choose a plug-in of any license; we don't want to limit your choice. Therefore non-GPL compatible plug-ins are allowed. Note that it's not allowed to distribute a precompiled Lazarus with these non-GPL-compatible plugins included statically; however, we do not see this as a severe limitation, since recompiling Lazarus is easy.<br />
<br />
== Contributors and Comments ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq version].</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Faq/ko&diff=32434Lazarus Faq/ko2008-12-01T13:34:13Z<p>Oranke: /* 도대체 실행파일의 크기가 왜 이렇게 큰 겁니까? */</p>
<hr />
<div>{{Lazarus Faq}}<br />
<br />
이 문서는 원래 www.lazarus.freepascal.org 에 있던 것 입니다. 관리 및 확장 면에서 위키가 훨씬 더 유용하기 때문에 이 곳으로 복사되었습니다. <br />
<br />
== 일반적인 이야기 ==<br />
<br />
=== 더 많은 FAQ를 볼 수 있는 곳은 어디인가요? ===<br />
See the [http://www.lazarus.freepascal.org official website]. There is another FAQ as well.<br />
<br />
===도대체 실행파일의 크기가 왜 이렇게 큰 겁니까?===<br />
실행파일의 크기가 큰 이유는 GDB (GNU Debugger) 를 사용하기 위한 많은 정보들을 포함하고 있기 때문입니다. <br />
<br />
컴파일러에 이 디버깅 정보를 제거하기 위한 옵션 (-Xs) 이 있습니다만, 버전 2.0.2 이전의 컴파일러는 이 기능에 버그가 있기 때문에 제대로 동작하지 않습니다. 이 버그는 현재 개발버전에서는 수정되었습니다. <br />
<br />
"strip" 이라는 이름의 프로그램을 사용하면 실행파일로 부터 디버그 심볼을 삭제할 수 있습니다. 이 프로그램은 lazarus\pp\bin\i386-win32\ 에 있습니다. <br />
<br />
커맨드 라인에서 간단하게 "strip --strip-all <대상 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
실행파일을 좀 더 작게 만들려면, [http://upx.sourceforge.net/ UPX] 가 좋은 해법이 될 것입니다. UPX는 정말 멋진 실행파일 압축기 로서, 압축 해제에 추가적인 메모리가 필요없는 알고리즘을 사용합니다. (역자 주: 이 압축 알고리즘은 [http://www.oberhumer.com/opensource/lzo/ LZO] 라고 불리며, 오래 전 셀빅의 카마수트라 라는 어플에서 사용되었...^^) 또한 상당히 빠른 압축 해제 속도를 가지고 있습니다. (펜티엄 133에서 초당 10 MB 정도)<br />
<br />
커맨드 라인에서 간단하게 "upx <압축할 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
라자루스로 만든 간단한 GUI 어플리케이션의 경우 strip과 upx를 사용한 후 크기는 다음과 같습니다. <br />
* 리눅스 상에서는 ~ 700kb <br />
* 윈도우 상에서는 ~ 420kb<br />
<br />
그렇다고 UPX가 꼭 좋은 것은 아닙니다. UPX에 대한 좀 더 자세한 이야기는 [[Size Matters|크기문제]]에 대한 페이지를 참고하세요.<br />
<br />
또 한가지 주목해야 할 사실은, 라자루스의 "hello world" 프로그램은 그 자체로 이미 다음에 나열된 많은 기능들을 포함하고 있다는 것 입니다.<br />
<br />
* XML 제어 라이브러리<br />
* png, xpm, bmp 그리고 ico 파일을 다루는 이미지 라이브러리<br />
* 라자루스 컴포넌트 라이브러리의 위젯 대부분<br />
* 프리 파스칼 런타일 라이브러리 전체<br />
<br />
이런 이유로 매우 큰 크기를 가집니다만, 사실 여기에는 실제 어플리케이션이 필요로 하는 대부분의 기능들이 이미 포함되어 있습니다. <br />
<br />
라자루스 실행파일의 크기는 처음에는 매우 크지만 아주 조금씩 늘어나게 되는데, 이는 프리파스칼 컴파일러와 라자루스가 폼을 다루는 방식 때문 입니다. C++ 프로젝트의 경우 (뭐 다른 언어들도 마찬가지 입니다만) hello world 프로그램은 매우 작지만 조금만 복잡한 어플리케이션을 작성하려고 하면, 그 크기가 급격하게 늘어나게 됩니다. <br />
<br />
[[Image:Lazarus_vs_cpp.png]]<br />
<br />
=== Why is the linking so slow on Windows? ===<br />
<br />
This problem is over from FPC 2.2 and Lazarus 0.9.24. Please update your Lazarus. For older versions read text below.<br />
<br />
Generally speaking, compilation on Windows takes more time then other platforms because the GNU Linker utilized by Free Pascal is slow on this platform. This problem only affects Windows, and is only bad on relatively old computers (less then 1Ghz) and computers with little RAM (128MB or less).<br />
<br />
Also, if you smartlink LCL the linking will be much slower. A study about this is located here: [[File size and smartlinking]]<br />
<br />
A internal linker was developed, and is ready, but will only be available when Free Pascal 2.2 is released (of course it's also available via subversion). It decreases the linking time dramatically.<br />
<br />
'''Note''': In 2.1.1 Windows uses an internal linker for win32/64/ce which speeds the process up a bit. A Lazarus recompile then eats about 280MB.<br />
<br />
=== Do I need ppc386.cfg or fpc.cfg? ===<br />
<br />
You only need fpc.cfg. This way the compiler knows where to find the libraries.<br />
<br />
=== How do I compile lazarus? ===<br />
<br />
Do something like this:<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
=== How do I build other projects based upon the LCL ===<br />
<br />
If you can't use the IDE to build your applications, use lazbuild. This is a command line version of the IDE to build lazarus projects and packages.<br />
If you want to build LCL applications without the IDE and without the lazbuild, add the following lines to the end of your ''fpc.cfg''<br />
<br />
# searchpath for other toolkits (Linux)<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{YourToolKit}<br />
<br />
# searchpath for other toolkits (Windows)<br />
-Fu/{YourLazarusDirectory}/components/units/{YourToolKit}<br />
<br />
:Where {YourToolKit} may be ''gtk2'', ''gnome'', ''qt'' or ''win32'' and run:<br />
::ppc386 your.project.pp<br />
<br />
'''Hint:''' Don't forget to install the development packages for your toolkit otherwise you might a receive something like: [[Linker message: cannot find -l]].<br />
<br />
=== What version of FPC is required? ===<br />
<br />
2.0.4 for MacOSX and 2.2.2 for all other systems. Warning: The 2.2.0 has a bug under MacOSX with case sensitive filenames.<br />
You can also use the svn version of fpc 2.2.3 and 2.3.x.<br />
<br />
=== I can't compile Lazarus ===<br />
<br />
# Check if the compiler has the correct version<br />
# Check if the (fpc)libraries are from the same version.<br />
# Check if you have a fpc.cfg and no old ppc386.cfg<br />
# Check also the OS-dependent FAQs<br />
<br />
=== When I try to compile a project, I have an error ===<br />
==== "Cannot find Unit interfaces". How can I solve this?====<br />
It means the compiler can not find the file 'interfaces.ppu' '''or''' it means it found one, but it is wrong or outdated.<br />
<br />
This unit can be found in {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu. For example: /home/username/lazarus/lcl/units/i386-linux/gtk/interfaces.ppu.<br />
<br />
Make sure, it is only there. If you have multiple versions of interfaces.ppu, then you probably have a wrong configuration (for instance you added a lcl directory to a search path). Remove all interfaces.ppu, but the one in the directory above.<br />
<br />
If you selected a different widgetset than you used to build lazarus, you need to build the LCL for this widgetset. <br />
<br />
If it is there, but you get this error, you are using a different compiler / rtl for compiling your project than you used for compiling your Lazarus IDE. You can do one of the following<br />
* Rebuild the LCL (or Lazarus completely) with the compiler selected in the Environmnent Options. You can do this with Tools -> Build Lazarus. Before doing this, check the current settings in Tools -> Configure Build Lazarus.<br />
* Change the compiler in the Environment Options to the one you used to compile Lazarus. Look carefully also in the Environment Options to see if you are using the correct paths for the Lazarus Directory and the FPC sources directory. Check that there is only one version of the compiler configuration file fpc.cfg - it should reside in /etc/ for Linux/Unix systems or in the same directory as the fpc compiler for Windows systems. Try to run "fpc -vt bogus" to check which fpc.cfg is being used in your system. Rogue copies often creep in if you have updated your compiler to a new version; they may be found in your home directory or in the same directory as the one in which you built your new compiler. DELETE THESE!!<br />
* You may also try to change the widgetset currently selected for the project. For example, the sample project "objectinspector" that comes with Lazarus is set to gtk by default. Compiling this project will surely give you "Can't find unit interfaces" in Windows platform. Changing widgetset to default(Win32) in Project | Compiler Options... | LCL Widget Type (various) should fix this issue.<br />
<br />
=== When I try to compile delphi projects under lazarus, I have an error ===<br />
==== at the line :{$R *.DFM} How can I solve this problem ? ====<br />
<br />
Lazarus (or better Linux) doesn't know about resources, so you can't use them in the way Delphi/Win32 does. However Lazarus uses a method pretty compatible with this. You can still use your Delphi layouts (.dfm files) if you use the following steps:<br />
<br />
*You need a textual version of the .dfm files. D5 and higher are doing this as default. If you have older files: ALT-F12 to see the layout as text and paste/copy. When you have a text .dfm file, just copy it to a .lfm file.<br />
*Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm<br />
*Add the following initialization section to<br />
<br />
initialization<br />
{$I yourform.lrs}<br />
<br />
Please keep in mind that not all properties in the dfm are supported yet by<br />
lazarus, so you might get a crash.<br />
<br />
==== 'Identifier not found LazarusResources'. ====<br />
<br />
When creating a form Lazarus automaticaly add some extra units to the uses section of your form unit. During the conversion of a delphi unit to a Lazarus unit this does not happen. So you need to add LResources to the Uses section of your form unit.<br />
<br />
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===<br />
<br />
Make sure, in the Project -> Project Inspector, that your project depends on the package 'LCL' and that you have installed the FPC sources.<br />
<br />
Lazarus is the IDE and the visual components library LCL.<br />
All other stuff, like IO, Database, FCL and RTL are provided by FPC.<br />
The IDE needs the paths to all sources.<br />
<br />
The FPC source path can be set via:<br />
Environment -> Environment Options -> Files -> FPC source directory<br />
<br />
===How to embed a small file in the executable, without the need of a separate file? How to embed a resource?===<br />
<br />
For example:<br />
/your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...<br />
will create sound.lrs from sound1.wav and sound2.wav.<br />
<br />
Then include it *behind* the form lrs file:<br />
<br />
...<br />
initialization<br />
{$i unit1.lrs} // this is main resource file (first)<br />
{$i sound.lrs} // user defined resource file<br />
<br />
end.<br />
In your program you can then use:<br />
Sound1AsString:=LazarusResources.Find('sound1').Value;<br />
<br />
=== How can I see debug output? ===<br />
<br />
The LCL has in the LCLProc unit two procedures to write debug output. They are named: <br />
* '''DebugLn:''' which works about the same as WriteLn, but accepts only strings.<br />
* '''DbgOut:''' which works about the same as Write, but accepts only strings.<br />
<br />
In normal circumstances the output is written to stdout. If stdout is closed, (for example when the application is {$AppType Gui} or compiled with -WG on Windows), no output is written.<br />
<br />
Debug output can also be written to file. The initialization code of the LCLProc unit checks Lazarus.exe's command line parameters for '--debug-log=<file>'. On finding this parameter any subsequent debug output is sent to <file>.<br />
<br />
If no '--debug-log' command line parameter has been given, it next checks if an operating system environment variable xxx_debuglog exists, where xxx is the program file name without extension. For Lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses the file specified in the lazarus_debuglog environment variable as file to receive debug output. Example: if you do:<br />
set lazarus_debuglog=c:\lazarus\debug.txt<br />
debug output will be written to c:\lazarus\debug.txt.<br />
<br />
Since this is implemented in lclproc, every application using lclproc, can use this output facility.<br />
<br />
;Debuging Lazarus : Most useful for Windows: If you want output on a console, add {$APPTYPE console} to lazarus.pp ; Then rebuild Lazarus.<br />
<br />
=== What is the meaning of the various file extensions used by Lazarus? ===<br />
<br />
The [[Lazarus Tutorial#The Lazarus files]] explains some extensions by an example.<br />
Here is a brief list:<br />
<br />
; <code>*.lpi</code> : Lazarus Project Information file (stored in XML; contains project-specific settings)<br />
; <code>*.lpr</code> : Lazarus Program file; contains Pascal source of main program<br />
; <code>*.lfm</code> : Lazarus Form file; contains configuration information for all objects on a form (stored in a Lazarus-specific textual format; the actions are described by Pascal source code in a corresponding <code>*.pas</code> file)<br />
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code (typically for a form stored in a corresponding <code>*.lfm</code> file)<br />
; <code>*.lrs</code> : Lazarus Resource file (this is a generated file; not to be confused with a Windows resource file). <br />
: This file can be created with lazres tool (in directory Lazarus/Tools) using commandline: lazres myfile.lrs myfile.lfm<br />
; <code>*.ppu</code> : Compiled unit<br />
; <code>*.lpk</code> : Lazarus package information file. (stored in XML; contains package-specific settings)<br />
<br />
=== I have fixed/improved lazarus. How can I add my changes to the official lazarus source? ===<br />
Create a patch and send it to the developers. For details see [[Creating A Patch]].<br />
=== When I do ''var mytext: text;'' to declare a text file, I get "Unit1.pas(32,15) Error: Error in type definition". How can I fix this?===<br />
The TControl class has a [[doc:lcl/controls/tcontrol.text.html|Text]] property. In a method of a form, that has higher visibility, the [[doc:rtl/system/text.html|Text]] type from the system unit. You can use the [[doc:rtl/system/textfile.html|TextFile]] type, which is just an alias for the Text type or you can add the unit to the type definition.<br />
var<br />
MyTextFile: TextFile;<br />
MyText: System.Text;<br />
A similar name clash exists with assigning and closing a text file. TForm has a ''assign'' and a [[doc:lcl/forms/tcustomform.close.html|Close]] method. You can use [[doc:rtl/objpas/assignfile.html|AssignFile]] and [[doc:rtl/objpas/closefile.html|CloseFile]] or add the unit name ''System''.<br />
<br />
=== I get an error when using Printer.BeginDoc ===<br />
<br />
The unit Printers must be added to the uses section.<br />
<br />
The Printer4Lazarus package must be added to your project requirement in the IDE under:<br />
Project|Project Inspector|Add|New Requirement|Package Name:<br />
<br />
If the package Printer4Lazarus package is not in the list when opening the dropdown box it must be installed. The package is part of the Lazarus installation and can be found in:<br />
[lazarus installed directory]\components\printers<br />
<br />
If you used the default installation directories [lazarus installed directory] is:<br />
*Windows: c:\lazarus <br />
*Linux: /usr/lib/lazarus<br />
<br />
The same solution also applies to the exception you can get when referencing Printer.Printers<br />
<br />
=== Why are TForm.ClientWidth/ClientHeight the same as TForm.Width/Height ===<br />
<br />
The TForm.Width/Height do no include the frame, because there was no way to retrieve the frame size on all platforms. Without a reliable way, the LCL would move the forms around on the screen or resize them endlessly.<br />
<br />
Eventually when there is a reliable way to get the size and position of a window with its frame on all platforms, then it will be changed. To keep compatibility with older LCL forms, a version number and some extra methods will be added.<br />
<br />
=== I created a Patch to dock the IDE Messages form on the "Source Code Editor" form (at bottom) ===<br />
<br />
Such patches will not be applied, because they only implement a small part of the needed docking. The goal is to create a complete dock manager and use that. A complete dock manager can dock all IDE windows and it allows to let the user define how to dock. For example dock the messages window above or below the source editor or ... or not at all. For instance:<br />
<br />
<pre><br />
+-------------------++--+<br />
|menu || |<br />
+-------------------+| |<br />
+--++---------------+| |<br />
|PI|| Source Editor ||CE|<br />
+--+| || |<br />
+--+| || |<br />
| |+---------------++--+<br />
|OI|+-------------------+<br />
| ||messages |<br />
+--++-------------------+<br />
</pre><br />
<br />
The dock manager can store the layout and restore it on next load. Preferably the dock manager can dock in pages too. The dock manager does not need to use drag and drop.<br />
All patches implementing docking without a dock manager makes it harder to implement a real dock manager and will be rejected.<br />
<br />
=== How can I become a developer lazarus and access management in the SVN and bug-tracker? ===<br />
<br />
First of all: you must learn about Lazarus, to prove your knowledge and skill.<br />
Start by reading the [[Lazarus_Documentation|wiki articles]], read the Lazarus source code, giving a look at the [http://www.lazarus.freepascal.org/mantis Lazarus Bug-Tracker], fix some bugs, and if you think you are ready, contact the developers on the [http://www.mail-archive.com/lazarus@miraclec.com mailing list].<br />
<br />
== Where is ... defined ==<br />
<br />
=== Virtual key constants ===<br />
Virtual key constants are defined in LCLType. Add LCLtype to your <b>uses</b>.<br />
<br />
== Using the IDE ==<br />
<br />
=== How can I use "identifier completion"? ===<br />
You can invoke identifier completion by pressing [ctrl][space].<br />
Under the menu item ''Environment -> Editor Options -> Code Tools -> Automatic Features'' you can set how quick this should happen automatically.<br />
<br />
== Linux ==<br />
<br />
=== How can I debug on Linux without the IDE? ===<br />
<br />
First of all you need a debugger. gdb is the standard debugger under linux and<br />
there are several GUI-frontends available. One common frontend is ddd, which is<br />
part of most common distributions. To compile lazarus/lcl with debug-information<br />
you should then use the following commands to start a debug session:<br />
<br />
$ make clean; make OPT=-dDEBUG<br />
$ ddd lazarus<br />
<br />
Be warned however, that ddd is not as comfortable as e.g. the Lazarus debugger.<br />
Specially if it comes to view the contents of a variable you have to take into<br />
account that ddd/gdb are case sensitive whereas Pascal is case-insensitive.<br />
Therefore you have to type all variable names in uppercase to see their<br />
contents. For more information take a look into the fpc-manuals.<br />
<br />
=== I can debug now but ddd does not find my sources or complains that they contain no code. Whats that? ===<br />
<br />
This is a path-related problem with either gdb or ddd. You can aviod this by<br />
<br />
* Use the "Change directory" command from the ddd menu and choose the directory where the sources are located. The drawback of this method is that you now can't use the source of the program you started with (e.g. lazarus). Thus it may be neccessary to change the directory multiple times.<br />
* In ddd goto [Edit] [gdb-settings] and set the search-path<br />
* Create a $(HOME)/.gdbinit file like:<br />
directory /your/path/to/lazarus<br />
directory /your/path/to/lazarus/lcl<br />
directory /your/path/to/lazarus/lcl/include<br />
<br />
=== I receive an error during the linking that states /usr/bin/ld can't find -l<some lib> ===<br />
<br />
; '''Package Based Distributions''' : You need to install the package that provides the lib<somelib>.so or lib<somelib>.a files. Dynamic libs under linux have the extension .so, while static libs have the extension .a. On some Linux distro's you have installed the package (rpm, deb) <packagename> which provides <some lib>, but you also need the development package (rpm, deb), normally called <packagename>-dev, which contains the .a (static lib) and/or the .so (dynamic lib). <br />
: Some distributions have commands to find which package contains a file:<br />
: '''Mandriva'''<br />
<br />
[]$ urpmf lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -devel<br />
<br />
: '''Debian'''<br />
<br />
:install the apt-file utility (apt-get install apt-file) then<br />
<br />
[]$ apt-file search lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -dev<br />
<br />
<br />
<br />
; '''Source Based Distributions and Manual Compilation (LFS)''' : Make sure that there is a lib<somelib>.a in the path, and that it contains the right version. To let the linker find the dynamic library, create a symlink called lib<some lib>.so to lib<some lib><version>-x,y.so if necessary (and/or for static lib; lib<some lib>.a to lib<some lib><version>-x,y.a).<br />
<br />
; '''FreeBSD''' : As source based distro's, and also make sure you have -Fl/usr/local/lib in your fpc.cfg and/or Lazarus library path. Keep in mind that GTK1.2 has "gtk12" as package name under FreeBSD. (same for glib) NOTE: This has changed as of late. Newest ports have gtk-12 and glib-12 as well. You might stumble on this problem, since FPC requires the "-less" ones, you will need to symlink them like this:<br />
<br />
[]# cd /usr/local/lib && ln -s libglib-12.so libglib12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgtk-12.so libgtk12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgdk-12.so libgdk12.so<br />
<br />
; '''NetBSD''' : As source based distro's, and also make sure you have -Fl/usr/pkg/lib in your fpc.cfg and/or Lazarus library path<br />
<br />
=== How can I convert a kylix 2 project into a lazarus project? ===<br />
<br />
Nearly the same way as converting a Kylix project into a Delphi/VCL project.<br />
<br />
The LCL (Lazarus Component Library) tries to be compatible to Delphis VCL.<br />
Kylix CLX tries to be QT compatible.<br />
Here are some general hints:<br />
<br />
* Rename all used CLX Q-units like QForms, QControls, QGraphics, ... into their VCL counterparts: Forms, Controls, Graphics, ...<br />
* Add LResources to the uses section of every form source<br />
* Rename or copy all .xfm files to .lfm files.<br />
* Rename or copy .dpr file to .lpr file.<br />
* Add "Interfaces" to the uses section in the .lpr file.<br />
* Remove {$R *.res} directive<br />
* Remove {$R *.xfm} directive<br />
* Add {$mode objfpc}{$H+} or {$mode delphi}{$H+} directive to .pas and .lpr files<br />
* Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):<br />
initialization<br />
{$I unit1.lrs}<br />
:The .lrs files can be created via the lazres tool in: (lazarusdir)/tools/lazres.<br />
:For example: ./lazres unit1.lrs unit1.lfm<br />
<br />
* Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.<br />
<br />
* To make it more platform independant, reduce unit libc (which is deprecated) references and substitute with native FPC units like baseunix/unix as much as possible. This will be necessary to support other targets than linux/x86 (including OS X, FreeBSD and Linux/x86_64)<br />
<br />
=== When compiling lazarus the compiler can not find a unit. e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB ===<br />
<br />
1. Check a clean rebuild: do a 'make clean all'<br />
<br />
2. Check if the compiler has the correct version (2.0.4 or higher)<br />
<br />
3. Check if the compiler is using the right config file. The normal installation creates /etc/fpc.cfg. But fpc also searches for ~/.ppc386.cfg, ~/.fpc.cfg, /etc/ppc386.cfg and it uses only the first it finds.<br />
<br />
:'''Hint:''' You can see which config file is used with 'ppc386 -vt bogus'<br />
:Remove any ppc386.cfg as it is really obsolete.<br />
<br />
4. Check if the config file (/etc/fpc.cfg) contains the right paths to your fpc libs. There must be three lines like this:<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*<br />
:The first part of these paths (/usr/lib/fpc) depends on your system. On some systems this can be for example /usr/local/lib/fpc/... .<br />
:'''Hint:''' You can see your searchpaths with 'ppc386 -vt bogus'<br />
<br />
5. Check that the config file (/etc/fpc.cfg) does not contain search paths to the lcl source files (.pp, .pas):<br />
forbidden: -Fu(lazarus_source_directory)/lcl<br />
forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk<br />
:If you want to add the lcl for all your fpc projects, make sure that the two paths look like the following and are placed after the above fpc lib paths:<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk<br />
<br />
6. Check if the missing unit (glib.ppu) exists in your fpc lib directory. For example the gtk.ppu can be found in /usr/lib/fpc/$fpcversion/units/i386-linux/gtk/. If it does not exists, the fpc lib is corrupt and should be reinstalled.<br />
<br />
7. Check if the sources are in a NFS mounted directory. In some cases the NFS updates created files incorrectly. Please, try to move the sources into a non NFS directory and compile there.<br />
<br />
8. If you are still not succeeded try to use samplecfg script as follows:<br />
<br />
''#'' cd /usr/lib/fpc/''version''/<br />
<br />
''#'' sudo ./samplecfg /usr/lib/fpc/''\$version'' /etc<br />
<br />
Note! Do not put - / - after etc because if you do that the system will create a file - /etc/fpc.cfg/fpc.cfg. In fact we want that samplecfg make a file - /etc/fpc.cfg - not the folder /etc/fpc.cfg.<br />
<br />
=== I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS ===<br />
<br />
Probably you are using a newer fpc package, than that used for building the<br />
lazarus binaries. The best solution is to download the sources and compile<br />
lazarus manually. You can download the source snapshot or get the source<br />
via svn:<br />
<br />
$ bash<br />
$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
Make sure that lazarus get the new source directory:<br />
Environment->General Options->Files->Lazarus Directory Top<br />
<br />
===Lazarus compiles, but linking fails with: libgdk-pixbuf not found===<br />
Install the gdk-pixbuf library for gtk1.x:<br />
<br />
Where to find the gdk-pixbuf library:<br />
<br />
RPMs:<br />
http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=<br />
<br />
Debian packages:<br />
libgdk-pixbuf-dev<br />
<br />
Sources:<br />
ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/<br />
<br />
===I have SuSE and I get /usr/bin/ld: cannot find -lgtk Error: Error while linking===<br />
SuSE installs the gtk devel libs under /opt/gnome/lib (or /opt/gnome/lib64 for 64 bits), which is not in<br />
the standard lib path. Simply add it to your /etc/fpc.cfg.<br />
(-Fl/opt/gnome/lib).<br />
<br />
===Lazarus crashes with runtime error 211 after I installed a component===<br />
After I installed a component, Lazarus crashes with the following message:<br />
Threading has been used before cthreads was initialized.<br />
Make cthreads one of the first units in your uses clause.<br />
Runtime error 211 at $0066E188<br />
How can I fix this?<br />
<br />
Your freshly installed component is using threads. FPC on *nix doesn't automatically include threading support, but it must be intialized. This initialization is done in the cthreads unit. Every application using the component needs to add this unit to the uses clause of the main program. Lazarus itself is no exception. This can be done in two ways:<br />
<br />
1) Open the package. In the package editor click on ''Options''. Under page ''Usage'' add to the ''custom'' options '''-dUseCThreads'''. Then rebuild the IDE. This way the cthreads unit will be automatically used by the IDE under unix and the cthreads are initialized.<br />
<br />
2) In order to avoid modifying package, a fpc compiler option could be used directly. Open menu Tools->Configure "build Lazarus". Configure "build Lazarus" dialog will be shown, in field "Options:" type -Facthreads and then press "OK" button. The next step is to install the package. Lazarus will be built with option -Facthreads which means that it will treat main program as if unit cthreads where first in uses clause. <br />
<br />
''Hint:'' Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.<br />
<br />
See also [[Multithreaded_Application_Tutorial#Units_needed_for_a_multithreaded_application]]<br />
<br />
===When I run a program with threads I get runtime error 232===<br />
The complete error message is:<br />
This binary has no thread support compiled in.<br />
Recompile the application with a thread-driver in the program uses<br />
clause before other units using thread.<br />
Runtime error 232<br />
'''Solution''': Add cthreads as first unit to the uses clause of your main program, usually the .lpr-file.<br />
<br />
===I have Ubuntu Breezy and my fonts in Lazarus IDE look too big===<br />
If Lazarus is compiled with Gtk1.2, the settings in Gnome Preferences/Font don't have any effect as<br />
they are related to Gtk2.<br />
You could try this solution:<br />
Create a file named .gtkrc.mine in your home directory (if it's not already there) and add<br />
these lines to it:<br />
<br />
<pre><br />
style "default-text" {<br />
fontset = "-*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\<br />
-*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"<br />
}<br />
<br />
class "GtkWidget" style "default-text"<br />
</pre><br />
<br />
If this is not enough try and create also a .gtkrc symlink to .gtkrc.mine . It worked in this way under Xubuntu 7.10.<br />
<br />
===How can my gtk programs use custom rc files?===<br />
<br />
Option a)<br />
Name the rc file ''yourprogram.gtkrc'' and put it in the same directory where the executable is.<br />
<br />
Option b)<br />
Use unit ''GtkInt'' and call ''GTKWidgetSet.SetRCFilename('your_preferred_rc_file');''<br />
Best done before ''Application.Initialize'' in the .lpr file with ''{$IFDEF LCLGtk}''.<br />
<br />
===I have Ubuntu and I cannot compile for Gtk2 due to missing libraries===<br />
Ubuntu has a problem with not creating all the symbolic links that you'll need even when the libraries are installed. Make sure that all missing libraries when trying to link for Gtk2 have their appropriate links. For instance, you might need to do:<br />
<br />
<pre><br />
cd /usr/lib<br />
sudo ln -s libgdk-x11-2.0.so.0 libgtk-x11-2.0.so<br />
</pre><br />
<br />
Make sure that the [whatever].so symbolic links are created and point to the actual libraries.<br />
<br />
===How can I compile a program for Gtk2?===<br />
<br />
At the moment, the Gtk2 compiled IDE is a little unstable, but you can compile software for Gtk2 using the Gtk1 IDE.<br />
<br />
To start with recompile LCL for Gtk2. Go to the menu "Tools"->"Configure Build Lazarus" and set LCL to clean+build and everything else to none.<br />
<br />
Now click Ok and go to the menu "Tools"->"Build Lazarus"<br />
<br />
Now you can compile your software with Gtk2 going on the Compiler options and changing the widgetset to Gtk2.<br />
<br />
===I get this message: "[WARNING] ** Multibyte character encodings (like UTF8) are not supported at the moment."===<br />
<br />
Since revision 10535 (0.9.21) this message doesn't exist anymore. <br />
Previously it was used to warn that a UTF-8 encoding was used. The internal keyhandling routines for the gtk1 widgetset couldn't handle such encoding for keypresses, with the result that keypresses with for instance accented chars were not or wrong detected.<br />
<br />
(original text for older versions of lazarus)<br><br />
<strike><br />
This warning message indicates that your locale enconding is set to utf-8. If you are using Gtk 1 this can be a serious problem and prevent the correct working of Lazarus or software created with Lazarus.<br />
<br />
To work around this, just change your locale to a non utf-8 before executing the program on the command line, like this:<br />
<br />
<pre><br />
export LC_CTYPE="pt_BR"<br />
export LANG="pt_BR"<br />
export LANGUAGE="pt_BR"<br />
./lazarus<br />
</pre><br />
<br />
Substitute pt_BR with the locale for your country. You can create a script to automate this.<br />
</strike><br />
<br />
== Windows ==<br />
<br />
=== When I cycle the compiler, I get:The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time. ===<br />
<br />
In the compiler directory there is an OS2 scriptfile named make.cmd. Different versions of Windows also see this as a script file, so remove it since what is needed for OS2 becomes a hindrance on Windows.<br />
<br />
=== When I cycle the compiler, I get: make[3]: ./ppc1.exe: Command not found ===<br />
<br />
I don't know why but somehow make has lost its path. Try to cycle with a<br />
basedir set like: make cycle BASEDIR=your_fpc_source_dir_herecompiler<br />
<br />
=== When I try to make Lazarus I get:===<br />
====make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2 ====<br />
You need to upgrade your make.<br />
<br />
====makefile:27: *** You need the GNU utils package to use this Makefile. Stop.====<br />
Make sure you didn't install FPC in a path with spaces in the name. The<br />
Makefile doesn't support it.<br />
<br />
<br />
<br />
===How can I give my program an XP look like lazarus has?===<br />
Project -> Project Options -> Check 'Use manifest to enables themes'.<br />
<br />
===When I run Windows program created in Lazarus it starts with a DOS window===<br />
Specify the -WG argument (Windows GUI) on the command line of the compiler or in the Lazarus IDE check the Windows GUI check box on the compiler options dialog box (Project menu -> Compiler Options -> Linking -> target OS Specific options.<br />
<br />
== Mac OS X ==<br />
<br />
=== Why does compiling a project fail with 'unknown section attribute: no_dead_strip'?===<br />
<br />
Dead code stripping is not supported by the assembler and linker before Xcode 1.5 (available for Mac OS X 10.3.9). Disable the compiler options <br />
<br />
*Code > Unit style > Smart linkable (-CX) <br />
*and Linking > Link Style > Link smart (-XX)<br />
<br />
== Licensing ==<br />
<br />
=== Can I make commercial applications with Lazarus ? ===<br />
<br />
Yes, the LCL is licensed under the LGPL with an exception, which allows you to link to it statically without releasing the source of your application. Modifications and enhancements to the LCL must be distributed with source. Lazarus, the IDE, is licensed under the GPL.<br />
<br />
=== Can I make commercial plug-ins for Lazarus ? ===<br />
<br />
Yes, the IDEIntf part of the IDE is licensed under the LGPL with the same exception, so that shared data structures in this part will not force you to license your plug-in or design-time package under the GPL. You are free to choose a plug-in of any license; we don't want to limit your choice. Therefore non-GPL compatible plug-ins are allowed. Note that it's not allowed to distribute a precompiled Lazarus with these non-GPL-compatible plugins included statically; however, we do not see this as a severe limitation, since recompiling Lazarus is easy.<br />
<br />
== Contributors and Comments ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq version].</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Faq/ko&diff=32433Lazarus Faq/ko2008-12-01T13:22:33Z<p>Oranke: /* 도대체 실행파일의 크기가 왜 이렇게 큰 겁니까? */</p>
<hr />
<div>{{Lazarus Faq}}<br />
<br />
이 문서는 원래 www.lazarus.freepascal.org 에 있던 것 입니다. 관리 및 확장 면에서 위키가 훨씬 더 유용하기 때문에 이 곳으로 복사되었습니다. <br />
<br />
== 일반적인 이야기 ==<br />
<br />
=== 더 많은 FAQ를 볼 수 있는 곳은 어디인가요? ===<br />
See the [http://www.lazarus.freepascal.org official website]. There is another FAQ as well.<br />
<br />
===도대체 실행파일의 크기가 왜 이렇게 큰 겁니까?===<br />
실행파일의 크기가 큰 이유는 GDB (GNU Debugger) 를 사용하기 위한 많은 정보들을 포함하고 있기 때문입니다. <br />
<br />
컴파일러에 이 디버깅 정보를 제거하기 위한 옵션 (-Xs) 이 있습니다만, 버전 2.0.2 이전의 컴파일러는 이 기능에 버그가 있기 때문에 제대로 동작하지 않습니다. 이 버그는 현재 개발버전에서는 수정되었습니다. <br />
<br />
"strip" 이라는 이름의 프로그램을 사용하면 실행파일로 부터 디버그 심볼을 삭제할 수 있습니다. 이 프로그램은 lazarus\pp\bin\i386-win32\ 에 있습니다. <br />
<br />
커맨드 라인에서 간단하게 "strip --strip-all <대상 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
실행파일을 좀 더 작게 만들려면, [http://upx.sourceforge.net/ UPX] 가 좋은 해법이 될 것입니다. UPX는 정말 멋진 실행파일 압축기 로서, 압축 해제에 추가적인 메모리가 필요없는 알고리즘을 사용합니다. (역자 주: 이 압축 알고리즘은 [http://www.oberhumer.com/opensource/lzo/ LZO] 라고 불리며, 오래 전 셀빅의 카마수트라 라는 어플에서 사용되었...^^) 또한 상당히 빠른 압축 해제 속도를 가지고 있습니다. (펜티엄 133에서 초당 10 MB 정도)<br />
<br />
커맨드 라인에서 간단하게 "upx <압축할 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
라자루스로 만든 간단한 GUI 어플리케이션의 경우 strip과 upx를 사용한 후 크기는 다음과 같습니다. <br />
* 리눅스 상에서는 ~ 700kb <br />
* 윈도우 상에서는 ~ 420kb<br />
<br />
그렇다고 UPX가 꼭 좋은 것은 아닙니다. UPX에 대한 좀 더 자세한 이야기는 [[Size Matters|크기문제]]에 대한 페이지를 참고하세요.<br />
<br />
It's also important to note that the hello world lazarus software already includes a huge amount of features. It includes:<br />
<br />
* XML 제어 라이브러리<br />
* png, xpm, bmp 그리고 ico 파일을 다루는 이미지 라이브러리<br />
* 라자루스 컴포넌트 라이브러리의 위젯 대부분<br />
* 프리 파스칼 런타일 라이브러리 전체<br />
<br />
이런 이유로 매우 큰 크기를 가집니다만, 사실 여기에는 실제 어플리케이션이 필요로 하는 대부분의 기능들이 이미 포함되어 있습니다. <br />
<br />
라자루스 실행파일의 크기는 처음에는 매우 크지만 아주 조금씩 늘어나게 되는데, 이는 프리파스칼 컴파일러와 라자루스가 폼을 다루는 방식 때문 입니다. C++ 프로젝트의 경우 (뭐 다른 언어들도 마찬가지 입니다만) hello world 프로그램은 매우 작지만 조금만 복잡한 어플리케이션을 작성하려고 하면, 그 크기가 급격하게 늘어나게 됩니다. <br />
<br />
[[Image:Lazarus_vs_cpp.png]]<br />
<br />
=== Why is the linking so slow on Windows? ===<br />
<br />
This problem is over from FPC 2.2 and Lazarus 0.9.24. Please update your Lazarus. For older versions read text below.<br />
<br />
Generally speaking, compilation on Windows takes more time then other platforms because the GNU Linker utilized by Free Pascal is slow on this platform. This problem only affects Windows, and is only bad on relatively old computers (less then 1Ghz) and computers with little RAM (128MB or less).<br />
<br />
Also, if you smartlink LCL the linking will be much slower. A study about this is located here: [[File size and smartlinking]]<br />
<br />
A internal linker was developed, and is ready, but will only be available when Free Pascal 2.2 is released (of course it's also available via subversion). It decreases the linking time dramatically.<br />
<br />
'''Note''': In 2.1.1 Windows uses an internal linker for win32/64/ce which speeds the process up a bit. A Lazarus recompile then eats about 280MB.<br />
<br />
=== Do I need ppc386.cfg or fpc.cfg? ===<br />
<br />
You only need fpc.cfg. This way the compiler knows where to find the libraries.<br />
<br />
=== How do I compile lazarus? ===<br />
<br />
Do something like this:<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
=== How do I build other projects based upon the LCL ===<br />
<br />
If you can't use the IDE to build your applications, use lazbuild. This is a command line version of the IDE to build lazarus projects and packages.<br />
If you want to build LCL applications without the IDE and without the lazbuild, add the following lines to the end of your ''fpc.cfg''<br />
<br />
# searchpath for other toolkits (Linux)<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{YourToolKit}<br />
<br />
# searchpath for other toolkits (Windows)<br />
-Fu/{YourLazarusDirectory}/components/units/{YourToolKit}<br />
<br />
:Where {YourToolKit} may be ''gtk2'', ''gnome'', ''qt'' or ''win32'' and run:<br />
::ppc386 your.project.pp<br />
<br />
'''Hint:''' Don't forget to install the development packages for your toolkit otherwise you might a receive something like: [[Linker message: cannot find -l]].<br />
<br />
=== What version of FPC is required? ===<br />
<br />
2.0.4 for MacOSX and 2.2.2 for all other systems. Warning: The 2.2.0 has a bug under MacOSX with case sensitive filenames.<br />
You can also use the svn version of fpc 2.2.3 and 2.3.x.<br />
<br />
=== I can't compile Lazarus ===<br />
<br />
# Check if the compiler has the correct version<br />
# Check if the (fpc)libraries are from the same version.<br />
# Check if you have a fpc.cfg and no old ppc386.cfg<br />
# Check also the OS-dependent FAQs<br />
<br />
=== When I try to compile a project, I have an error ===<br />
==== "Cannot find Unit interfaces". How can I solve this?====<br />
It means the compiler can not find the file 'interfaces.ppu' '''or''' it means it found one, but it is wrong or outdated.<br />
<br />
This unit can be found in {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu. For example: /home/username/lazarus/lcl/units/i386-linux/gtk/interfaces.ppu.<br />
<br />
Make sure, it is only there. If you have multiple versions of interfaces.ppu, then you probably have a wrong configuration (for instance you added a lcl directory to a search path). Remove all interfaces.ppu, but the one in the directory above.<br />
<br />
If you selected a different widgetset than you used to build lazarus, you need to build the LCL for this widgetset. <br />
<br />
If it is there, but you get this error, you are using a different compiler / rtl for compiling your project than you used for compiling your Lazarus IDE. You can do one of the following<br />
* Rebuild the LCL (or Lazarus completely) with the compiler selected in the Environmnent Options. You can do this with Tools -> Build Lazarus. Before doing this, check the current settings in Tools -> Configure Build Lazarus.<br />
* Change the compiler in the Environment Options to the one you used to compile Lazarus. Look carefully also in the Environment Options to see if you are using the correct paths for the Lazarus Directory and the FPC sources directory. Check that there is only one version of the compiler configuration file fpc.cfg - it should reside in /etc/ for Linux/Unix systems or in the same directory as the fpc compiler for Windows systems. Try to run "fpc -vt bogus" to check which fpc.cfg is being used in your system. Rogue copies often creep in if you have updated your compiler to a new version; they may be found in your home directory or in the same directory as the one in which you built your new compiler. DELETE THESE!!<br />
* You may also try to change the widgetset currently selected for the project. For example, the sample project "objectinspector" that comes with Lazarus is set to gtk by default. Compiling this project will surely give you "Can't find unit interfaces" in Windows platform. Changing widgetset to default(Win32) in Project | Compiler Options... | LCL Widget Type (various) should fix this issue.<br />
<br />
=== When I try to compile delphi projects under lazarus, I have an error ===<br />
==== at the line :{$R *.DFM} How can I solve this problem ? ====<br />
<br />
Lazarus (or better Linux) doesn't know about resources, so you can't use them in the way Delphi/Win32 does. However Lazarus uses a method pretty compatible with this. You can still use your Delphi layouts (.dfm files) if you use the following steps:<br />
<br />
*You need a textual version of the .dfm files. D5 and higher are doing this as default. If you have older files: ALT-F12 to see the layout as text and paste/copy. When you have a text .dfm file, just copy it to a .lfm file.<br />
*Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm<br />
*Add the following initialization section to<br />
<br />
initialization<br />
{$I yourform.lrs}<br />
<br />
Please keep in mind that not all properties in the dfm are supported yet by<br />
lazarus, so you might get a crash.<br />
<br />
==== 'Identifier not found LazarusResources'. ====<br />
<br />
When creating a form Lazarus automaticaly add some extra units to the uses section of your form unit. During the conversion of a delphi unit to a Lazarus unit this does not happen. So you need to add LResources to the Uses section of your form unit.<br />
<br />
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===<br />
<br />
Make sure, in the Project -> Project Inspector, that your project depends on the package 'LCL' and that you have installed the FPC sources.<br />
<br />
Lazarus is the IDE and the visual components library LCL.<br />
All other stuff, like IO, Database, FCL and RTL are provided by FPC.<br />
The IDE needs the paths to all sources.<br />
<br />
The FPC source path can be set via:<br />
Environment -> Environment Options -> Files -> FPC source directory<br />
<br />
===How to embed a small file in the executable, without the need of a separate file? How to embed a resource?===<br />
<br />
For example:<br />
/your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...<br />
will create sound.lrs from sound1.wav and sound2.wav.<br />
<br />
Then include it *behind* the form lrs file:<br />
<br />
...<br />
initialization<br />
{$i unit1.lrs} // this is main resource file (first)<br />
{$i sound.lrs} // user defined resource file<br />
<br />
end.<br />
In your program you can then use:<br />
Sound1AsString:=LazarusResources.Find('sound1').Value;<br />
<br />
=== How can I see debug output? ===<br />
<br />
The LCL has in the LCLProc unit two procedures to write debug output. They are named: <br />
* '''DebugLn:''' which works about the same as WriteLn, but accepts only strings.<br />
* '''DbgOut:''' which works about the same as Write, but accepts only strings.<br />
<br />
In normal circumstances the output is written to stdout. If stdout is closed, (for example when the application is {$AppType Gui} or compiled with -WG on Windows), no output is written.<br />
<br />
Debug output can also be written to file. The initialization code of the LCLProc unit checks Lazarus.exe's command line parameters for '--debug-log=<file>'. On finding this parameter any subsequent debug output is sent to <file>.<br />
<br />
If no '--debug-log' command line parameter has been given, it next checks if an operating system environment variable xxx_debuglog exists, where xxx is the program file name without extension. For Lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses the file specified in the lazarus_debuglog environment variable as file to receive debug output. Example: if you do:<br />
set lazarus_debuglog=c:\lazarus\debug.txt<br />
debug output will be written to c:\lazarus\debug.txt.<br />
<br />
Since this is implemented in lclproc, every application using lclproc, can use this output facility.<br />
<br />
;Debuging Lazarus : Most useful for Windows: If you want output on a console, add {$APPTYPE console} to lazarus.pp ; Then rebuild Lazarus.<br />
<br />
=== What is the meaning of the various file extensions used by Lazarus? ===<br />
<br />
The [[Lazarus Tutorial#The Lazarus files]] explains some extensions by an example.<br />
Here is a brief list:<br />
<br />
; <code>*.lpi</code> : Lazarus Project Information file (stored in XML; contains project-specific settings)<br />
; <code>*.lpr</code> : Lazarus Program file; contains Pascal source of main program<br />
; <code>*.lfm</code> : Lazarus Form file; contains configuration information for all objects on a form (stored in a Lazarus-specific textual format; the actions are described by Pascal source code in a corresponding <code>*.pas</code> file)<br />
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code (typically for a form stored in a corresponding <code>*.lfm</code> file)<br />
; <code>*.lrs</code> : Lazarus Resource file (this is a generated file; not to be confused with a Windows resource file). <br />
: This file can be created with lazres tool (in directory Lazarus/Tools) using commandline: lazres myfile.lrs myfile.lfm<br />
; <code>*.ppu</code> : Compiled unit<br />
; <code>*.lpk</code> : Lazarus package information file. (stored in XML; contains package-specific settings)<br />
<br />
=== I have fixed/improved lazarus. How can I add my changes to the official lazarus source? ===<br />
Create a patch and send it to the developers. For details see [[Creating A Patch]].<br />
=== When I do ''var mytext: text;'' to declare a text file, I get "Unit1.pas(32,15) Error: Error in type definition". How can I fix this?===<br />
The TControl class has a [[doc:lcl/controls/tcontrol.text.html|Text]] property. In a method of a form, that has higher visibility, the [[doc:rtl/system/text.html|Text]] type from the system unit. You can use the [[doc:rtl/system/textfile.html|TextFile]] type, which is just an alias for the Text type or you can add the unit to the type definition.<br />
var<br />
MyTextFile: TextFile;<br />
MyText: System.Text;<br />
A similar name clash exists with assigning and closing a text file. TForm has a ''assign'' and a [[doc:lcl/forms/tcustomform.close.html|Close]] method. You can use [[doc:rtl/objpas/assignfile.html|AssignFile]] and [[doc:rtl/objpas/closefile.html|CloseFile]] or add the unit name ''System''.<br />
<br />
=== I get an error when using Printer.BeginDoc ===<br />
<br />
The unit Printers must be added to the uses section.<br />
<br />
The Printer4Lazarus package must be added to your project requirement in the IDE under:<br />
Project|Project Inspector|Add|New Requirement|Package Name:<br />
<br />
If the package Printer4Lazarus package is not in the list when opening the dropdown box it must be installed. The package is part of the Lazarus installation and can be found in:<br />
[lazarus installed directory]\components\printers<br />
<br />
If you used the default installation directories [lazarus installed directory] is:<br />
*Windows: c:\lazarus <br />
*Linux: /usr/lib/lazarus<br />
<br />
The same solution also applies to the exception you can get when referencing Printer.Printers<br />
<br />
=== Why are TForm.ClientWidth/ClientHeight the same as TForm.Width/Height ===<br />
<br />
The TForm.Width/Height do no include the frame, because there was no way to retrieve the frame size on all platforms. Without a reliable way, the LCL would move the forms around on the screen or resize them endlessly.<br />
<br />
Eventually when there is a reliable way to get the size and position of a window with its frame on all platforms, then it will be changed. To keep compatibility with older LCL forms, a version number and some extra methods will be added.<br />
<br />
=== I created a Patch to dock the IDE Messages form on the "Source Code Editor" form (at bottom) ===<br />
<br />
Such patches will not be applied, because they only implement a small part of the needed docking. The goal is to create a complete dock manager and use that. A complete dock manager can dock all IDE windows and it allows to let the user define how to dock. For example dock the messages window above or below the source editor or ... or not at all. For instance:<br />
<br />
<pre><br />
+-------------------++--+<br />
|menu || |<br />
+-------------------+| |<br />
+--++---------------+| |<br />
|PI|| Source Editor ||CE|<br />
+--+| || |<br />
+--+| || |<br />
| |+---------------++--+<br />
|OI|+-------------------+<br />
| ||messages |<br />
+--++-------------------+<br />
</pre><br />
<br />
The dock manager can store the layout and restore it on next load. Preferably the dock manager can dock in pages too. The dock manager does not need to use drag and drop.<br />
All patches implementing docking without a dock manager makes it harder to implement a real dock manager and will be rejected.<br />
<br />
=== How can I become a developer lazarus and access management in the SVN and bug-tracker? ===<br />
<br />
First of all: you must learn about Lazarus, to prove your knowledge and skill.<br />
Start by reading the [[Lazarus_Documentation|wiki articles]], read the Lazarus source code, giving a look at the [http://www.lazarus.freepascal.org/mantis Lazarus Bug-Tracker], fix some bugs, and if you think you are ready, contact the developers on the [http://www.mail-archive.com/lazarus@miraclec.com mailing list].<br />
<br />
== Where is ... defined ==<br />
<br />
=== Virtual key constants ===<br />
Virtual key constants are defined in LCLType. Add LCLtype to your <b>uses</b>.<br />
<br />
== Using the IDE ==<br />
<br />
=== How can I use "identifier completion"? ===<br />
You can invoke identifier completion by pressing [ctrl][space].<br />
Under the menu item ''Environment -> Editor Options -> Code Tools -> Automatic Features'' you can set how quick this should happen automatically.<br />
<br />
== Linux ==<br />
<br />
=== How can I debug on Linux without the IDE? ===<br />
<br />
First of all you need a debugger. gdb is the standard debugger under linux and<br />
there are several GUI-frontends available. One common frontend is ddd, which is<br />
part of most common distributions. To compile lazarus/lcl with debug-information<br />
you should then use the following commands to start a debug session:<br />
<br />
$ make clean; make OPT=-dDEBUG<br />
$ ddd lazarus<br />
<br />
Be warned however, that ddd is not as comfortable as e.g. the Lazarus debugger.<br />
Specially if it comes to view the contents of a variable you have to take into<br />
account that ddd/gdb are case sensitive whereas Pascal is case-insensitive.<br />
Therefore you have to type all variable names in uppercase to see their<br />
contents. For more information take a look into the fpc-manuals.<br />
<br />
=== I can debug now but ddd does not find my sources or complains that they contain no code. Whats that? ===<br />
<br />
This is a path-related problem with either gdb or ddd. You can aviod this by<br />
<br />
* Use the "Change directory" command from the ddd menu and choose the directory where the sources are located. The drawback of this method is that you now can't use the source of the program you started with (e.g. lazarus). Thus it may be neccessary to change the directory multiple times.<br />
* In ddd goto [Edit] [gdb-settings] and set the search-path<br />
* Create a $(HOME)/.gdbinit file like:<br />
directory /your/path/to/lazarus<br />
directory /your/path/to/lazarus/lcl<br />
directory /your/path/to/lazarus/lcl/include<br />
<br />
=== I receive an error during the linking that states /usr/bin/ld can't find -l<some lib> ===<br />
<br />
; '''Package Based Distributions''' : You need to install the package that provides the lib<somelib>.so or lib<somelib>.a files. Dynamic libs under linux have the extension .so, while static libs have the extension .a. On some Linux distro's you have installed the package (rpm, deb) <packagename> which provides <some lib>, but you also need the development package (rpm, deb), normally called <packagename>-dev, which contains the .a (static lib) and/or the .so (dynamic lib). <br />
: Some distributions have commands to find which package contains a file:<br />
: '''Mandriva'''<br />
<br />
[]$ urpmf lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -devel<br />
<br />
: '''Debian'''<br />
<br />
:install the apt-file utility (apt-get install apt-file) then<br />
<br />
[]$ apt-file search lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -dev<br />
<br />
<br />
<br />
; '''Source Based Distributions and Manual Compilation (LFS)''' : Make sure that there is a lib<somelib>.a in the path, and that it contains the right version. To let the linker find the dynamic library, create a symlink called lib<some lib>.so to lib<some lib><version>-x,y.so if necessary (and/or for static lib; lib<some lib>.a to lib<some lib><version>-x,y.a).<br />
<br />
; '''FreeBSD''' : As source based distro's, and also make sure you have -Fl/usr/local/lib in your fpc.cfg and/or Lazarus library path. Keep in mind that GTK1.2 has "gtk12" as package name under FreeBSD. (same for glib) NOTE: This has changed as of late. Newest ports have gtk-12 and glib-12 as well. You might stumble on this problem, since FPC requires the "-less" ones, you will need to symlink them like this:<br />
<br />
[]# cd /usr/local/lib && ln -s libglib-12.so libglib12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgtk-12.so libgtk12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgdk-12.so libgdk12.so<br />
<br />
; '''NetBSD''' : As source based distro's, and also make sure you have -Fl/usr/pkg/lib in your fpc.cfg and/or Lazarus library path<br />
<br />
=== How can I convert a kylix 2 project into a lazarus project? ===<br />
<br />
Nearly the same way as converting a Kylix project into a Delphi/VCL project.<br />
<br />
The LCL (Lazarus Component Library) tries to be compatible to Delphis VCL.<br />
Kylix CLX tries to be QT compatible.<br />
Here are some general hints:<br />
<br />
* Rename all used CLX Q-units like QForms, QControls, QGraphics, ... into their VCL counterparts: Forms, Controls, Graphics, ...<br />
* Add LResources to the uses section of every form source<br />
* Rename or copy all .xfm files to .lfm files.<br />
* Rename or copy .dpr file to .lpr file.<br />
* Add "Interfaces" to the uses section in the .lpr file.<br />
* Remove {$R *.res} directive<br />
* Remove {$R *.xfm} directive<br />
* Add {$mode objfpc}{$H+} or {$mode delphi}{$H+} directive to .pas and .lpr files<br />
* Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):<br />
initialization<br />
{$I unit1.lrs}<br />
:The .lrs files can be created via the lazres tool in: (lazarusdir)/tools/lazres.<br />
:For example: ./lazres unit1.lrs unit1.lfm<br />
<br />
* Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.<br />
<br />
* To make it more platform independant, reduce unit libc (which is deprecated) references and substitute with native FPC units like baseunix/unix as much as possible. This will be necessary to support other targets than linux/x86 (including OS X, FreeBSD and Linux/x86_64)<br />
<br />
=== When compiling lazarus the compiler can not find a unit. e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB ===<br />
<br />
1. Check a clean rebuild: do a 'make clean all'<br />
<br />
2. Check if the compiler has the correct version (2.0.4 or higher)<br />
<br />
3. Check if the compiler is using the right config file. The normal installation creates /etc/fpc.cfg. But fpc also searches for ~/.ppc386.cfg, ~/.fpc.cfg, /etc/ppc386.cfg and it uses only the first it finds.<br />
<br />
:'''Hint:''' You can see which config file is used with 'ppc386 -vt bogus'<br />
:Remove any ppc386.cfg as it is really obsolete.<br />
<br />
4. Check if the config file (/etc/fpc.cfg) contains the right paths to your fpc libs. There must be three lines like this:<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*<br />
:The first part of these paths (/usr/lib/fpc) depends on your system. On some systems this can be for example /usr/local/lib/fpc/... .<br />
:'''Hint:''' You can see your searchpaths with 'ppc386 -vt bogus'<br />
<br />
5. Check that the config file (/etc/fpc.cfg) does not contain search paths to the lcl source files (.pp, .pas):<br />
forbidden: -Fu(lazarus_source_directory)/lcl<br />
forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk<br />
:If you want to add the lcl for all your fpc projects, make sure that the two paths look like the following and are placed after the above fpc lib paths:<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk<br />
<br />
6. Check if the missing unit (glib.ppu) exists in your fpc lib directory. For example the gtk.ppu can be found in /usr/lib/fpc/$fpcversion/units/i386-linux/gtk/. If it does not exists, the fpc lib is corrupt and should be reinstalled.<br />
<br />
7. Check if the sources are in a NFS mounted directory. In some cases the NFS updates created files incorrectly. Please, try to move the sources into a non NFS directory and compile there.<br />
<br />
8. If you are still not succeeded try to use samplecfg script as follows:<br />
<br />
''#'' cd /usr/lib/fpc/''version''/<br />
<br />
''#'' sudo ./samplecfg /usr/lib/fpc/''\$version'' /etc<br />
<br />
Note! Do not put - / - after etc because if you do that the system will create a file - /etc/fpc.cfg/fpc.cfg. In fact we want that samplecfg make a file - /etc/fpc.cfg - not the folder /etc/fpc.cfg.<br />
<br />
=== I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS ===<br />
<br />
Probably you are using a newer fpc package, than that used for building the<br />
lazarus binaries. The best solution is to download the sources and compile<br />
lazarus manually. You can download the source snapshot or get the source<br />
via svn:<br />
<br />
$ bash<br />
$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
Make sure that lazarus get the new source directory:<br />
Environment->General Options->Files->Lazarus Directory Top<br />
<br />
===Lazarus compiles, but linking fails with: libgdk-pixbuf not found===<br />
Install the gdk-pixbuf library for gtk1.x:<br />
<br />
Where to find the gdk-pixbuf library:<br />
<br />
RPMs:<br />
http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=<br />
<br />
Debian packages:<br />
libgdk-pixbuf-dev<br />
<br />
Sources:<br />
ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/<br />
<br />
===I have SuSE and I get /usr/bin/ld: cannot find -lgtk Error: Error while linking===<br />
SuSE installs the gtk devel libs under /opt/gnome/lib (or /opt/gnome/lib64 for 64 bits), which is not in<br />
the standard lib path. Simply add it to your /etc/fpc.cfg.<br />
(-Fl/opt/gnome/lib).<br />
<br />
===Lazarus crashes with runtime error 211 after I installed a component===<br />
After I installed a component, Lazarus crashes with the following message:<br />
Threading has been used before cthreads was initialized.<br />
Make cthreads one of the first units in your uses clause.<br />
Runtime error 211 at $0066E188<br />
How can I fix this?<br />
<br />
Your freshly installed component is using threads. FPC on *nix doesn't automatically include threading support, but it must be intialized. This initialization is done in the cthreads unit. Every application using the component needs to add this unit to the uses clause of the main program. Lazarus itself is no exception. This can be done in two ways:<br />
<br />
1) Open the package. In the package editor click on ''Options''. Under page ''Usage'' add to the ''custom'' options '''-dUseCThreads'''. Then rebuild the IDE. This way the cthreads unit will be automatically used by the IDE under unix and the cthreads are initialized.<br />
<br />
2) In order to avoid modifying package, a fpc compiler option could be used directly. Open menu Tools->Configure "build Lazarus". Configure "build Lazarus" dialog will be shown, in field "Options:" type -Facthreads and then press "OK" button. The next step is to install the package. Lazarus will be built with option -Facthreads which means that it will treat main program as if unit cthreads where first in uses clause. <br />
<br />
''Hint:'' Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.<br />
<br />
See also [[Multithreaded_Application_Tutorial#Units_needed_for_a_multithreaded_application]]<br />
<br />
===When I run a program with threads I get runtime error 232===<br />
The complete error message is:<br />
This binary has no thread support compiled in.<br />
Recompile the application with a thread-driver in the program uses<br />
clause before other units using thread.<br />
Runtime error 232<br />
'''Solution''': Add cthreads as first unit to the uses clause of your main program, usually the .lpr-file.<br />
<br />
===I have Ubuntu Breezy and my fonts in Lazarus IDE look too big===<br />
If Lazarus is compiled with Gtk1.2, the settings in Gnome Preferences/Font don't have any effect as<br />
they are related to Gtk2.<br />
You could try this solution:<br />
Create a file named .gtkrc.mine in your home directory (if it's not already there) and add<br />
these lines to it:<br />
<br />
<pre><br />
style "default-text" {<br />
fontset = "-*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\<br />
-*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"<br />
}<br />
<br />
class "GtkWidget" style "default-text"<br />
</pre><br />
<br />
If this is not enough try and create also a .gtkrc symlink to .gtkrc.mine . It worked in this way under Xubuntu 7.10.<br />
<br />
===How can my gtk programs use custom rc files?===<br />
<br />
Option a)<br />
Name the rc file ''yourprogram.gtkrc'' and put it in the same directory where the executable is.<br />
<br />
Option b)<br />
Use unit ''GtkInt'' and call ''GTKWidgetSet.SetRCFilename('your_preferred_rc_file');''<br />
Best done before ''Application.Initialize'' in the .lpr file with ''{$IFDEF LCLGtk}''.<br />
<br />
===I have Ubuntu and I cannot compile for Gtk2 due to missing libraries===<br />
Ubuntu has a problem with not creating all the symbolic links that you'll need even when the libraries are installed. Make sure that all missing libraries when trying to link for Gtk2 have their appropriate links. For instance, you might need to do:<br />
<br />
<pre><br />
cd /usr/lib<br />
sudo ln -s libgdk-x11-2.0.so.0 libgtk-x11-2.0.so<br />
</pre><br />
<br />
Make sure that the [whatever].so symbolic links are created and point to the actual libraries.<br />
<br />
===How can I compile a program for Gtk2?===<br />
<br />
At the moment, the Gtk2 compiled IDE is a little unstable, but you can compile software for Gtk2 using the Gtk1 IDE.<br />
<br />
To start with recompile LCL for Gtk2. Go to the menu "Tools"->"Configure Build Lazarus" and set LCL to clean+build and everything else to none.<br />
<br />
Now click Ok and go to the menu "Tools"->"Build Lazarus"<br />
<br />
Now you can compile your software with Gtk2 going on the Compiler options and changing the widgetset to Gtk2.<br />
<br />
===I get this message: "[WARNING] ** Multibyte character encodings (like UTF8) are not supported at the moment."===<br />
<br />
Since revision 10535 (0.9.21) this message doesn't exist anymore. <br />
Previously it was used to warn that a UTF-8 encoding was used. The internal keyhandling routines for the gtk1 widgetset couldn't handle such encoding for keypresses, with the result that keypresses with for instance accented chars were not or wrong detected.<br />
<br />
(original text for older versions of lazarus)<br><br />
<strike><br />
This warning message indicates that your locale enconding is set to utf-8. If you are using Gtk 1 this can be a serious problem and prevent the correct working of Lazarus or software created with Lazarus.<br />
<br />
To work around this, just change your locale to a non utf-8 before executing the program on the command line, like this:<br />
<br />
<pre><br />
export LC_CTYPE="pt_BR"<br />
export LANG="pt_BR"<br />
export LANGUAGE="pt_BR"<br />
./lazarus<br />
</pre><br />
<br />
Substitute pt_BR with the locale for your country. You can create a script to automate this.<br />
</strike><br />
<br />
== Windows ==<br />
<br />
=== When I cycle the compiler, I get:The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time. ===<br />
<br />
In the compiler directory there is an OS2 scriptfile named make.cmd. Different versions of Windows also see this as a script file, so remove it since what is needed for OS2 becomes a hindrance on Windows.<br />
<br />
=== When I cycle the compiler, I get: make[3]: ./ppc1.exe: Command not found ===<br />
<br />
I don't know why but somehow make has lost its path. Try to cycle with a<br />
basedir set like: make cycle BASEDIR=your_fpc_source_dir_herecompiler<br />
<br />
=== When I try to make Lazarus I get:===<br />
====make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2 ====<br />
You need to upgrade your make.<br />
<br />
====makefile:27: *** You need the GNU utils package to use this Makefile. Stop.====<br />
Make sure you didn't install FPC in a path with spaces in the name. The<br />
Makefile doesn't support it.<br />
<br />
<br />
<br />
===How can I give my program an XP look like lazarus has?===<br />
Project -> Project Options -> Check 'Use manifest to enables themes'.<br />
<br />
===When I run Windows program created in Lazarus it starts with a DOS window===<br />
Specify the -WG argument (Windows GUI) on the command line of the compiler or in the Lazarus IDE check the Windows GUI check box on the compiler options dialog box (Project menu -> Compiler Options -> Linking -> target OS Specific options.<br />
<br />
== Mac OS X ==<br />
<br />
=== Why does compiling a project fail with 'unknown section attribute: no_dead_strip'?===<br />
<br />
Dead code stripping is not supported by the assembler and linker before Xcode 1.5 (available for Mac OS X 10.3.9). Disable the compiler options <br />
<br />
*Code > Unit style > Smart linkable (-CX) <br />
*and Linking > Link Style > Link smart (-XX)<br />
<br />
== Licensing ==<br />
<br />
=== Can I make commercial applications with Lazarus ? ===<br />
<br />
Yes, the LCL is licensed under the LGPL with an exception, which allows you to link to it statically without releasing the source of your application. Modifications and enhancements to the LCL must be distributed with source. Lazarus, the IDE, is licensed under the GPL.<br />
<br />
=== Can I make commercial plug-ins for Lazarus ? ===<br />
<br />
Yes, the IDEIntf part of the IDE is licensed under the LGPL with the same exception, so that shared data structures in this part will not force you to license your plug-in or design-time package under the GPL. You are free to choose a plug-in of any license; we don't want to limit your choice. Therefore non-GPL compatible plug-ins are allowed. Note that it's not allowed to distribute a precompiled Lazarus with these non-GPL-compatible plugins included statically; however, we do not see this as a severe limitation, since recompiling Lazarus is easy.<br />
<br />
== Contributors and Comments ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq version].</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Documentation/ko&diff=32431Lazarus Documentation/ko2008-12-01T12:12:30Z<p>Oranke: /* 라자루스와 파스칼 튜토리얼 */</p>
<hr />
<div>{{Lazarus Documentation}}<br />
<br />
==라자루스와 파스칼 튜토리얼==<br />
*[[Overview of Free Pascal and Lazarus/ko|프리파스칼과 라자루스 살펴보기]] - 간략한 소개글 입니다.<br />
*[[Lazarus Tutorial/ko|라자루스 튜토리얼]] - 라자루스 IDE에 대해 자세히 다루고 있는 초보자를 위한 설명서 입니다.<br />
*[[Lazarus IDE Tools|라자루스 IDE 툴]] - 코드 자동완성을 비롯한 기타 IDE의 내용들을 다루는 중급자용 설명서 입니다.<br />
*[[Lazarus Database Tutorial|라자루스 데이터베이스 튜토리얼]] - 데이터베이스 개발에 라자루스를 사용하기 위한 소개서 입니다.<br />
*[[Developing with Graphics|그래픽 개발]] - 그래픽 프로그래밍을 위한 기본적인 예제들 입니다.<br />
*[[Pascal Tutorial]] - [http://www.taoyue.com/ Tao Yue's] [http://www.taoyue.com/tutorials/pascal/ Pascal Tutorial] (reposted with permission).<br />
*[[Object Oriented Programming with FreePascal and Lazarus|프리파스칼과 라자루스를 사용한 객체 지향 프로그래밍]] - 파스칼 이상의 파스칼<br />
*[[Console Mode Pascal|콘솔 모드 파스칼]] - 라자루스 IDE를 사용해 텍스트 모드에서 구동되는 프로그램 만들기 입니다.<br />
*[[Executing External Programs|외부 프로그램 실행]] - 외부 프로그램을 실행시키는 방법에 대한 간단한 설명서 입니다.<br />
*[[TXMLPropStorage]] - Using TXMLPropStorage to save user preferences.<br />
*[[Hardware Access/ko|하드웨어 제어]] - ISA, PCI카드, 패러랠, 시리얼, USB 디바이스 등의 하드웨어 접근법 입니다.<br />
*[[Networking|네트워킹]] - Tutorials about TCP/IP protocol, creating secure network programs, WebServices, etc.<br />
*[[XML Tutorial|XML 튜토리얼]] - XML 파일 읽고 쓰기에 대한 내용 입니다.<br />
*[[Multithreaded Application Tutorial|멀티쓰레드 어플리케이션 튜토리얼]] - 프리파스칼과 라자루스를 사용한 멀티쓰레드 어플리케이션 제작법 입니다.<br />
*[[Streaming components|스트리밍 컴포넌트]] - 스트림에 컴포넌트를 저장하고, 다시 읽어들여 생성하는 방법 입니다.<br />
*[[OpenGL Tutorial/ko|OpenGL 튜토리얼]] - GLUT 라이브러리를 라자루스에서 사용하는 방법 입니다.<br />
*[[Creating bindings for C libraries|C 라이브러리와 연결]] - C 헤더파일을 (.h) 파스칼 유니트로 변환하는 방법에 대해 설명합니다.<br />
*[[Lazarus/FPC Libraries]] - 동적 라이브러리 (.so, .dll, .dylib) 를 만들고 또 그것을 사용하는 방법에 대해 설명합니다.<br />
*[[Translations / i18n / localizations for programs]] - How to provide localized versions of your programs and packages<br />
*[[Daemons and Services]] - 윈도의 서비스, 또는 리눅스의 데몬을 만드는 법에 대해 이야기 합니다.<br />
*[[Office Automation]] - How to interact with office software and create spreadsheets, text documents, presentations, etc.<br />
*[[Lazarus Inline Assembler|라자루스 인라인 어셈블러]] - 입문서 입니다.<br />
*[[VirtualTreeview Example for Lazarus]] - Using VirtualTreeview on Lazarus.<br />
*[http://es.wikibooks.org/wiki/Programaci%C3%B3n_en_Pascal Programando en Pascal] - Spanish tutorial focused on FPC/Lazarus, hosted in Wikibooks.<br />
<br />
==라자루스 사용자 가이드==<br />
*[[Lazarus Faq/ko|라자루스 FAQ]] - 리눅스 및 윈도 유저를 위한 일반적인 정보들 입니다..<br />
*[[Lazarus DB Faq|라자루스 DB FAQ]] - 라자루스에서 DB를 다룰 때 만나는 문제들에 대한 FAQ 입니다.<br />
*[[Databases in Lazarus|라자루스와 데이터베이스]] - 라자루스에서 데이터베이스를 사용하는 것에 대한 간략한 안내 입니다.<br />
*[[Code Examples|예제 모음]] - 라자루스 예제 모음 입니다.<br />
*[[Feature_Ideas|Wishlist/Wanted Features]] - Features that you would like to see in Lazarus<br />
*[[How do I create a bug report]] - You think you found a bug in Lazarus, how can you report it?<br />
<br />
===설치하기=== <br />
*[[Installing Lazarus|라자루스 설치]] - 설치 방법에 대한 안내 입니다.<br />
*[[Getting Lazarus|라자루스 구하기]] - 라자루스의 릴리즈버전, 또는 SVN을 통한 개발버전을 얻는 방법에 대한 안내 입니다. <br />
*[[Multiple Lazarus|여러 버전의 라자루스]] - 한 대의 컴퓨터에 여러 버전의 라자루스를 설치하는 방법에 대한 안내 입니다. <br />
<br />
===IDE===<br />
*[[IDE tricks]] - Tips, tricks and hidden features<br />
*[[Lazarus IDE]] - The IDE windows<br />
*[[Lazarus IDE Shortcuts]] - The key mapping and shortcuts.<br />
*[[Lazarus Packages]] - A guide for creating a package under Lazarus<br />
*[[Install Packages]] - A small guide to install packages<br />
*[[Extending the IDE]] - How to add functionality to the Lazarus IDE<br />
*[[Adding Kylix Help]] - How to use the Borland Help files within the IDE editor.<br />
*[[Using Lazarus for other computer languages]] - How to use the IDE for C, Java, etc.<br />
*[[IDE Development]] - Various pages about current development of the IDE.<br />
<br />
===LCL===<br />
*[[doc:lcl/|LCL documentation]] - On line help for LCL (work in progress).<br />
*[[The LCL in various platforms]] - A brief discussion about LCL features which behave differently in different platforms.<br />
*[[Autosize / Layout]] - How to design forms that work on all platforms.<br />
*[[Main Loop Hooks]] - How to handle multiple event sources<br />
*[[Asynchronous Calls]] - How to queue methods for later execution<br />
*[[File size and smartlinking]] - How to smartlink applications and create smaller executables.<br />
*[[Accessing the Interfaces directly]] - Example how to access the LCL widgetsets<br />
*[[Add Help to Your Application]] - How to create a Online Help for your application<br />
*[[Anchor Sides]] - Description of Anchor Sides Feature<br />
*[[LCL Tips]] - Tips and tricks<br />
*[[LCL Defines]] - Choosing the right options to recompile LCL<br />
<br />
===Developing===<br />
*[[The Power of Proper Planning and Practices]] - common-sense programming best practices for the Free Pascal and Lazarus developer<br />
*[[Multiplatform Programming Guide]] - How to develop cross-platform applications and how to port from one platform to another<br />
*[[Using Pascal Libraries with .NET and Mono]] - yes, you can use your Free Pascal code with .NET and Mono<br />
*[[Deploying Your Application]] - How to create an installer for your application<br />
*[[Cross compiling]] - Creating executables of one platform, on another.<br />
*[[Remote Debugging]] - How to debug your Lazarus application from another machine.<br />
*[[Application Icon]] - Setting the application icon<br />
<br />
===플랫폼 별 유용한 팁===<br />
*[[OS X Programming Tips]] - Lazarus installation, useful tools, Unix commands, and more...<br />
*[[WinCE Programming Tips]] - Using the telephone API, sending SMSes, and more...<br />
<br />
===함께 하면 유용한 도구들===<br />
*[[Lazarus Documentation Editor]] - Using "lazde" to create documentation<br />
*[[LazDoc]] - An integrated editor for documentation files<br />
*[[FPDoc Updater]] - A GUI tool for updating FPDoc files<br />
*[[lazbuild]] - Compiling projects and packages without the IDE<br />
*[[LazSVNPkg]] - Lazarus SVN IDE Plugin<br />
<br />
===델파이 사용자를 위한 안내===<br />
*[[Lazarus Components|라자루스 컴포넌트]] - 라자루스와 터보델파이 컴포넌트들의 차이점에 대한 정보 입니다. <br />
*[[Lazarus For Delphi Users|델파이 사용자와 라자루스]] - 라자루스를 시작하려는 델파이 사용자를 위한 정보들 입니다.<br />
*[[Code Conversion Guide|코드 변환 가이드]] - 델파이와 카일릭스용 코드 및 컴포넌트를 라자루스에서 사용하는 방법에 대해 다룹니다.<br />
<br />
==라자루스 개발자 가이드==<br />
*[[Lazarus Development Process|라자루스 개발 프로세스]] - 로드맵, 아이디어, 그리고 현재.<br />
*[[How To Help Developing Lazarus|라자루스 개발을 돕는 법]] - 라자루스의 성능 개선을 위해 도움을 주려는 새로운 개발자가 참고할만한 내용들<br />
*[[Version Numbering|버전 번호 붙이기]] - 라자루스의 버전 번호의 차이점에 대한 설명 <br />
*[[Creating A Patch| 패치 만들기]] - 개선된 기능을 라자루스에 적용하기 위해 패치를 만드는 방법<br />
*[[Creating a Backtrace with GDB|GBD용 백트레이스 생성]] - 디버깅을 위해 백트레이스를 만드는 방법<br />
*[[Nomenclature/ko|이름 붙이기]] - 메소드나 프로퍼티에 이름 붙이는 방법에 대한 설명<br />
*[[DesignGuidelines/ko|디자인 가이드 라인]] - 라자루스 소스 코드 변경시 준수해야 할 규칙<br />
*[[GUI design]] - Notes on guidelines when designing the lazarus GUI<br />
*[[Roadmap]] - An idea of the current status of the various parts of Lazarus<br />
*[[Road To 1.0]] - What needs to be done for Lazarus 1.0 and To Do lists<br />
*[[Moderating the bug tracker]] - Guidelines for lazarus developers and moderators for using the [http://www.freepascal.org/mantis/ bug tracker].<br />
*[[Codetools]] - How the codetools are integrated into the IDE<br />
*[[Creating IDE Help]] - How to extend the IDE documentation<br />
*[[Unit not found - How to find units]] - How to setup the IDE and source files<br />
*[[Bounties]] - Need a particular new feature soon? Set a price here. <br />
<br />
===LCL - 라자루스 컴포넌트 라이브러리===<br />
*[[LCL Messages]] - Guide related to LCL Messages<br />
*[[LCL Internals]] - Some info about the inner workings of the LCL<br />
*[[LCL Key Handling]] - Help! A key press, what now?<br />
*[[LCL Internals - Resizing, Moving]] - How the LCL communicates with the LCL interface to resize, move controls<br />
*[[LCL Unicode Support]] - Road to Unicode enabled Lazarus<br />
*[[LCL Documentation Roadmap]] - Which units have to be documented<br />
*[[LCL Bindings]] - Bindings to use LCL on other languages<br />
<br />
===Interfaces===<br />
*[[Lazarus known issues (things that will never be fixed)]] - A list of interface compatibility issues<br />
*[[Win32/64 Interface]] - The winapi interface for Windows 95/98/Me/2K/XP/Vista, but not CE<br />
*[[GTK1 Interface]] - The gtk1.2 for Unixes, Mac OS X, Windows<br />
*[[GTK2 Interface]] - The gtk2 for Unixes, Mac OS X, Windows<br />
*[[Carbon Interface]] - The Carbon Interface for Mac OS X<br />
*[[Qt Interface]] - The Qt 4 Interface for Unixes, Mac OS X and linux-based PDAs<br />
*[[Windows CE Interface]] - For Pocket PC and Smartphones<br />
*[[fpGUI Interface]] - A widgetset completely written in Object Pascal<br />
*[[Cocoa Interface]] - The Cocoa Interface for Mac OS X<br />
<br />
===Translations===<br />
* [[Getting translation strings right]] A few notes for programmers on how to create and use translateable strings in your application. Quickly discusses general things about creating strings, offers a few hints on implementation issues and points out some things to consider when using English as base language in particular.<br />
* '''Localization Notes:'''<br />
:* [[German localization notes|German]] - Notes and guidelines for translating the Lazarus IDE to German, including a small dictionary to look up often used translations.<br />
:* [[Portuguese-Brazilian Localization Notes|Portuguese-Brazilian]] - Small dictionary containing common translations of terms used in the Lazarus IDE for the Portuguese-Brazilian translation.<br />
:* [[Russian localization notes|Russian]] - Notes and guidelines for translating the Lazarus IDE to Russian.<br />
<!-- *[[TO-DO]] Remaining Tasks --><br />
* [[Help:Add language bar | Add language bar]] explains how you can add a list of translations to the top of a wiki page.<br />
<br />
==Additional Components Documentation==<br />
*[[Pascal Script]] and [[Pascal Script Examples]] - How to use the pascal script components in Lazarus<br />
*[[OpenGL]] - How to use OpenGL in Lazarus<br />
*[[KOL-CE]] - Free Pascal/Lazarus port of KOL&MCK library. How to create very compact applications for Win32/WinCE in Lazarus.<br />
<br />
==Free Pascal Compiler Documentation==<br />
In addition to [http://lazarus-ccr.sourceforge.net/fpcdoc/ this site], the latest version of the documentation can also be found online and in a variety of downloadable formats on the main [http://www.freepascal.org/docs.html Free Pascal Compiler site].<br />
There is now also a WiKi site for FreePascal [http://www.freepascal.org/wiki/index.php/Main_Page] very similar in style to this one, to allow developers to submit documentation in addition to the official FPC documents below.<br />
<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/user/user.html User's guide]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/prog/prog.html Programmer's guide]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/ref/ref.html Reference guide for the system unit, and supported Pascal constructs]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/rtl/index.html Run-Time Library reference manual]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/fcl/index.html Free Component Library reference manual]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/fpdoc/fpdoc.html Free Pascal documentation tool manual]<br />
*[[Build messages]]<br />
<br />
==Lazarus related blogs and websites==<br />
'''Blogs'''<br />
*[[Adventures of a Newbie]] - A blog of a newbie getting started with some tutorial information in a running log.<br />
*[http://lazarusroad.blogspot.com/ On the road with Lazarus/Freepascal] - A blog dedicated to register my experiences while programming with Lazarus and Freepascal (by Luiz Américo)<br />
*[http://port2laz.blogspot.com/ Porting to Lazarus] - This blog describes the porting of a medium-sized application (~100 kloc) from D7 with CLX to Lazarus (by Alexsander da Rosa)<br />
*[http://living-lazarus.blogspot.com/ Living Lazarus] - One mans exploration into the possibilities of an open source RAD (by [[User:Wibblytim|Wibblytim]]).<br />
*[http://beeography.wordpress.com/tag/object-pascal/ Bee.ography] just (another) Bee’s buzz!<br />
*[http://donaldshimoda.blogspot.com/ Parallel Pascal Worlds] Donald Shimoda.<br />
<br />
'''Websites'''<br />
*[[swainbrain pascal wiki]] - unique free pascal tutorials and info [http://mercury.it.swin.edu.au/swinbrain/index.php/Pascal#Pascal_Development_Tools swainbrain]</div>Orankehttps://wiki.freepascal.org/index.php?title=OpenGL_Tutorial/ko&diff=32419OpenGL Tutorial/ko2008-11-29T13:44:06Z<p>Oranke: </p>
<hr />
<div>{{OpenGL Tutorial}}<br />
<br />
<br />
OpenGL은 이기종간 이식가능하고 상호 작용이 가능한 2D 및 3D 그래픽 어플리케이션을 개발할 수 있는 훌륭한 환경이다. 1992년 처음 소개된 이래 OpenGL은 산업계에서 가장 폭넓게 이용되며 2D와 3D 그래픽 어플리케이션 인터페이스(API)를 제공하며 다양한 컴퓨터 플랫폼에서 수 많은 어플리케이션이 있다. OpenGL은 렌더링, 텍스쳐 매핑, 특수효과 및 다른 강력한 시각화 함수등의 다양한 셋을 삽입하여 혁신적이고 빠른 어플리케이션의 개발을 가능하게 하였다. 개발자는 모든 인기있는 데스크톱과 워크스테이션 플랫폼에서 다양한 어플리케이션 개발의 성공을 보장받기 위해 OpenGL의 능력을 저울질하게 된다.<br />
<br />
OpenGL에 관한 더 많은 정보는 [http://www.opengl.org/about/overview/ 이곳]에서 찾을 수 있다.<br />
<br />
= GLUT =<br />
<br />
GLUT(glutony의 glu와 발음이 비슷)는 OpenGL Utility Toolkit으로,윈도우 시스템과 독립적인 툴킷으로 OpenGL 프로그램 작서에 사용된다. 이것은 OpenGL을 위한 간단한 윈도우 어플리케이션 프로그래밍 인터페이스(API)를 구현한다. GLUT는 이식 가능한 API를 제공하여 모든 PC와 워크스테이션 플랫폼에 동작하는 단일 OpenGL 프로그램을 작성할 수 있게 한다.<br />
<br />
GLUT에 관한 더 자세한 정보는 [http://www.opengl.org/resources/libraries/glut/ 여기]에 있다.<br />
<br />
많은 OS는 GLUT를 설치하고 있으나 당신이 [http://www.google.com/ 구글]에서 쉽게 찾을 수 없다면 윈도우즈 바이너리를 [http://www.xmission.com/~nate/glut.html www.xmission.com]에서 다운로드 할 수 있다.<br />
<br />
= LCL =<br />
<br />
라자루스 컴포넌트 라이브러리는 OpenGL과 함께 하용할 수 있다. 라자루스는 OpenGl 컨텍스트를 가진 LCL 컨트롤을 가진 TOpenGLControl 을 포함하고 있다. 라자루스 패키지 LazOpenGLContext는 lazarus/components/opengl/lazopenglcontext.lpk에서 찾을 수 있다. 예제는 lazarus/examples/openglcontrol/openglcontrol_demo.lpi에서 찾을 수 있다.<br />
<br />
= LCL / GLUT =<br />
<br />
GLUT와 LCL은 어제 이용하나?<br />
<br />
*내 맘대로 무언가를 그리려고 한다면 GLUT가 더 낫다.<br />
*보통의 어플리케이션에서는 LCL이 더 낫다. 예를 들어 3D 에디터는 몇개의 OpenGL 윈도우를 필요로 하며 나머지는 보통의 버튼, 콤보박스, 윈도우 모달 윈도우 등을 사용하는 보통의 어플리케이션이다.<br />
<br />
OpenGL 파트는 매우 유사하다. GLUT는 윈도우 환경에서 dll을 필요로 하며 LCL은 박스의 바깥에서 실행되지만 LCL 실행 파일은 더 커진다.<br />
<br />
= 첫번째 GLUT 프로그램 작성 =<br />
<br />
GLUT를 이용하기 위해서는 반드시 먼저 초기화가 필요하다.이것은 <b>glutInit</b> 함수를 사용하여 수행한다. 이 함수는 명령어 라인을 파싱하여 메인 윈도우를 위해 파라메터를 설정하지만, C/C++ 스타일로 입력되어야 한다. ParamCount와 ParamStr을 C/C++와 유사한 명령어 파라메터로 변환하는 각자의 함수를 작성할 수가 있다.<br />
<br />
<delphi><br />
procedure glutInitPascal(ParseCmdLine: Boolean); <br />
var<br />
Cmd: array of PChar;<br />
CmdCount, I: Integer;<br />
begin<br />
if ParseCmdLine then<br />
CmdCount := ParamCount + 1<br />
else<br />
CmdCount := 1;<br />
SetLength(Cmd, CmdCount);<br />
for I := 0 to CmdCount - 1 do<br />
Cmd[I] := PChar(ParamStr(I));<br />
glutInit(@CmdCount, @Cmd);<br />
end;<br />
</delphi><br />
<br />
본질적으로, 프로그래머는 배열을 생성하고 ParamStr에 있는 문자열로 배열을 채워야 한다. 이 함수는 어떤 것이 gluInit에 전달되는지를 컨트롤하는 파라메터(명령어 라인 전체 혹은 실행파일 이름 만)를 취한다.<br />
<br />
할일: '''glutInit(@argc, @argv);'''가 충분하다면.<br />
<br />
glutInit에 더 많은 정보: http://www.opengl.org/resources/libraries/glut/spec3/node10.html <br />
<br />
다음으로는 메인 윈도우를 생성할 필요가 있다.<br />
<b>glutInitDisplayMode</b>를 사용하여 메인윈도우의 디스플레이 모드를 설정한다. 이것은 플래그의 조합으로 이루어진 단 한개의 파라메터만을 취한다. 보통 <b>GLUT_DOUBLE 나 GLUT_RGB, GLUT_DEPTH</b>가 필요한 전부이다.<br />
<br />
glutInitDisplayMode에 관한 더 많은 정보: http://www.opengl.org/resources/libraries/glut/spec3/node12.html <br />
<br />
윈도우의 위치와 크기는 <b>glutInitWindowPosition</b>와 <b>glutInitWindowSize</b>를 사용하여 조절할 수가 있다. 이것들은 2개의 파라메터를 취한다. 전자는 Y와 Y 좌표를, 후자는 폭(width)과 높이(height)이다. <b>glutGet</b>을 사용하여 스크린의 크기와 윈도우의 중심을 알아낼 수 있다.<br />
<br />
lutInitWindowPosition, glutInitWindowSize 및 glutGet에 관한 더 자세한 것은: http://www.opengl.org/resources/libraries/glut/spec3/node11.html <br />
http://www.opengl.org/documentation/specs/glut/spec3/node70.html <br />
<br />
마지막으로 윈도우는 <b>glutCreateWindow</b>함수를 사용하여 생성하면 된다. 이것은 윈도우를 생성하고 파라메터를 통해 윈도우의 캡션을 설정한다. 그 결과 윈도우의 핸들을 반환한다. 이 핸들은 이것을 필요로 하는 다른 함수에서 사용할 수 있다.<br />
<br />
glutCreateWindow에 관한 더 자세한 정보는: http://www.opengl.org/resources/libraries/glut/spec3/node16.html <br />
<br />
작성한 프로그램이 메인 루프에 들어가기 전에 몇몇 콜백을 설정해야만 한다. 윈도우를 그리고, 크기를 변경하고 키보드 입력을 얻는데 콜백이 필요하다. 이 콜백들은 <b>glutDisplayFunc</b>, <b>glutReshapeFunc</b> 및<b>glutKeyboardFunc</b>을 이용하여 설정한다.<br />
<br />
콜백을 설정하는 더 자세한 정보는: http://www.opengl.org/resources/libraries/glut/spec3/node45.html#SECTION00080000000000000000 <br />
<br />
당신의 그리기 함수는 다름과 같은 모습을 띨것이다:<br />
<br />
procedure DrawGLScene; cdecl;<br />
begin<br />
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);<br />
glutSwapBuffers;<br />
end;<br />
<br />
이것은 윈도우를 배경색상으로 지우고 zbuffer를 리셋한다(zbuffer에 대해 걱정하지 마라... 뒤에 더 자세히 다룰 것이다).<br />
<br />
당신의 리사이즈 함수는 다음과 같을 것이다: <br />
<br />
procedure ReSizeGLScene(Width, Height: Integer); cdecl;<br />
begin<br />
if Height = 0 then<br />
Height := 1;<br />
<br />
glViewport(0, 0, Width, Height);<br />
glMatrixMode(GL_PROJECTION);<br />
glLoadIdentity;<br />
gluPerspective(45, Width / Height, 0.1, 1000);<br />
<br />
glMatrixMode(GL_MODELVIEW);<br />
glLoadIdentity;<br />
end;<br />
<br />
이 코드에서, 윈도우의 어느 곳에 그리며, 원하는 값을 행렬(matrix함수는 뒤에서 설명한다)에 설정할지를 OpenGL에게 알려주어야 한다.<br />
<br />
키보드 입력은 다음 콜백을 검증한다.<br />
<br />
procedure GLKeyboard(Key: Byte; X, Y: Longint); cdecl;<br />
begin<br />
if Key = 27 then<br />
Halt(0);<br />
end;<br />
<br />
이 함수는 프로그램에서 ESC 키가 눌리면 종료하도록 명령한다. GLUT는 이벤트 구동방식이므로 프로그램을 종료하는 유일한 방법은 당신의 콜백함수 중의 하나의 내부에서 <b>Halt</b>를 콜하는 것이다. 만약 다른 방법으로 윈도우를 종료한다면, 윈도우는 사라지지만 프로그램은 메인 루틴에서 무한정 루프를 계속 돌 것이다.<br />
<br />
메인 루프를 시작하기 위해 <b>glutMainLoop</b>를 콜해야 한다. 이것은 무한 루프에 들어가 프로그램의 모든 콜백함수들을 호출하게 된다<br />
<br />
프로그램의 메인 파트는 다음과 같은 모습을 띨 것이다:<br />
<br />
const <br />
AppWidth = 640; <br />
AppHeight = 480; <br />
<br />
procedure InitializeGL; <br />
begin <br />
glClearColor(0.18, 0.20, 0.66, 0); <br />
end; <br />
<br />
var <br />
ScreenWidth, ScreenHeight: Integer; <br />
begin <br />
glutInitPascal(True); <br />
glutInitDisplayMode(GLUT_DOUBLE or GLUT_RGB or GLUT_DEPTH); <br />
glutInitWindowSize(AppWidth, AppHeight); <br />
ScreenWidth := glutGet(GLUT_SCREEN_WIDTH); <br />
ScreenHeight := glutGet(GLUT_SCREEN_HEIGHT); <br />
glutInitWindowPosition((ScreenWidth - AppWidth) div 2,<br />
(ScreenHeight - AppHeight) div 2); <br />
glutCreateWindow('OpenGL Tutorial 1'); <br />
<br />
InitializeGL; <br />
<br />
glutDisplayFunc(@DrawGLScene); <br />
glutReshapeFunc(@ReSizeGLScene); <br />
glutKeyboardFunc(@GLKeyboard); <br />
<br />
glutMainLoop; <br />
end.<br />
<br />
다음 튜토리얼은 간단한 도형을 그리는 몇몇 코드를 더할 것이다.<br />
<br />
소스코드나 리눅스/윈도우즈 실행 파일은 다음에서 다운로드 할 수가 있다 [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=199145 Lazarus CCR SourceForge].<br />
<br />
=간단한 도형 그리기=<br />
<br />
<br />
'''Note:'''이어지는 부분은 거의 OpenGL에 관한 것이므로 GLUT와 LCL에서 실행하여야 한다. 'glu' 접두어를 통해 GLUT에 관련된 함수라는 것을 알 수가 있다.<br />
<br />
이 시점에서 단지 몇 라인의 코드만을 추가 할 것이며 몇몇 OpenGL 함수에 관한 설명에 촛점을 맞출 것이다.<br />
<br />
다음 코드에 대해 설명할 것이다.<br />
<br />
.<br />
.<br />
.<br />
glMatrixMode(GL_PROJECTION);<br />
glLoadIdentity;<br />
gluPerspective(45, Width / Height, 0.1, 1000);<br />
<br />
glMatrixMode(GL_MODELVIEW);<br />
glLoadIdentity;<br />
end;<br />
<br />
<b>glMatrixMode</b> 함수를 사용하여 변경하고자 하는 매트릭스(행렬)를 선택 할 수가 있다. OpenGL은 3개의 매트릭스를 이용하여 작업을 수행한다:<br />
<br />
<b>GL_MODELVIEW</b>: 이것은 버텍스를 모델 스페이스로 이동할 때 사용한다.<br />
<br />
<b>GL_PROJECTION</b>: 이것은 최종 픽셀위치를 위해 3d 좌표를 2d 좌표로 변환하는데 사용한다.<br />
<br />
<b>GL_TEXTURE</b>: 이것은 텍스쳐 좌표를 변경할 떄 사용한다.<br />
<br />
변화시키고자 하는 매트릭스를 선택했으면, 매트릭스 값을 변화시키는 함수를 호출하여야 한다. <b>glLoadIdentity</b>는 매트릭스를 리셋하므로 버텍스 위치에 영향을 미치지 못한다. 거의 대부분의 매트릭스 함수가 현재 매트릭스를 생성된 매트릭스와 곱하므로, 때때로 이 함수로 매트릭스를 지워주어야 한다.<br />
<br />
perspective 매트릭스를 설정하기 위해 <b>gluPerspective</b> 함수를 사용할 수 있다. 네개의 파라메터는 시야(field of view), 가로세로비율(aspect ratio), 근접(near) 및 far 평면(plane)을 나타낸다. 이렇게 간단하다.<br />
<br />
이제 모델 매트릭스를 변경할 것이며 identity만 설정하면 된다.<br />
<br />
좋다... 그리고 이제 첫번째 도형을 그리는 코드이다.:<br />
<br />
procedure DrawGLScene; cdecl;<br />
begin<br />
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);<br />
<br />
glLoadIdentity;<br />
glTranslatef(0, 0, -5);<br />
<br />
glBegin(GL_TRIANGLES);<br />
glColor3f(1, 0, 0);<br />
glVertex3f(-1, -1, 0);<br />
<br />
glColor3f(0, 1, 0);<br />
glVertex3f(1, -1, 0);<br />
<br />
glColor3f(0, 0, 1);<br />
glVertex3f(0, 1, 0);<br />
glEnd;<br />
<br />
glutSwapBuffers;<br />
end;<br />
<br />
우리는 이미 glClear 함수를 사용하였다. 이것은 버퍼를 리셋하기만 한다. 우리는 다음 두 함수는를 건너뛰고 도형을 그리는 곳으로 향할 것이다.<br />
<br />
<b>glBegin</b>는 드로잉 블록의 시작을 표시한다. 이 함수 뒤에 버텍스를 입력을 시작할 수 있다. 파라메터는 드로잉 할 때 버텍스가 어떻게 이용되는 지를 설명해 준다:<br />
<br />
GL_POINTS: 각 버텍스를 단일 포인트로 취급한다. 버텍스 n은 포인트 n으로 정의한다. N개의 포인트가 그려진다.<br />
<br />
GL_LINES: 각 버텍스 쌍을 독립적인 라인 세그컨트로 취급한다. 버텍스 2n-1과 2n은 라인 n을 정의한다. n/2개의 라인이 그려진다.<br />
<br />
GL_LINE_STRIP: 첫번째 버텍스에서 마지막까지 라인세그먼트의 연결된 그룹을 그린다. n-1개의 라인이 그려진다.<br />
<br />
GL_LINE_LOOP: 첫번째 버텍스에서 마지막까지 라인세그먼트의 연결된 그룹을 그린다. 그리고 첫번째 버텍스로 그린다. n과 n+1째 버텍스는 라인 n을 정의한다. 그러나 마지막 라인은 n과 1로 정의된다. n개의 라인이 그려진다.<br />
<br />
GL_TRIANGLES: 각 세개의 버텍스를 독립된 삼각형으로 취급한다. 버텍스 3n-2, 3n-1 및 3n은 삼각형 n을 정의한다. n/3개의 삼각형이 그려진다.<br />
<br />
GL_TRIANGLE_STRIP: 삼각형이 연결된 그룹을 그린다. 한개의 삼각형은 각 버텍스가 앞 두 버텍스와 함께 정의된다. 홀수 n에서 버텍스 n, n+1, n+2는 삼각형 n을 정의한다. 짝수 n에서, 버텍스 n+1, n 및 n+2는 삼각형 n을 정의한다. n-2개의 삼각형이 그려진다.<br />
<br />
GL_TRIANGLE_FAN: 삼각형이 연결된 그룹을 그린다. 한개의 삼각형은 각 버텍스가 앞 두 버텍스와 함께 정의된다. 버텍스 1, n+1 및 n+2는 삼각형 n으로 정의한다. n-2개의 삼각형이 그려진다.<br />
<br />
GL_QUADS: 각 네개의 버텍스를 독립된 사각형으로 취급한다. 버텍스 4n-3, 4n-2, 4n-1 및 4n은 사각형을 정의한다. n/4개의 사각형이 그려진다.<br />
<br />
GL_QUAD_STRIP: 사각형이 연결된 그룹을 그린다. 한개의 사각형은 각 쌍의 버텍스가 앞의 한쌍과 함께 정의된다. 버텍스 2n-1, 2n, 2n+2 및 2n+1 는 사각형 n을 정의한다. n/2-1개의 사각형이 그려진다. 스트립 데이타 중의 어떤 버텍스가 사각형을 그리는데 사용되는지의 순서가 독립적인 데이타 함께사용 될 때는 다르다. <br />
<br />
GL_POLYGON: 한개의 볼록 다각형을 그린다. 버텍스 1에서 n은 이 다각형을 정의한다.<br />
<br />
[[Image:SimpleShapePic1.jpg|thumb]] 한개의 삼각형을 그릴 수 있으며, 이를 위해 TRIANGLES 플래그가 트릭으로 사용된다. <b>glVertex3f</b> 함수는 그리고자 하는 버텍스의 위치를 정의한다. 더 많은 glVertex* 함수가 있다. 유일한 차이점은 필요로 하는 파라메터의 수와 타입이다.예를 들면... glVertex2i 는 두개의 파라메터 정수형 (x 및y)를 취한다. glVertex3f 는 거의 항상 당신이 필요로 하는 것일 것이다.<br />
<br />
glVertex 전에 색상, material, 텍스쳐...를 설정할 수 있다. 간단하게 하기 위해 이 튜토리얼에서는 각 버텍스에 색상을 부여할 것이다. 색상은 <b>glColor3f</b>함수를 사용하여 설정한다. glColor 는 glVertex 같이 다른 셋의 파라메터를 취할 수 있다.<br />
<br />
코드를 통해 보았듯이 모든 버텍스에서 Z는 0으로 설정되어 있었다. near plane을 0.1로 설정하였으므로 삼각형은 보이지 않을 것이다. 그것은 시작 부분에서 건너뛴 두 함수가 점프한 곳이 그곳이기 때문이다. glLoadIdentity 함수가 매트릭스를 리셋한다는 것을 이미 알고 있다. <b>glTranslatef</b>는 삼각형을 X, Y 및 Z값 만큼 이동시킨다. Z를 -5로 설정하였기 때문에(마이너스 Z는 카메라로 부터 멀리 떨어져 있는 것이다) 모든 버텍스는 우리가 볼 수 있는 뷰에서 5유닛 만큼 후퇴해 있다.<br />
<br />
마지막에서 <b>glEnd</b>함수를 호출하여 드로잉을 종료한다. 원한다면 이제 새로운 glBegin 함수와 함께 또 다른 블록을 시작할 수가 있다.<br />
<br />
소스코드, 리눅스 실행파일, 또는 윈도우즈 실행파일은 다음에서 다운로드 받을 수 있다: [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=199145 Lazarus CCR SourceForge].<br />
<br />
=디스플레이 리스트 사용하기=<br />
<br />
가끔 한 장면(scene)에서 몇몇 오브젝트를 여러 번 그려야 할 때가 있을 것이다. OpenGL은 더 빠르게 그릴 수 있는 <b>display lists</b>를 빌드할 수 있다. 디스플레이 리스트를 생성하는 것은 매우 쉽다.... 이전의 튜토리얼 처럼 버텍스들을 그리기만 하고 <b>glNewList</b> 와 <b>glEndList</b> 호출로 묶어주기만 하면 된다.<br />
<br />
const<br />
LIST_OBJECT = 1;<br />
<br />
procedure CreateList;<br />
begin<br />
glNewList(LIST_OBJECT, GL_COMPILE);<br />
glBegin(GL_TRIANGLE_FAN);<br />
glColor3f(1, 0, 0);<br />
glVertex3f(0, 0.5, 0);<br />
<br />
glColor3f(1, 1, 0);<br />
glVertex3f(-0.5, -0.5, 0.5);<br />
<br />
glColor3f(1, 1, 1);<br />
glVertex3f(0.5, -0.5, 0.5);<br />
<br />
glColor3f(0, 1, 1);<br />
glVertex3f(0.5, -0.5, -0.5);<br />
<br />
glColor3f(0, 0, 1);<br />
glVertex3f(-0.5, -0.5, -0.5);<br />
<br />
glColor3f(0, 1, 0);<br />
glVertex3f(-0.5, -0.5, 0.5);<br />
glEnd;<br />
<br />
glBegin(GL_QUADS);<br />
glColor3f(1, 1, 0);<br />
glVertex3f(-0.5, -0.5, 0.5);<br />
<br />
glColor3f(1, 1, 1);<br />
glVertex3f(0.5, -0.5, 0.5);<br />
<br />
glColor3f(0, 1, 1);<br />
glVertex3f(0.5, -0.5, -0.5);<br />
<br />
glColor3f(0, 0, 1);<br />
glVertex3f(-0.5, -0.5, -0.5);<br />
<br />
glColor3f(0, 1, 0);<br />
glVertex3f(-0.5, -0.5, 0.5);<br />
glEnd;<br />
glEndList;<br />
end;<br />
<br />
<b>glNewList</b> 는 새로운 리스트를 생성하고 모든 그리기 함수는 <b>glEndList</b>를 호출하기 전까지는 기록이 된다. glNewList 함수에 대한 첫번째 파라메터는 리스트 ID이다. 각 리스트는 각각의 ID에 의해 정의된다. 만약 리스트가 기존의 ID로 생성되면 이전의 기록은 지워질 것이다. 만약 두번째 파라메터가 GL_COMPILE이면 모든 드로잉 함수는 바로 기록이 될 것이지만, GL_COMPILE_AND_EXECUTE라면 자동적으로 기록되고 실행될 것이다.<br />
<br />
<b>glIsList</b> 함수는 디스플레이 함수 사용에 도움을 준다. 이것은 어떤 리스트 ID가 이미 데이터로 사용되고 있는 지를 알려준다. <br />
다른 유용한 함수는 <b>glGenLists</b>이다. 이것은 다수의 텅빈 디스플레이 리스트르 생성할 것이다. 원하는 디스플레이 리스트 수를 넘기면 첫번째의 ID를 얻을 수 있을것이다. n 리스트를 원하면 r ID를 받을 것이고 생성된 리스트는: r, r+1, r+2,..., r+n-1 이 된다.<br />
<br />
생성된 모든 리스트는 제거해야만 한다. 프로그램을 종료하기 전에 실행하여야 한다:<br />
<br />
procedure GLKeyboard(Key: Byte; X, Y: Longint); cdecl;<br />
begin<br />
if Key = 27 then<br />
begin<br />
glDeleteLists(LIST_OBJECT, 1);<br />
Halt(0);<br />
end;<br />
end;<br />
<br />
<b>glDeleteLists</b>는 2개의 파라메터 즉, 삭제하려고하는 디스플레이 리스트의 ID 와 리스트의 수를 필요로 한다. 만약 ID가 r 이고 삭제하려는 리스트의 수가 n이라면 삭제되는 리스트는: r, r+1, r+2,..., r+n-1 이다.<br />
<br />
이제 디스플레이 리스트를 생성하고 삭제하는 방법을 알았다... 이것들을 어떻게 그리는 지 알아보자:<br />
<br />
procedure DrawGLScene; cdecl;<br />
begin<br />
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);<br />
<br />
glLoadIdentity;<br />
glTranslatef(-2, 0, -5);<br />
glRotatef(40, 1, 0, 1);<br />
glCallList(LIST_OBJECT);<br />
<br />
glLoadIdentity;<br />
glTranslatef(1, -2, -10);<br />
glRotatef(62, 0, 1, 0);<br />
glCallList(LIST_OBJECT);<br />
<br />
glLoadIdentity;<br />
glTranslatef(-4, 0.5, -15);<br />
glRotatef(200, 1, 0, 0);<br />
glCallList(LIST_OBJECT);<br />
<br />
glutSwapBuffers;<br />
end;<br />
<br />
[[Image:DisplayListsPic1.jpg|thumb]] <b>glCallList</b>를 사용하면 당 한개의 디스플레이 리스트를 그릴 수 있다. 이 튜토리얼에서, 디스플레이 리스트를 그리기 전에, 모델 매트릭스를 변경하고 다른 위치에 오브넥트를 그려야 한다.<br />
<br />
가끔은 한번에 여러 개의 리스트를 그리고 싶을 것이다. <b>glCallLists</b> 함수를 사용한다면 가능하다. 이것은 그리고자 하는 리스트의 수, 디스플레이 리스트 ID를 가진 배열의 타입 및 디스플레이 리스트 ID를 가진 배열을 받는다. 리스트의 타입은 다음 중의 하나이다:<br />
<br />
GL_BYTE: 리스트는 -128에서 127까지의 부호있는 바이트의 배열로 취급한다.<br />
<br />
GL_UNSIGNED_BYTE: 리스트는 0에서 255까지의 부호없는 바이트의 배열로 취급한다.<br />
<br />
GL_SHORT: 리스트는 -32768에서 32767까지의 부호있는 두 바이트 정수의 배열로 취급한다.<br />
<br />
GL_UNSIGNED_SHORT: 리스트는 0에서 65535까지의 부호없는 두 바이트 정수의 배열로 취급한다.<br />
<br />
GL_INT: 리스트는 부호있는 네자리 정수의 배열로 취급한다.<br />
<br />
GL_UNSIGNED_INT: 리스트는 부호없는 네자리 정수의 배열로 취급한다.<br />
<br />
GL_FLOAT: 리스트는 네자리 부동소수점 배열로 취급한다.<br />
<br />
GL_2_BYTES: 리스트는 부호없는 바이트의 배열로 취급한다. 각 바이트 쌍은 단일한 디스플레이 리스트 ID를 지정한다. 각 쌍의 값은 부호없는 첫번째 바이트 값과 부호없는 두번째 바이트 값의 합을 256회 계산한다.<br />
<br />
GL_3_BYTES: 리스트는 부호없는 바이트의 배열로 취급한다. 각 바이트 세 개쌍(triplet)는 단일한 디스플레이 리스트 ID를 지정한다. 세 개쌍의 값은 단일한 디스플레이 리스트 ID를 지정한다. 세 개쌍의 값은 65536회 계산한다. 부호없는 첫번째 바이트 값과 부호없는 두번째 바이트 값의 합을 256회 계산하고 세번째 바이트 값을 더한다.<br />
<br />
GL_4_BYTES: 리스트는 부호없는 바이트의 배열로 취급한다. 각 바이트 네 개쌍(triplet)는 단일한 디스플레이 리스트 ID를 지정한다. 네 개쌍의 값은 단일한 디스플레이 리스트 ID를 지정한다. 네 개쌍의 값은 16777216회 계산한다. 부호없는 첫번째 바이트 값과 부호없는 두번째 바이트 값의 합을 65535회 계산하고 세번째 바이트 값을 더하고 256회 계산 한 후 네번째 부호없는 바이트를 더한다.<br />
<br />
다음 튜토리얼은 작은 행성계를 만드는 방법을 보여 줄 것이다. 매트릭스 및 초당 프레임에 얽매이지 않는 움직이는 장면(scene)을 만드는 방법에 대하여 이야기 할 것이다.<br />
<br />
소스, 리눅스 실행파일과 윈도우즈 실행파일은 다음에서 다운로드 할 수 있다 [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=199145 Lazarus CCR SourceForge].<br />
<br />
=Full screen animation=<br />
<br />
Entering full screen mode is easy with GLUT. Let's change main part of the program:<br />
<br />
const<br />
FSMode = '800x600:32@75';<br />
<br />
begin<br />
glutInitPascal(False);<br />
glutInitDisplayMode(GLUT_DOUBLE or GLUT_RGB or GLUT_DEPTH);<br />
glutGameModeString(FSMode);<br />
glutEnterGameMode;<br />
glutSetCursor(GLUT_CURSOR_NONE);<br />
<br />
InitializeGL;<br />
<br />
glutDisplayFunc(@DrawGLScene);<br />
glutReshapeFunc(@ReSizeGLScene);<br />
glutKeyboardFunc(@GLKeyboard);<br />
glutIdleFunc(@DrawGLScene);<br />
<br />
glutMainLoop;<br />
end.<br />
<br />
Since we don't want GLUT to parse command line this time we call glutInitPascal with False parameter. As you can see, there is no code for window creation. GLUT have <b>glutEnterGameMode</b> that create full screen window. To specify what kind of full screen mode you want, you call <b>glutGameModeString</b> function which takes string that defines mode you like.<br />
Format of that string is:<br />
<br />
[width "x" height][":" bpp]["@" hertz]<br />
<br />
In FSMode string we declared that full screen mode should be 800x600, with 32bit pallete and 75Hz refresh. It is possible to skip one of the group. If you omit size, GLUT will try to use current one or first smaller that can work. That policy is used and for other parameters.<br />
<br />
Usually in full screen mode cursor is not visible. To hide cursor you use <b>glutSetCursor</b> function. It takes only one parameter which describes cursor you would like to see:<br />
GLUT_CURSOR_RIGHT_ARROW<br />
GLUT_CURSOR_LEFT_ARROW<br />
GLUT_CURSOR_INFO<br />
GLUT_CURSOR_DESTROY<br />
GLUT_CURSOR_HELP<br />
GLUT_CURSOR_CYCLE<br />
GLUT_CURSOR_SPRAY<br />
GLUT_CURSOR_WAIT<br />
GLUT_CURSOR_TEXT<br />
GLUT_CURSOR_CROSSHAIR<br />
GLUT_CURSOR_UP_DOWN<br />
GLUT_CURSOR_LEFT_RIGHT<br />
GLUT_CURSOR_TOP_SIDE<br />
GLUT_CURSOR_BOTTOM_SIDE<br />
GLUT_CURSOR_LEFT_SIDE<br />
GLUT_CURSOR_RIGHT_SIDE<br />
GLUT_CURSOR_TOP_LEFT_CORNER<br />
GLUT_CURSOR_TOP_RIGHT_CORNER<br />
GLUT_CURSOR_BOTTOM_RIGHT_CORNER<br />
GLUT_CURSOR_BOTTOM_LEFT_CORNER<br />
GLUT_CURSOR_FULL_CROSSHAIR<br />
GLUT_CURSOR_NONE<br />
GLUT_CURSOR_INHERIT<br />
<br />
<b>glutIdleFunc</b> defines callback function that you want to be called every time you program has no messages to process. Since we just want to render new frame if there is nothing to do, just set idle function to DrawGLScene.<br />
Some other tutorials show that idle function should send refresh message insted of drawing, but that way I have 50-100 frames less than using method I described.<br />
<br />
Now, let's look at the program termination where you need to exit full screen mode:<br />
<br />
procedure GLKeyboard(Key: Byte; X, Y: Longint); cdecl;<br />
begin<br />
if Key = 27 then<br />
begin<br />
glutLeaveGameMode;<br />
Halt(0);<br />
end;<br />
end;<br />
<br />
As you can see, all you need to do is to call <b>glutLeaveGameMode</b>.<br />
<br />
Now, we'll introduce some new matrix functions. First, let's change ReSizeGLScene function:<br />
<br />
procedure ReSizeGLScene(Width, Height: Integer); cdecl;<br />
begin<br />
.<br />
.<br />
.<br />
<br />
glMatrixMode(GL_MODELVIEW);<br />
glLoadIdentity;<br />
gluLookAt(0, 20, 25, 0, 0, 0, 0, 1, 0);<br />
end;<br />
<br />
<b>gluLookAt</b> create matrix that will define from where are you look to objects. First 3 parameters are X, Y and Z coordinate of position of camera. Next 3 parameters are X, Y and Z coordinate of point where camera look at, and last 3 parameters defines "up" vector (where is "up" for the camera). Usually, up is positive y axis.<br />
<br />
OK, let's draw now. Since you set matrix with gluLookAt that should be used with all objects, you can't just use glLoadIdentity to reset matrix for next object... you'll save previous matrix state and restore it after object is drawn:<br />
<br />
procedure DrawGLScene; cdecl;<br />
var<br />
T: Single;<br />
begin<br />
T := glutGet(GLUT_ELAPSED_TIME) / 1000;<br />
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);<br />
<br />
glPushMatrix;<br />
glRotatef(5 * T, 0, 1, 0);<br />
glColor3f(1, 1, 0);<br />
glutWireSphere(2, 20, 20);<br />
glPopMatrix;<br />
<br />
glPushMatrix;<br />
glRotatef(90 * T, 0, 1, 0);<br />
glTranslatef(5, 0, 0);<br />
glRotatef(40 * T, 0, 1, 0);<br />
glColor3f(1, 0, 0);<br />
glutWireSphere(0.6, 10, 10);<br />
glPopMatrix;<br />
<br />
glPushMatrix;<br />
glRotatef(60 * T, 0, 1, 0);<br />
glTranslatef(-3, 0, 9);<br />
glRotatef(50 * T, 0, 1, 0);<br />
glColor3f(0, 1, 0);<br />
glutWireSphere(1, 16, 16);<br />
<br />
glPushMatrix;<br />
glRotatef(360 * T, 0, 1, 0);<br />
glTranslatef(-1.7, 0, 0);<br />
glRotatef(50 * T, 0, 1, 0);<br />
glColor3f(0, 0, 1);<br />
glutWireSphere(0.4, 10, 10);<br />
glPopMatrix;<br />
<br />
glPopMatrix;<br />
<br />
glutSwapBuffers;<br />
end;<br />
<br />
[[Image:FullScreenAnimationPic1.jpg|thumb]] <b>glPushMatrix</b> i <b>glPopMatrix</b> are used to save and restore matrix state. As you can see, we save matrix state, then change matrix in order to draw object in right place, and then restore old matrix state.<br />
<br />
You may wonder what is <b>T</b> variable for. Well, it is used to determen animation speed. Every change that depends on time is multiplied with T. That way animation speed is constant on every frame rate.<br />
<b>glutGet</b> function with <b>GLUT_ELAPSED_TIME</b> parameter returns time in milliseconds from glutInit is called. By dividing that value with 1000, we get time in seconds.<br />
<br />
<b>glRotatef</b> function create rotation matrix. First parameter is angle in degrees, and last 3 parameters defines axis around which rotation will be done.<br />
Since you multiplied angle with T, object will be rotated by that angle in exactly 1 second.<br />
<br />
Download source code, linux executable or windows executable from [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=199145 Lazarus CCR SourceForge].<br />
<br />
=Light=<br />
<br />
This tutorial will introduce some light to the scene. You'll make rotating cube and one light which will add some realism to the scene, but first let's make some utility unit.<br />
<br />
For now it will have only basic functions to help us getting current and delta (time that elapsed from one render to other render call) times and for calculating frames per second.<br />
<br />
unit utils;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
interface<br />
<br />
uses<br />
glut;<br />
<br />
function GetTotalTime: Single;<br />
function GetDeltaTime: Single;<br />
procedure FrameRendered(Count: Integer = 1);<br />
function GetFPS: Single;<br />
<br />
implementation<br />
<br />
var<br />
OldTime: Integer = 0;<br />
FPSTime: Integer = 0;<br />
FPSCount: Integer = 0;<br />
<br />
function GetTotalTime: Single;<br />
begin<br />
Result := glutGet(GLUT_ELAPSED_TIME) / 1000;<br />
end;<br />
<br />
function GetDeltaTime: Single;<br />
var<br />
NewTime: Integer;<br />
begin<br />
NewTime := glutGet(GLUT_ELAPSED_TIME);<br />
Result := (NewTime - OldTime) / 1000;<br />
OldTime := NewTime;<br />
end;<br />
<br />
procedure FrameRendered(Count: Integer);<br />
begin<br />
Inc(FPSCount, Count);<br />
end;<br />
<br />
function GetFPS: Single;<br />
var<br />
NewTime: Integer;<br />
begin<br />
NewTime := glutGet(GLUT_ELAPSED_TIME);<br />
<br />
Result := FPSCount / ((NewTime - FPSTime) / 1000);<br />
<br />
FPSTime := NewTime;<br />
FPSCount := 0;<br />
end;<br />
<br />
end.<br />
<br />
As you can see, there is nothing complicated in this unit. Time is simply saved betwen calls and difference is returned. FrameRendered should be called every time you draw scene so function can calculate FPS.<br />
<br />
Now, let's have fun with lights.<br />
<br />
OpenGL have several types of light... ambient, diffuse, point, spot, specular and emissive light.<br />
<br />
Ambient light is something like Sun. When sun rays pass through the window of a room they hit the walls and are reflected and scattered into all different directions which averagely brightens up the whole room. All vertices are lit with ambient light.<br />
<br />
Diffuse light can be represented as parallel light rays comming from far away. They will lit only vertices that are oriented towards the light source.<br />
<br />
Point light lights all around it. It is like a fire ball, it send light rays all around it and lights vertices that are oriented towards light source and that are close enough.<br />
<br />
Spot light is like light from flashlight. It is simply a point light source with a small light cone radius. All vertices that falls inside of cone and are close enough are lit.<br />
<br />
Just like Diffuse light, Specular light is a directional type of light. It comes from one particular direction. The difference between the two is that specular light reflects off the surface in a sharp and uniform way. The rendering of specular light relies on the angle between the viewer and the light source. From the viewer’s standpoint specular light creates a highlighted area on the surface of the viewed object known as specular highlight or specular reflection.<br />
<br />
Emissive light is a little different than any other previously explained light components. This light comes out of object you draw but don't lit other objects in nearby.<br />
<br />
For simplicity we'll use only diffuse light in this tutorial. Later on, some other lights may appear in tutorials :)<br />
<br />
Let's see how to enable light in scene:<br />
<br />
const<br />
DiffuseLight: array[0..3] of GLfloat = (0.8, 0.8, 0.8, 1);<br />
<br />
glEnable(GL_LIGHTING);<br />
glLightfv(GL_LIGHT0, GL_DIFFUSE, DiffuseLight);<br />
glEnable(GL_LIGHT0);<br />
<br />
As you see, we enable lighting in OpenGL so lights affect scene you are rendering. Light parameters are set with <b>glLightfv</b> function. It takes 3 parameters... one for light number you want to change (OpenGL suports up to 8 lights), next tells OpenGL what light parameter to change, and the last one is new parameter for light.<br />
You'll set just diffuse color for light in this tutorial. After that, you can enable light and there will be light in the scene... but... that is not all.<br />
<br />
More about glLightfv: http://www.opengl.org//documentation/specs/man_pages/hardcopy/GL/html/gl/light.html<br />
<br />
If you want to use lights you can't just set color for vertex... you must set material for vertices. Let's setup material for drawing:<br />
<br />
glEnable(GL_COLOR_MATERIAL);<br />
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);<br />
<br />
[[Image:LightPic1.jpg|thumb]] You expected something more complicated, do you? :) Well, this code allows us to use glColor function to set material to vertices. By using glEnable function and GL_COLOR_MATERIAL flag, you can define what material properties will glColor change. <b>glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE)</b> tells OpenGL that glColor changes ambient and diffuse material. We'll discus materials more in later tutorials.<br />
<br />
One more thing that is important when using lights... every vertex must have normal associated with it. Normal is used to find the direction of vertex so light can be calculated properly. You'll use GLUT function to draw cube and it provides normals for us, so this time we'll just walk by normals.<br />
<br />
After all those setting ups, light will shine up your cube :)<br />
<br />
Part of the text is copied from [http://www.falloutsoftware.com/tutorials/gl/gl8.htm The OpenGL Light Bible]<br />
<br />
Download source code, linux executable or windows executable from [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=199145 Lazarus CCR SourceForge].<br />
<br />
=Bitmap fonts=<br />
<br />
Games and programs usually need to write some text on screen. GLUT provides several functions for drawing chars that are platform independent.<br />
<br />
First, we'll show how to use default bitmap fonts. Almost all code additions will be made to utils.pas unit.<br />
<br />
Since text will be drawn in 2D, we'll need to know width and height of viewport... so, we'll write two functions for that:<br />
<br />
function glGetViewportWidth: Integer;<br />
var<br />
Rect: array[0..3] of Integer;<br />
begin<br />
glGetIntegerv(GL_VIEWPORT, @Rect);<br />
Result := Rect[2] - Rect[0];<br />
end;<br />
<br />
function glGetViewportHeight: Integer;<br />
var<br />
Rect: array[0..3] of Integer;<br />
begin<br />
glGetIntegerv(GL_VIEWPORT, @Rect);<br />
Result := Rect[3] - Rect[1];<br />
end;<br />
<br />
We just get left/right, top/bottom and calculate width/height by subtracting them.<br />
<br />
There must be functions for entering and leaving 2D mode:<br />
<br />
procedure glEnter2D;<br />
begin<br />
glMatrixMode(GL_PROJECTION);<br />
glPushMatrix;<br />
glLoadIdentity;<br />
gluOrtho2D(0, glGetViewportWidth, 0, glGetViewportHeight);<br />
<br />
glMatrixMode(GL_MODELVIEW);<br />
glPushMatrix;<br />
glLoadIdentity;<br />
<br />
glDisable(GL_DEPTH_TEST);<br />
end;<br />
<br />
procedure glLeave2D;<br />
begin<br />
glMatrixMode(GL_PROJECTION);<br />
glPopMatrix;<br />
glMatrixMode(GL_MODELVIEW);<br />
glPopMatrix;<br />
<br />
glEnable(GL_DEPTH_TEST);<br />
end;<br />
<br />
When entering 2D mode, we save current matrices and set 2D matrix using <b>gluOrtho2D</b> function. This way if we draw some thing on 100, 100 it will be drawn on exactly 100 pixels from left edge of window, and 100 pixels form bottom edge (positive Y is up). Also, we disable ZBuffer. This way text won't alter ZBuffer.<br />
<br />
Leaving 2D mode just returns old matrices and enable ZBuffer.<br />
<br />
Now, we can create function for text drawing:<br />
<br />
procedure glWrite(X, Y: GLfloat; Font: Pointer; Text: String);<br />
var<br />
I: Integer;<br />
begin<br />
glRasterPos2f(X, Y);<br />
for I := 1 to Length(Text) do<br />
glutBitmapCharacter(Font, Integer(Text[I]));<br />
end;<br />
<br />
<b>glutBitmapCharacter</b> can draw only one character of selected font. First parameter is desired font (GLUT_BITMAP_9_BY_15, GLUT_BITMAP_8_BY_13, GLUT_BITMAP_TIMES_ROMAN_10, GLUT_BITMAP_TIMES_ROMAN_24, GLUT_BITMAP_HELVETICA_10, GLUT_BITMAP_HELVETICA_12 or GLUT_BITMAP_HELVETICA_18) and other one is character.<br />
<br />
Character will be drawn at current raster position. To set desired raster position we call <b>glRasterPos</b> function. glRasterPos can handle different number and types of parameters just like glVertex function. Coordinate specified is transformed by model and projection matrix to get 2D coordinate where new raster position will be. Since we entered 2D mode, X and Y coordinates are actual 2D coordinates where drawing will occur.<br />
<br />
This new functions will make text drawing very easy:<br />
<br />
procedure DrawGLScene; cdecl;<br />
begin<br />
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);<br />
<br />
glLoadIdentity;<br />
glTranslatef(0, 0, -5);<br />
glRotatef(GetTotalTime * 10, 0, 0.5, 0.5);<br />
<br />
glColor3f(1, 0, 0);<br />
glutSolidCube(2);<br />
<br />
glEnter2D;<br />
<br />
glColor3f(0.2, 0.8 + 0.2 * Sin(GetTotalTime * 5), 0);<br />
glWrite(20, glGetViewportHeight - 20, GLUT_BITMAP_8_BY_13,<br />
Format('OpenGL Tutorial :: Bitmap Fonts :: FPS - %.2f FPS', [FPS]));<br />
<br />
glColor3f(1, 1, 1);<br />
glWrite(50, glGetViewportHeight - 60, GLUT_BITMAP_9_BY_15, 'GLUT_BITMAP_9_BY_15');<br />
glWrite(50, glGetViewportHeight - 90, GLUT_BITMAP_8_BY_13, 'GLUT_BITMAP_8_BY_13');<br />
glWrite(50, glGetViewportHeight - 120, GLUT_BITMAP_TIMES_ROMAN_10, 'GLUT_BITMAP_TIMES_ROMAN_10');<br />
glWrite(50, glGetViewportHeight - 150, GLUT_BITMAP_TIMES_ROMAN_24, 'GLUT_BITMAP_TIMES_ROMAN_24');<br />
glWrite(50, glGetViewportHeight - 180, GLUT_BITMAP_HELVETICA_10, 'GLUT_BITMAP_HELVETICA_10');<br />
glWrite(50, glGetViewportHeight - 210, GLUT_BITMAP_HELVETICA_12, 'GLUT_BITMAP_HELVETICA_12');<br />
glWrite(50, glGetViewportHeight - 240, GLUT_BITMAP_HELVETICA_18, 'GLUT_BITMAP_HELVETICA_18');<br />
<br />
glColor3f(0.5, 0.5, 1);<br />
glWrite(<br />
glGetViewportWidth - glutBitmapLength(GLUT_BITMAP_9_BY_15, LazText) - 5,<br />
10, GLUT_BITMAP_9_BY_15, LazText);<br />
<br />
glLeave2D;<br />
<br />
glutSwapBuffers;<br />
<br />
FrameRendered;<br />
end;<br />
[[Image:BitmapFontsPic1.jpg|thumb]]<br />
We draw red cube and rotate it, and some text to show how various bitmap fonts look like.<br />
<b>glutBitmapLength</b> function is used to find width of string so it could be aligned to right. Code can easily be altered to center text.<br />
<br />
Note: See how cube looks without light.<br />
<br />
Download source code, linux executable or windows executable from [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=199145 Lazarus CCR SourceForge].<br />
<br />
=Textures=<br />
<br />
It's time to use textures :)<br />
<br />
This tutorial will show how to draw textured polygons and how to blend textures using multipass technic.<br />
Since OpenGL has no builtin mechanism for loading textures, we'll use external library: [http://imaginglib.sourceforge.net/ Vampyre Imaging Library].<br />
We'll use just OpenGL helper functions, but you may find this lib handy for some other things to.<br />
<br />
Let's get started... we'll create display list for drawing textured rectangle:<br />
<br />
procedure CreateList;<br />
begin<br />
glNewList(LIST_OBJECT, GL_COMPILE);<br />
glBegin(GL_QUADS);<br />
glTexCoord2f(1, 0);<br />
glVertex3f( 2, 2, 0);<br />
glTexCoord2f(0, 0);<br />
glVertex3f(-2, 2, 0);<br />
glTexCoord2f(0, 1);<br />
glVertex3f(-2,-2, 0);<br />
glTexCoord2f(1, 1);<br />
glVertex3f( 2,-2, 0);<br />
glEnd;<br />
glEndList;<br />
end;<br />
<br />
Notice <b>glTexCoord</b> functions. They are used to specify which part of texture is assigned to vertex. Coordinates defined in this functions are from 0 to 1 (values greater than 1 are allowed but can generate different results). 0 is first pixel and 1 is last pixel. So, 0.5 will be right in the middle of texture.<br />
<br />
Texture loading is extremely easy with Vampyre Imaging Library:<br />
<br />
var<br />
Tex1, Tex2: GLuint;<br />
<br />
procedure InitializeGL;<br />
begin<br />
glClearColor(0, 0, 0, 0);<br />
Tex1 := LoadGLTextureFromFile('ashwood.bmp');<br />
Tex2 := LoadGLTextureFromFile('Flare.bmp');<br />
glEnable(GL_TEXTURE_2D);<br />
end;<br />
<br />
<b>LoadGLTextureFromFile</b> loads texture from file and returns it's ID. When texture is loaded it is allready setup for rendering.<br />
Last line just enables 2D textures.<br />
<br />
To draw textured polygon you have to bind texture and setup texture coordinations (texture coordinations are set in display list in this tutorial):<br />
<br />
...<br />
glLoadIdentity;<br />
glTranslatef(-5, 0, -15);<br />
glBindTexture(GL_TEXTURE_2D, Tex1);<br />
glCallList(LIST_OBJECT);<br />
...<br />
<br />
<b>glBindTexture</b> function is used to select texture. When you draw polygins they will have selected texture on them. It's that easy :)<br />
<br />
So, using one texture is easy... but how to blend two textures. Basicly you draw polygon once with one texture, setup blending parameters, and draw polygon once more time with other texture. You can blend houndreds of textures this way. Let's see how code for this looks:<br />
<br />
...<br />
glLoadIdentity;<br />
glTranslatef(5, 0, -15);<br />
glBindTexture(GL_TEXTURE_2D, Tex1);<br />
glCallList(LIST_OBJECT);<br />
<br />
glEnable(GL_BLEND);<br />
glBlendFunc(GL_ZERO, GL_SRC_COLOR);<br />
glLoadIdentity;<br />
glTranslatef(5, 0, -15);<br />
glBindTexture(GL_TEXTURE_2D, Tex2);<br />
glCallList(LIST_OBJECT);<br />
glDisable(GL_BLEND);<br />
...<br />
<br />
As you can see, polygon is drawn first time like we allready know. Before second drawing we enable blending by calling <b>glEnable(GL_BLEND)</b>. Blending means that finall pixel color is calculated like this:<br />
<br />
DrawingColor * SRCBLEND + BackgroundColor * DESTBLEND<br />
<br />
SRCBLEND and DESTBLEND are defined using <b>glBlendFunc</b> function. In this tutorial we set SRCBLEND to GL_ZERO (zero) and DESTBLENT to GL_SRC_COLOR (DrawingColor) and finall color is then:<br />
<br />
DrawingColor * 0 + BackgroundColor * DrawingColor<br />
[[Image:TexturesPic1.jpg|thumb]]<br />
<br />
This means that background will get darker when you draw with dark colors... when you draw with white color, background color will not be changed. The result will look like this<br />
<br />
Next time, we'll use extensions to show how to use singlepass multitexturing.<br />
<br />
Download source code, linux executable or windows executable from [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=199145 Lazarus CCR SourceForge].<br />
<br />
=Multitexturing (extensions)=<br />
<br />
When youknow multipass multi texturing, singlepass is very easy. Texturing is separated in stages. First stage setup and draw first texture, second stage draws another one and so on. All you have to do is to setup texture stages and to render object.<br />
<br />
Let's see how code looks like:<br />
<br />
procedure InitializeGL;<br />
begin<br />
Load_GL_ARB_multitexture;<br />
glClearColor(0, 0, 0, 0);<br />
Tex1 := LoadGLTextureFromFile('Lazarus.bmp');<br />
Tex2 := LoadGLTextureFromFile('Mask.bmp');<br />
glActiveTextureARB(GL_TEXTURE0_ARB);<br />
glEnable(GL_TEXTURE_2D);<br />
glBindTexture(GL_TEXTURE_2D, Tex1);<br />
glActiveTextureARB(GL_TEXTURE1_ARB);<br />
glEnable(GL_TEXTURE_2D);<br />
glBindTexture(GL_TEXTURE_2D, Tex2);<br />
end;<br />
<br />
First we need load OpenGL extension that will allow us to use multitexture functions. <b>Load_GL_ARB_multitexture</b> will try to load those extensions and will return TRUE if operation was successful.<br />
<br />
To select texture stage you want to work on, use <b>glActiveTextureARB</b> function. It takes only one parameter that define which stage you want. After that all texture functions (enabling, disabling, binding, creating...) will affect that stage.<br />
<br />
Since we setup every thing in initialization function, all we have to do is to draw object:<br />
<br />
procedure DrawGLScene; cdecl;<br />
begin<br />
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);<br />
<br />
glLoadIdentity;<br />
glTranslatef(0, 0, -5);<br />
<br />
glBegin(GL_QUADS);<br />
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 0);<br />
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1, 0);<br />
glVertex3f(2.516, 2, 0);<br />
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 0);<br />
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0, 0);<br />
glVertex3f(-2.516, 2, 0);<br />
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 1);<br />
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0, 1);<br />
glVertex3f(-2.516,-2, 0);<br />
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 1);<br />
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1, 1);<br />
glVertex3f(2.516,-2, 0);<br />
glEnd;<br />
<br />
glutSwapBuffers;<br />
end;<br />
[[Image:MultitexturePic1.jpg|thumb]]<br />
As you can see, difference is only in defining texture coordinations. We now use <b>glMultiTexCoord2fARB</b> function that takes texture stage and texture coordinations. Every thing else is unchanged.<br />
<br />
Today almost all graphic cards supports at least 2 texture stages. Using singlepass multitexturing is faster than multipass version since you draw objects only once. If hardware supports singlepass multitexturing (Load_GL_ARB_multitexture returns TRUE) use it.<br />
<br />
Download source code, linux executable or windows executable from [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=199145 Lazarus CCR SourceForge].<br />
<br />
=Render to texture=<br />
<br />
This one will be short. OpenGL can capture current scene to texture so you can use it for texturing other objects (TV screen, mirror or some thing else). Well just render scene to texture and apply it to rotating plane.<br />
<br />
First, we must create empty texture which well use to capture scene:<br />
<br />
procedure SetupRenderTexture;<br />
var<br />
Data: Pointer;<br />
begin<br />
GetMem(Data, 256*256*3);<br />
glGenTextures(1, @RenderTexture);<br />
glBindTexture(GL_TEXTURE_2D, RenderTexture);<br />
glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, Data);<br />
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);<br />
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);<br />
FreeMem(Data);<br />
end;<br />
<br />
Buffer for 256*256 RGB image is created and it is used to setup 2D texture.<br />
<br />
Main part is in drawing function:<br />
<br />
procedure DrawGLScene; cdecl;<br />
var<br />
TotalTime: Single;<br />
begin<br />
glClearColor(0, 0, 0, 0);<br />
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);<br />
glEnable(GL_LIGHTING);<br />
glDisable(GL_TEXTURE_2D);<br />
glViewport(0, 0, 256, 256);<br />
<br />
TotalTime := GetTotalTime;<br />
<br />
glLoadIdentity;<br />
glTranslatef(0, 0, -5);<br />
glRotatef(50 * TotalTime, 1, 0, 0);<br />
glRotatef(100 * TotalTime, 0, 1, 0);<br />
glRotatef(50 * TotalTime, 0, 0, 1);<br />
<br />
glColor3f(1, 1, 1);<br />
glutSolidCube(2);<br />
<br />
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 256, 256, 0);<br />
<br />
glClearColor(0.18, 0.20, 0.66, 0);<br />
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);<br />
glDisable(GL_LIGHTING);<br />
glEnable(GL_TEXTURE_2D);<br />
glViewport(0, 0, AppWidth, AppHeight);<br />
<br />
glLoadIdentity;<br />
glTranslatef(0, 0, -7);<br />
glRotatef(20 * TotalTime, 1, 0, 0);<br />
glRotatef(50 * TotalTime, 0, 1, 0);<br />
<br />
glBegin(GL_QUADS);<br />
glTexCoord2f(1, 0);<br />
glVertex3f(2, 2, 0);<br />
glTexCoord2f(0, 0);<br />
glVertex3f(-2, 2, 0);<br />
glTexCoord2f(0, 1);<br />
glVertex3f(-2,-2, 0);<br />
glTexCoord2f(1, 1);<br />
glVertex3f(2,-2, 0);<br />
glEnd;<br />
<br />
glutSwapBuffers;<br />
end;<br />
[[Image:RenderToTexturePic1.jpg|thumb]]<br />
First, everything is setup for scene that will be captured. Viewport is reduced to 256*256 so it will fit into texture and scene is drawn. <b>glCopyTexImage2D</b> is used to capture scene to currently selected texture.<br />
<br />
When we have scene captured to texture, everything can be cleared again, viewport can be returned to original size and final scene is drawn using previous scene as texture.<br />
<br />
P.S. Captured texture can be saved using <b>SaveGLTextureToFile</b> function from [http://imaginglib.sourceforge.net/ Vampyre Imaging Library].<br />
<br />
Download source code, linux executable or windows executable from [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=199145 Lazarus CCR SourceForge].<br />
<br />
=Vertex array=<br />
<br />
OpenGL is capable of rendering primitives using data that is stored in buffers insted of calling glVertex. Buffers can be used to define vertex and texture coordinates, and colors (index and RGBA), normals and edge flags.<br />
<br />
In this tutorial well use only vertex and color buffers, and we'll show non-indexed and indexed drawing. Non-indexed mode draws buffers as streams. Indexed mode will draw buffer elements in order that is defined in index buffer. But enough talking... let's start coding.<br />
<br />
First, let's define some types and constants:<br />
<br />
type<br />
TVertex3f = record<br />
X, Y, Z: Single;<br />
end;<br />
<br />
TColor3f = record<br />
R, G, B: Single;<br />
end;<br />
<br />
VertexBuffer: array [0..5] of TVertex3f = (<br />
(X : 1; Y : 1; Z : 0),<br />
(X : -1; Y : 1; Z : 0),<br />
(X : -1; Y : -1; Z : 0),<br />
(X : 1; Y : 1; Z : 0),<br />
(X : -1; Y : -1; Z : 0),<br />
(X : 1; Y : -1; Z : 0)<br />
);<br />
ColorBuffer: array [0..5] of TColor3f = (<br />
(R : 1; G : 0; B : 1),<br />
(R : 0; G : 0; B : 1),<br />
(R : 0; G : 1; B : 0),<br />
(R : 1; G : 0; B : 1),<br />
(R : 0; G : 1; B : 0),<br />
(R : 1; G : 1; B : 0)<br />
);<br />
<br />
We have two buffers. One for vertex coordinates and one for vertex colors. This 6 vertices defines 2 triangles that forms rectangle.<br />
<br />
Drawing primitives using buffers is easy:<br />
<br />
glEnableClientState(GL_VERTEX_ARRAY);<br />
glEnableClientState(GL_COLOR_ARRAY);<br />
glVertexPointer(3, GL_FLOAT, 0, @VertexBuffer[0]);<br />
glColorPointer(3, GL_FLOAT, 0, @ColorBuffer[0]);<br />
<br />
glDrawArrays(GL_TRIANGLES, 0, Length(VertexBuffer));<br />
<br />
glDisableClientState(GL_VERTEX_ARRAY);<br />
glDisableClientState(GL_COLOR_ARRAY);<br />
<br />
First we enable buffers we want to use using <b>glEnableClientState</b> function. Than we can select buffers we want to use. Every buffer type has own function for selecting (<b>glColorPointer</b>, <b>glEdgeFlagPointer</b>, <b>glIndexPointer</b>, <b>glNormalPointer</b>, <b>glTexCoordPointer</b>, <b>glVertexPointer</b>).<br />
First parameter in those functions defines how many numbers every element contains. For example, let's take vertex buffer. If this parameter is 2 than OpenGL expects that every element in buffer contains x and y coordinate. If this parameter is, for example, 4, than every element should contains x, y, z and w coordinate.<br />
Next parameter defines what type of data element contains (GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT or GL_DOUBLE).<br />
Next one defines how many bytes are between each element. This way you can have buffer that contains vertex coordinates and some custom data. For arbitrary data type, this parameter can be calculated like this:<br />
<br />
type<br />
TBufferData = record<br />
DataBefore: TDataBefore;<br />
Vertex: TVertex;<br />
DataAfter: TDataAfter;<br />
end;<br />
<br />
Bytes between elements = SizeOf(TDataBefore) + SizeOf(TDataAfter)<br />
<br />
Last parameter if pointer to the begginig of buffer.<br />
<br />
When buffers are selected we can draw them using <b>glDrawArrays</b> functions. All enabled buffers are used to draw primitives. What kind of polygons are being generated is defined in first parameter (same as in glBegin function). Next two defines subset of buffer which is used for drawing (start and count).<br />
<br />
When buffers are not needed you can disable them.<br />
<br />
To demonstrate indexed mode, I made some simple mesh class that can load vertex, color and index data from external files:<br />
<br />
type<br />
TMesh = class<br />
private<br />
FVertices: array of TVertex3f;<br />
FColors: array of TColor3f;<br />
FIndices: array of Integer;<br />
procedure FreeBuffers;<br />
public<br />
constructor Create;<br />
destructor Destroy; override;<br />
procedure LoadMesh(FileName: String);<br />
procedure DrawMesh;<br />
end;<br />
<br />
FVertices will contain data about vertices, FColors data about color and FIndices data about indices when external file is loaded.<br />
<br />
First we'll write some code that deals with creation and destruction of class:<br />
<br />
procedure TMesh.FreeBuffers;<br />
begin<br />
FVertices := nil;<br />
FColors := nil;<br />
FIndices := nil;<br />
end;<br />
<br />
constructor TMesh.Create;<br />
begin<br />
FreeBuffers;<br />
end;<br />
<br />
destructor TMesh.Destroy;<br />
begin<br />
FreeBuffers;<br />
inherited Destroy;<br />
end;<br />
<br />
File that will contain mesh data is simple text file. First row will contain number of vertices and indices separated by space character. After that row will come rows for every vertex and color. X, Y, Z, R, G and B all separated by space character. In the end, there will be rows for indices... every index number is written in its own row... so, for one triangle, data file will look like this:<br />
<br />
3 3<br />
-1 -1 0 1 1 1<br />
1 -1 0 1 1 1<br />
0 1 0 1 1 1<br />
0<br />
1<br />
2<br />
<br />
This means that there is 3 vertices and 3 indices defined in file. First vrtex is at -1, -1, 0 and has color 1, 1, 1 and so on. Indices defines that order in which vertices are drawn (in this case vertices are drawn in the same order as they are defined).<br />
<br />
Code for loading this data will loke like this:<br />
<br />
procedure TMesh.LoadMesh(FileName: String);<br />
var<br />
MeshFile: TextFile;<br />
VertexCount, IndexCount: Integer;<br />
iV, iI: Integer;<br />
begin<br />
FreeBuffers;<br />
<br />
AssignFile(MeshFile, FileName);<br />
Reset(MeshFile);<br />
<br />
ReadLn(MeshFile, VertexCount, IndexCount);<br />
<br />
SetLength(FVertices, VertexCount);<br />
SetLength(FColors, VertexCount);<br />
SetLength(FIndices, IndexCount);<br />
<br />
for iV := 0 to VertexCount - 1 do<br />
ReadLn(MeshFile,<br />
FVertices[iV].X, FVertices[iV].Y, FVertices[iV].Z,<br />
FColors[iV].R, FColors[iV].G, FColors[iV].B);<br />
<br />
for iI := 0 to IndexCount - 1 do<br />
ReadLn(MeshFile, FIndices[iI]);<br />
<br />
CloseFile(MeshFile);<br />
end;<br />
<br />
After loading data, we have everything for drawing:<br />
<br />
procedure TMesh.DrawMesh;<br />
begin<br />
glEnableClientState(GL_VERTEX_ARRAY);<br />
glEnableClientState(GL_COLOR_ARRAY);<br />
glVertexPointer(3, GL_FLOAT, 0, @FVertices[0]);<br />
glColorPointer(3, GL_FLOAT, 0, @FColors[0]);<br />
<br />
glDrawElements(GL_TRIANGLES, Length(FIndices), GL_UNSIGNED_INT, @FIndices[0]);<br />
<br />
glDisableClientState(GL_VERTEX_ARRAY);<br />
glDisableClientState(GL_COLOR_ARRAY);<br />
end;<br />
<br />
As you can see, allmost everything is the same as for non-indexed drawing, except function that actually draw polygons. In this case we use <b>glDrawElements</b> function. For this one we specify what kind of polygons we want, how many indices are in index buffer, type of data in index buffer and pointer to the beginning of index buffer.<br />
<br />
[[Image:VertexArrayPic1.jpg|thumb]]Full source code comes with mesh data file that this class can use to generates rectangle that is identical with one that is drawn using non-indexed mode. Mesh data file looks like this:<br />
<br />
4 6<br />
1 1 0 1 0 1<br />
-1 1 0 0 0 1<br />
-1 -1 0 0 1 0<br />
1 -1 0 1 1 0<br />
0<br />
1<br />
2<br />
0<br />
2<br />
3<br />
<br />
As you can see, there is data for only 4 vertices and 6 indices. So, first triangle is defined by vertices 0, 1 and 2, and the seccond one by vertices 0, 2 and 3. By using indexed mode we don't have to duplicate vertices.<br />
<br />
Download source code, linux executable or windows executable from [http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=199145 Lazarus CCR SourceForge].<br />
<br />
<br />
[[category:Example programs]]<br />
<br />
-------<br />
[[Creating bindings for C libraries]]</div>Orankehttps://wiki.freepascal.org/index.php?title=User_talk:Oranke&diff=32376User talk:Oranke2008-11-27T15:06:40Z<p>Oranke: /* 번역중... */</p>
<hr />
<div>라자루스 위키 번역작업중.<br />
<br />
=== 번역중... ===<br />
<br />
* [[Lazarus_Documentation/ko]]<br />
* [[Nomenclature/ko]]<br />
* [[DesignGuidelines/ko]]<br />
* [[Overview_of_Free_Pascal_and_Lazarus/ko]] - 한 줄이 번역 안됨.<br />
* [[FPC_documentation/ko]]<br />
* [[Lazarus_Faq/ko]]<br />
<br />
=== 번역완료... ===<br />
<br />
* [[Main_Page/ko]] - Arilang님, Azrael님 고생하셨습니다.</div>Orankehttps://wiki.freepascal.org/index.php?title=User_talk:Oranke&diff=32375User talk:Oranke2008-11-27T15:06:25Z<p>Oranke: /* 번역중... */</p>
<hr />
<div>라자루스 위키 번역작업중.<br />
<br />
=== 번역중... ===<br />
<br />
* [[Lazarus_Documentation/ko]]<br />
* [[Nomenclature/ko]]<br />
* [[DesignGuidelines/ko]]<br />
* [[Overview_of_Free_Pascal_and_Lazarus/ko]] - 한 줄이 번역 안됨.<br />
* [[FPC_documentation/ko]]<br />
* Lazarus_Faq/ko<br />
<br />
=== 번역완료... ===<br />
<br />
* [[Main_Page/ko]] - Arilang님, Azrael님 고생하셨습니다.</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Faq/ko&diff=32374Lazarus Faq/ko2008-11-27T15:03:48Z<p>Oranke: /* 도대체 실행파일의 크기가 왜 이렇게 큰 겁니까? */</p>
<hr />
<div>{{Lazarus Faq}}<br />
<br />
이 문서는 원래 www.lazarus.freepascal.org 에 있던 것 입니다. 관리 및 확장 면에서 위키가 훨씬 더 유용하기 때문에 이 곳으로 복사되었습니다. <br />
<br />
== 일반적인 이야기 ==<br />
<br />
=== 더 많은 FAQ를 볼 수 있는 곳은 어디인가요? ===<br />
See the [http://www.lazarus.freepascal.org official website]. There is another FAQ as well.<br />
<br />
===도대체 실행파일의 크기가 왜 이렇게 큰 겁니까?===<br />
실행파일의 크기가 큰 이유는 GDB (GNU Debugger) 를 사용하기 위한 많은 정보들을 포함하고 있기 때문입니다. <br />
<br />
컴파일러에 이 디버깅 정보를 제거하기 위한 옵션 (-Xs) 이 있습니다만, 버전 2.0.2 이전의 컴파일러는 이 기능에 버그가 있기 때문에 제대로 동작하지 않습니다. 이 버그는 현재 개발버전에서는 수정되었습니다. <br />
<br />
"strip" 이라는 이름의 프로그램을 사용하면 실행파일로 부터 디버그 심볼을 삭제할 수 있습니다. 이 프로그램은 lazarus\pp\bin\i386-win32\ 에 있습니다. <br />
<br />
커맨드 라인에서 간단하게 "strip --strip-all <대상 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
실행파일을 좀 더 작게 만들려면, [http://upx.sourceforge.net/ UPX] 가 좋은 해법이 될 것입니다. UPX는 정말 멋진 실행파일 압축기 로서, 압축 해제에 추가적인 메모리가 필요없는 알고리즘을 사용합니다. (역자 주: 이 압축 알고리즘은 [http://www.oberhumer.com/opensource/lzo/ LZO] 라고 불리며, 오래 전 셀빅의 카마수트라 라는 어플에서 사용되었...^^) 또한 상당히 빠른 압축 해제 속도를 가지고 있습니다. (펜티엄 133에서 초당 10 MB 정도)<br />
<br />
커맨드 라인에서 간단하게 "upx <압축할 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
라자루스로 만든 간단한 GUI 어플리케이션의 경우 strip과 upx를 사용한 후 크기는 다음과 같습니다. <br />
* 리눅스 상에서는 ~ 700kb <br />
* 윈도우 상에서는 ~ 420kb<br />
<br />
A more detailed answer with the drawbacks of using UPX is given on [[Size Matters]].<br />
<br />
It's also important to note that the hello world lazarus software already includes a huge amount of features. It includes:<br />
<br />
* XML 제어 라이브러리<br />
* png, xpm, bmp 그리고 ico 파일을 다루는 이미지 라이브러리<br />
* 라자루스 컴포넌트 라이브러리의 위젯 대부분<br />
* 프리 파스칼 런타일 라이브러리 전체<br />
<br />
이런 이유로 매우 큰 크기를 가집니다만, 사실 여기에는 실제 어플리케이션이 필요로 하는 대부분의 기능들이 이미 포함되어 있습니다. <br />
<br />
라자루스 실행파일의 크기는 처음에는 매우 크지만 아주 조금씩 늘어나게 되는데, 이는 프리파스칼 컴파일러와 라자루스가 폼을 다루는 방식 때문 입니다. C++ 프로젝트의 경우 (뭐 다른 언어들도 마찬가지 입니다만) hello world 프로그램은 매우 작지만 조금만 복잡한 어플리케이션을 작성하려고 하면, 그 크기가 급격하게 늘어나게 됩니다. <br />
<br />
[[Image:Lazarus_vs_cpp.png]]<br />
<br />
=== Why is the linking so slow on Windows? ===<br />
<br />
This problem is over from FPC 2.2 and Lazarus 0.9.24. Please update your Lazarus. For older versions read text below.<br />
<br />
Generally speaking, compilation on Windows takes more time then other platforms because the GNU Linker utilized by Free Pascal is slow on this platform. This problem only affects Windows, and is only bad on relatively old computers (less then 1Ghz) and computers with little RAM (128MB or less).<br />
<br />
Also, if you smartlink LCL the linking will be much slower. A study about this is located here: [[File size and smartlinking]]<br />
<br />
A internal linker was developed, and is ready, but will only be available when Free Pascal 2.2 is released (of course it's also available via subversion). It decreases the linking time dramatically.<br />
<br />
'''Note''': In 2.1.1 Windows uses an internal linker for win32/64/ce which speeds the process up a bit. A Lazarus recompile then eats about 280MB.<br />
<br />
=== Do I need ppc386.cfg or fpc.cfg? ===<br />
<br />
You only need fpc.cfg. This way the compiler knows where to find the libraries.<br />
<br />
=== How do I compile lazarus? ===<br />
<br />
Do something like this:<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
=== How do I build other projects based upon the LCL ===<br />
<br />
If you can't use the IDE to build your applications, use lazbuild. This is a command line version of the IDE to build lazarus projects and packages.<br />
If you want to build LCL applications without the IDE and without the lazbuild, add the following lines to the end of your ''fpc.cfg''<br />
<br />
# searchpath for other toolkits (Linux)<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{YourToolKit}<br />
<br />
# searchpath for other toolkits (Windows)<br />
-Fu/{YourLazarusDirectory}/components/units/{YourToolKit}<br />
<br />
:Where {YourToolKit} may be ''gtk2'', ''gnome'', ''qt'' or ''win32'' and run:<br />
::ppc386 your.project.pp<br />
<br />
'''Hint:''' Don't forget to install the development packages for your toolkit otherwise you might a receive something like: [[Linker message: cannot find -l]].<br />
<br />
=== What version of FPC is required? ===<br />
<br />
2.0.4 for MacOSX and 2.2.2 for all other systems. Warning: The 2.2.0 has a bug under MacOSX with case sensitive filenames.<br />
You can also use the svn version of fpc 2.2.3 and 2.3.x.<br />
<br />
=== I can't compile Lazarus ===<br />
<br />
# Check if the compiler has the correct version<br />
# Check if the (fpc)libraries are from the same version.<br />
# Check if you have a fpc.cfg and no old ppc386.cfg<br />
# Check also the OS-dependent FAQs<br />
<br />
=== When I try to compile a project, I have an error ===<br />
==== "Cannot find Unit interfaces". How can I solve this?====<br />
It means the compiler can not find the file 'interfaces.ppu' '''or''' it means it found one, but it is wrong or outdated.<br />
<br />
This unit can be found in {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu. For example: /home/username/lazarus/lcl/units/i386-linux/gtk/interfaces.ppu.<br />
<br />
Make sure, it is only there. If you have multiple versions of interfaces.ppu, then you probably have a wrong configuration (for instance you added a lcl directory to a search path). Remove all interfaces.ppu, but the one in the directory above.<br />
<br />
If you selected a different widgetset than you used to build lazarus, you need to build the LCL for this widgetset. <br />
<br />
If it is there, but you get this error, you are using a different compiler / rtl for compiling your project than you used for compiling your Lazarus IDE. You can do one of the following<br />
* Rebuild the LCL (or Lazarus completely) with the compiler selected in the Environmnent Options. You can do this with Tools -> Build Lazarus. Before doing this, check the current settings in Tools -> Configure Build Lazarus.<br />
* Change the compiler in the Environment Options to the one you used to compile Lazarus. Look carefully also in the Environment Options to see if you are using the correct paths for the Lazarus Directory and the FPC sources directory. Check that there is only one version of the compiler configuration file fpc.cfg - it should reside in /etc/ for Linux/Unix systems or in the same directory as the fpc compiler for Windows systems. Try to run "fpc -vt bogus" to check which fpc.cfg is being used in your system. Rogue copies often creep in if you have updated your compiler to a new version; they may be found in your home directory or in the same directory as the one in which you built your new compiler. DELETE THESE!!<br />
* You may also try to change the widgetset currently selected for the project. For example, the sample project "objectinspector" that comes with Lazarus is set to gtk by default. Compiling this project will surely give you "Can't find unit interfaces" in Windows platform. Changing widgetset to default(Win32) in Project | Compiler Options... | LCL Widget Type (various) should fix this issue.<br />
<br />
=== When I try to compile delphi projects under lazarus, I have an error ===<br />
==== at the line :{$R *.DFM} How can I solve this problem ? ====<br />
<br />
Lazarus (or better Linux) doesn't know about resources, so you can't use them in the way Delphi/Win32 does. However Lazarus uses a method pretty compatible with this. You can still use your Delphi layouts (.dfm files) if you use the following steps:<br />
<br />
*You need a textual version of the .dfm files. D5 and higher are doing this as default. If you have older files: ALT-F12 to see the layout as text and paste/copy. When you have a text .dfm file, just copy it to a .lfm file.<br />
*Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm<br />
*Add the following initialization section to<br />
<br />
initialization<br />
{$I yourform.lrs}<br />
<br />
Please keep in mind that not all properties in the dfm are supported yet by<br />
lazarus, so you might get a crash.<br />
<br />
==== 'Identifier not found LazarusResources'. ====<br />
<br />
When creating a form Lazarus automaticaly add some extra units to the uses section of your form unit. During the conversion of a delphi unit to a Lazarus unit this does not happen. So you need to add LResources to the Uses section of your form unit.<br />
<br />
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===<br />
<br />
Make sure, in the Project -> Project Inspector, that your project depends on the package 'LCL' and that you have installed the FPC sources.<br />
<br />
Lazarus is the IDE and the visual components library LCL.<br />
All other stuff, like IO, Database, FCL and RTL are provided by FPC.<br />
The IDE needs the paths to all sources.<br />
<br />
The FPC source path can be set via:<br />
Environment -> Environment Options -> Files -> FPC source directory<br />
<br />
===How to embed a small file in the executable, without the need of a separate file? How to embed a resource?===<br />
<br />
For example:<br />
/your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...<br />
will create sound.lrs from sound1.wav and sound2.wav.<br />
<br />
Then include it *behind* the form lrs file:<br />
<br />
...<br />
initialization<br />
{$i unit1.lrs} // this is main resource file (first)<br />
{$i sound.lrs} // user defined resource file<br />
<br />
end.<br />
In your program you can then use:<br />
Sound1AsString:=LazarusResources.Find('sound1').Value;<br />
<br />
=== How can I see debug output? ===<br />
<br />
The LCL has in the LCLProc unit two procedures to write debug output. They are named: <br />
* '''DebugLn:''' which works about the same as WriteLn, but accepts only strings.<br />
* '''DbgOut:''' which works about the same as Write, but accepts only strings.<br />
<br />
In normal circumstances the output is written to stdout. If stdout is closed, (for example when the application is {$AppType Gui} or compiled with -WG on Windows), no output is written.<br />
<br />
Debug output can also be written to file. The initialization code of the LCLProc unit checks Lazarus.exe's command line parameters for '--debug-log=<file>'. On finding this parameter any subsequent debug output is sent to <file>.<br />
<br />
If no '--debug-log' command line parameter has been given, it next checks if an operating system environment variable xxx_debuglog exists, where xxx is the program file name without extension. For Lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses the file specified in the lazarus_debuglog environment variable as file to receive debug output. Example: if you do:<br />
set lazarus_debuglog=c:\lazarus\debug.txt<br />
debug output will be written to c:\lazarus\debug.txt.<br />
<br />
Since this is implemented in lclproc, every application using lclproc, can use this output facility.<br />
<br />
;Debuging Lazarus : Most useful for Windows: If you want output on a console, add {$APPTYPE console} to lazarus.pp ; Then rebuild Lazarus.<br />
<br />
=== What is the meaning of the various file extensions used by Lazarus? ===<br />
<br />
The [[Lazarus Tutorial#The Lazarus files]] explains some extensions by an example.<br />
Here is a brief list:<br />
<br />
; <code>*.lpi</code> : Lazarus Project Information file (stored in XML; contains project-specific settings)<br />
; <code>*.lpr</code> : Lazarus Program file; contains Pascal source of main program<br />
; <code>*.lfm</code> : Lazarus Form file; contains configuration information for all objects on a form (stored in a Lazarus-specific textual format; the actions are described by Pascal source code in a corresponding <code>*.pas</code> file)<br />
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code (typically for a form stored in a corresponding <code>*.lfm</code> file)<br />
; <code>*.lrs</code> : Lazarus Resource file (this is a generated file; not to be confused with a Windows resource file). <br />
: This file can be created with lazres tool (in directory Lazarus/Tools) using commandline: lazres myfile.lrs myfile.lfm<br />
; <code>*.ppu</code> : Compiled unit<br />
; <code>*.lpk</code> : Lazarus package information file. (stored in XML; contains package-specific settings)<br />
<br />
=== I have fixed/improved lazarus. How can I add my changes to the official lazarus source? ===<br />
Create a patch and send it to the developers. For details see [[Creating A Patch]].<br />
=== When I do ''var mytext: text;'' to declare a text file, I get "Unit1.pas(32,15) Error: Error in type definition". How can I fix this?===<br />
The TControl class has a [[doc:lcl/controls/tcontrol.text.html|Text]] property. In a method of a form, that has higher visibility, the [[doc:rtl/system/text.html|Text]] type from the system unit. You can use the [[doc:rtl/system/textfile.html|TextFile]] type, which is just an alias for the Text type or you can add the unit to the type definition.<br />
var<br />
MyTextFile: TextFile;<br />
MyText: System.Text;<br />
A similar name clash exists with assigning and closing a text file. TForm has a ''assign'' and a [[doc:lcl/forms/tcustomform.close.html|Close]] method. You can use [[doc:rtl/objpas/assignfile.html|AssignFile]] and [[doc:rtl/objpas/closefile.html|CloseFile]] or add the unit name ''System''.<br />
<br />
=== I get an error when using Printer.BeginDoc ===<br />
<br />
The unit Printers must be added to the uses section.<br />
<br />
The Printer4Lazarus package must be added to your project requirement in the IDE under:<br />
Project|Project Inspector|Add|New Requirement|Package Name:<br />
<br />
If the package Printer4Lazarus package is not in the list when opening the dropdown box it must be installed. The package is part of the Lazarus installation and can be found in:<br />
[lazarus installed directory]\components\printers<br />
<br />
If you used the default installation directories [lazarus installed directory] is:<br />
*Windows: c:\lazarus <br />
*Linux: /usr/lib/lazarus<br />
<br />
The same solution also applies to the exception you can get when referencing Printer.Printers<br />
<br />
=== Why are TForm.ClientWidth/ClientHeight the same as TForm.Width/Height ===<br />
<br />
The TForm.Width/Height do no include the frame, because there was no way to retrieve the frame size on all platforms. Without a reliable way, the LCL would move the forms around on the screen or resize them endlessly.<br />
<br />
Eventually when there is a reliable way to get the size and position of a window with its frame on all platforms, then it will be changed. To keep compatibility with older LCL forms, a version number and some extra methods will be added.<br />
<br />
=== I created a Patch to dock the IDE Messages form on the "Source Code Editor" form (at bottom) ===<br />
<br />
Such patches will not be applied, because they only implement a small part of the needed docking. The goal is to create a complete dock manager and use that. A complete dock manager can dock all IDE windows and it allows to let the user define how to dock. For example dock the messages window above or below the source editor or ... or not at all. For instance:<br />
<br />
<pre><br />
+-------------------++--+<br />
|menu || |<br />
+-------------------+| |<br />
+--++---------------+| |<br />
|PI|| Source Editor ||CE|<br />
+--+| || |<br />
+--+| || |<br />
| |+---------------++--+<br />
|OI|+-------------------+<br />
| ||messages |<br />
+--++-------------------+<br />
</pre><br />
<br />
The dock manager can store the layout and restore it on next load. Preferably the dock manager can dock in pages too. The dock manager does not need to use drag and drop.<br />
All patches implementing docking without a dock manager makes it harder to implement a real dock manager and will be rejected.<br />
<br />
=== How can I become a developer lazarus and access management in the SVN and bug-tracker? ===<br />
<br />
First of all: you must learn about Lazarus, to prove your knowledge and skill.<br />
Start by reading the [[Lazarus_Documentation|wiki articles]], read the Lazarus source code, giving a look at the [http://www.lazarus.freepascal.org/mantis Lazarus Bug-Tracker], fix some bugs, and if you think you are ready, contact the developers on the [http://www.mail-archive.com/lazarus@miraclec.com mailing list].<br />
<br />
== Where is ... defined ==<br />
<br />
=== Virtual key constants ===<br />
Virtual key constants are defined in LCLType. Add LCLtype to your <b>uses</b>.<br />
<br />
== Using the IDE ==<br />
<br />
=== How can I use "identifier completion"? ===<br />
You can invoke identifier completion by pressing [ctrl][space].<br />
Under the menu item ''Environment -> Editor Options -> Code Tools -> Automatic Features'' you can set how quick this should happen automatically.<br />
<br />
== Linux ==<br />
<br />
=== How can I debug on Linux without the IDE? ===<br />
<br />
First of all you need a debugger. gdb is the standard debugger under linux and<br />
there are several GUI-frontends available. One common frontend is ddd, which is<br />
part of most common distributions. To compile lazarus/lcl with debug-information<br />
you should then use the following commands to start a debug session:<br />
<br />
$ make clean; make OPT=-dDEBUG<br />
$ ddd lazarus<br />
<br />
Be warned however, that ddd is not as comfortable as e.g. the Lazarus debugger.<br />
Specially if it comes to view the contents of a variable you have to take into<br />
account that ddd/gdb are case sensitive whereas Pascal is case-insensitive.<br />
Therefore you have to type all variable names in uppercase to see their<br />
contents. For more information take a look into the fpc-manuals.<br />
<br />
=== I can debug now but ddd does not find my sources or complains that they contain no code. Whats that? ===<br />
<br />
This is a path-related problem with either gdb or ddd. You can aviod this by<br />
<br />
* Use the "Change directory" command from the ddd menu and choose the directory where the sources are located. The drawback of this method is that you now can't use the source of the program you started with (e.g. lazarus). Thus it may be neccessary to change the directory multiple times.<br />
* In ddd goto [Edit] [gdb-settings] and set the search-path<br />
* Create a $(HOME)/.gdbinit file like:<br />
directory /your/path/to/lazarus<br />
directory /your/path/to/lazarus/lcl<br />
directory /your/path/to/lazarus/lcl/include<br />
<br />
=== I receive an error during the linking that states /usr/bin/ld can't find -l<some lib> ===<br />
<br />
; '''Package Based Distributions''' : You need to install the package that provides the lib<somelib>.so or lib<somelib>.a files. Dynamic libs under linux have the extension .so, while static libs have the extension .a. On some Linux distro's you have installed the package (rpm, deb) <packagename> which provides <some lib>, but you also need the development package (rpm, deb), normally called <packagename>-dev, which contains the .a (static lib) and/or the .so (dynamic lib). <br />
: Some distributions have commands to find which package contains a file:<br />
: '''Mandriva'''<br />
<br />
[]$ urpmf lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -devel<br />
<br />
: '''Debian'''<br />
<br />
:install the apt-file utility (apt-get install apt-file) then<br />
<br />
[]$ apt-file search lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -dev<br />
<br />
<br />
<br />
; '''Source Based Distributions and Manual Compilation (LFS)''' : Make sure that there is a lib<somelib>.a in the path, and that it contains the right version. To let the linker find the dynamic library, create a symlink called lib<some lib>.so to lib<some lib><version>-x,y.so if necessary (and/or for static lib; lib<some lib>.a to lib<some lib><version>-x,y.a).<br />
<br />
; '''FreeBSD''' : As source based distro's, and also make sure you have -Fl/usr/local/lib in your fpc.cfg and/or Lazarus library path. Keep in mind that GTK1.2 has "gtk12" as package name under FreeBSD. (same for glib) NOTE: This has changed as of late. Newest ports have gtk-12 and glib-12 as well. You might stumble on this problem, since FPC requires the "-less" ones, you will need to symlink them like this:<br />
<br />
[]# cd /usr/local/lib && ln -s libglib-12.so libglib12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgtk-12.so libgtk12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgdk-12.so libgdk12.so<br />
<br />
; '''NetBSD''' : As source based distro's, and also make sure you have -Fl/usr/pkg/lib in your fpc.cfg and/or Lazarus library path<br />
<br />
=== How can I convert a kylix 2 project into a lazarus project? ===<br />
<br />
Nearly the same way as converting a Kylix project into a Delphi/VCL project.<br />
<br />
The LCL (Lazarus Component Library) tries to be compatible to Delphis VCL.<br />
Kylix CLX tries to be QT compatible.<br />
Here are some general hints:<br />
<br />
* Rename all used CLX Q-units like QForms, QControls, QGraphics, ... into their VCL counterparts: Forms, Controls, Graphics, ...<br />
* Add LResources to the uses section of every form source<br />
* Rename or copy all .xfm files to .lfm files.<br />
* Rename or copy .dpr file to .lpr file.<br />
* Add "Interfaces" to the uses section in the .lpr file.<br />
* Remove {$R *.res} directive<br />
* Remove {$R *.xfm} directive<br />
* Add {$mode objfpc}{$H+} or {$mode delphi}{$H+} directive to .pas and .lpr files<br />
* Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):<br />
initialization<br />
{$I unit1.lrs}<br />
:The .lrs files can be created via the lazres tool in: (lazarusdir)/tools/lazres.<br />
:For example: ./lazres unit1.lrs unit1.lfm<br />
<br />
* Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.<br />
<br />
* To make it more platform independant, reduce unit libc (which is deprecated) references and substitute with native FPC units like baseunix/unix as much as possible. This will be necessary to support other targets than linux/x86 (including OS X, FreeBSD and Linux/x86_64)<br />
<br />
=== When compiling lazarus the compiler can not find a unit. e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB ===<br />
<br />
1. Check a clean rebuild: do a 'make clean all'<br />
<br />
2. Check if the compiler has the correct version (2.0.4 or higher)<br />
<br />
3. Check if the compiler is using the right config file. The normal installation creates /etc/fpc.cfg. But fpc also searches for ~/.ppc386.cfg, ~/.fpc.cfg, /etc/ppc386.cfg and it uses only the first it finds.<br />
<br />
:'''Hint:''' You can see which config file is used with 'ppc386 -vt bogus'<br />
:Remove any ppc386.cfg as it is really obsolete.<br />
<br />
4. Check if the config file (/etc/fpc.cfg) contains the right paths to your fpc libs. There must be three lines like this:<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*<br />
:The first part of these paths (/usr/lib/fpc) depends on your system. On some systems this can be for example /usr/local/lib/fpc/... .<br />
:'''Hint:''' You can see your searchpaths with 'ppc386 -vt bogus'<br />
<br />
5. Check that the config file (/etc/fpc.cfg) does not contain search paths to the lcl source files (.pp, .pas):<br />
forbidden: -Fu(lazarus_source_directory)/lcl<br />
forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk<br />
:If you want to add the lcl for all your fpc projects, make sure that the two paths look like the following and are placed after the above fpc lib paths:<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk<br />
<br />
6. Check if the missing unit (glib.ppu) exists in your fpc lib directory. For example the gtk.ppu can be found in /usr/lib/fpc/$fpcversion/units/i386-linux/gtk/. If it does not exists, the fpc lib is corrupt and should be reinstalled.<br />
<br />
7. Check if the sources are in a NFS mounted directory. In some cases the NFS updates created files incorrectly. Please, try to move the sources into a non NFS directory and compile there.<br />
<br />
8. If you are still not succeeded try to use samplecfg script as follows:<br />
<br />
''#'' cd /usr/lib/fpc/''version''/<br />
<br />
''#'' sudo ./samplecfg /usr/lib/fpc/''\$version'' /etc<br />
<br />
Note! Do not put - / - after etc because if you do that the system will create a file - /etc/fpc.cfg/fpc.cfg. In fact we want that samplecfg make a file - /etc/fpc.cfg - not the folder /etc/fpc.cfg.<br />
<br />
=== I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS ===<br />
<br />
Probably you are using a newer fpc package, than that used for building the<br />
lazarus binaries. The best solution is to download the sources and compile<br />
lazarus manually. You can download the source snapshot or get the source<br />
via svn:<br />
<br />
$ bash<br />
$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
Make sure that lazarus get the new source directory:<br />
Environment->General Options->Files->Lazarus Directory Top<br />
<br />
===Lazarus compiles, but linking fails with: libgdk-pixbuf not found===<br />
Install the gdk-pixbuf library for gtk1.x:<br />
<br />
Where to find the gdk-pixbuf library:<br />
<br />
RPMs:<br />
http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=<br />
<br />
Debian packages:<br />
libgdk-pixbuf-dev<br />
<br />
Sources:<br />
ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/<br />
<br />
===I have SuSE and I get /usr/bin/ld: cannot find -lgtk Error: Error while linking===<br />
SuSE installs the gtk devel libs under /opt/gnome/lib (or /opt/gnome/lib64 for 64 bits), which is not in<br />
the standard lib path. Simply add it to your /etc/fpc.cfg.<br />
(-Fl/opt/gnome/lib).<br />
<br />
===Lazarus crashes with runtime error 211 after I installed a component===<br />
After I installed a component, Lazarus crashes with the following message:<br />
Threading has been used before cthreads was initialized.<br />
Make cthreads one of the first units in your uses clause.<br />
Runtime error 211 at $0066E188<br />
How can I fix this?<br />
<br />
Your freshly installed component is using threads. FPC on *nix doesn't automatically include threading support, but it must be intialized. This initialization is done in the cthreads unit. Every application using the component needs to add this unit to the uses clause of the main program. Lazarus itself is no exception. This can be done in two ways:<br />
<br />
1) Open the package. In the package editor click on ''Options''. Under page ''Usage'' add to the ''custom'' options '''-dUseCThreads'''. Then rebuild the IDE. This way the cthreads unit will be automatically used by the IDE under unix and the cthreads are initialized.<br />
<br />
2) In order to avoid modifying package, a fpc compiler option could be used directly. Open menu Tools->Configure "build Lazarus". Configure "build Lazarus" dialog will be shown, in field "Options:" type -Facthreads and then press "OK" button. The next step is to install the package. Lazarus will be built with option -Facthreads which means that it will treat main program as if unit cthreads where first in uses clause. <br />
<br />
''Hint:'' Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.<br />
<br />
See also [[Multithreaded_Application_Tutorial#Units_needed_for_a_multithreaded_application]]<br />
<br />
===When I run a program with threads I get runtime error 232===<br />
The complete error message is:<br />
This binary has no thread support compiled in.<br />
Recompile the application with a thread-driver in the program uses<br />
clause before other units using thread.<br />
Runtime error 232<br />
'''Solution''': Add cthreads as first unit to the uses clause of your main program, usually the .lpr-file.<br />
<br />
===I have Ubuntu Breezy and my fonts in Lazarus IDE look too big===<br />
If Lazarus is compiled with Gtk1.2, the settings in Gnome Preferences/Font don't have any effect as<br />
they are related to Gtk2.<br />
You could try this solution:<br />
Create a file named .gtkrc.mine in your home directory (if it's not already there) and add<br />
these lines to it:<br />
<br />
<pre><br />
style "default-text" {<br />
fontset = "-*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\<br />
-*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"<br />
}<br />
<br />
class "GtkWidget" style "default-text"<br />
</pre><br />
<br />
If this is not enough try and create also a .gtkrc symlink to .gtkrc.mine . It worked in this way under Xubuntu 7.10.<br />
<br />
===How can my gtk programs use custom rc files?===<br />
<br />
Option a)<br />
Name the rc file ''yourprogram.gtkrc'' and put it in the same directory where the executable is.<br />
<br />
Option b)<br />
Use unit ''GtkInt'' and call ''GTKWidgetSet.SetRCFilename('your_preferred_rc_file');''<br />
Best done before ''Application.Initialize'' in the .lpr file with ''{$IFDEF LCLGtk}''.<br />
<br />
===I have Ubuntu and I cannot compile for Gtk2 due to missing libraries===<br />
Ubuntu has a problem with not creating all the symbolic links that you'll need even when the libraries are installed. Make sure that all missing libraries when trying to link for Gtk2 have their appropriate links. For instance, you might need to do:<br />
<br />
<pre><br />
cd /usr/lib<br />
sudo ln -s libgdk-x11-2.0.so.0 libgtk-x11-2.0.so<br />
</pre><br />
<br />
Make sure that the [whatever].so symbolic links are created and point to the actual libraries.<br />
<br />
===How can I compile a program for Gtk2?===<br />
<br />
At the moment, the Gtk2 compiled IDE is a little unstable, but you can compile software for Gtk2 using the Gtk1 IDE.<br />
<br />
To start with recompile LCL for Gtk2. Go to the menu "Tools"->"Configure Build Lazarus" and set LCL to clean+build and everything else to none.<br />
<br />
Now click Ok and go to the menu "Tools"->"Build Lazarus"<br />
<br />
Now you can compile your software with Gtk2 going on the Compiler options and changing the widgetset to Gtk2.<br />
<br />
===I get this message: "[WARNING] ** Multibyte character encodings (like UTF8) are not supported at the moment."===<br />
<br />
Since revision 10535 (0.9.21) this message doesn't exist anymore. <br />
Previously it was used to warn that a UTF-8 encoding was used. The internal keyhandling routines for the gtk1 widgetset couldn't handle such encoding for keypresses, with the result that keypresses with for instance accented chars were not or wrong detected.<br />
<br />
(original text for older versions of lazarus)<br><br />
<strike><br />
This warning message indicates that your locale enconding is set to utf-8. If you are using Gtk 1 this can be a serious problem and prevent the correct working of Lazarus or software created with Lazarus.<br />
<br />
To work around this, just change your locale to a non utf-8 before executing the program on the command line, like this:<br />
<br />
<pre><br />
export LC_CTYPE="pt_BR"<br />
export LANG="pt_BR"<br />
export LANGUAGE="pt_BR"<br />
./lazarus<br />
</pre><br />
<br />
Substitute pt_BR with the locale for your country. You can create a script to automate this.<br />
</strike><br />
<br />
== Windows ==<br />
<br />
=== When I cycle the compiler, I get:The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time. ===<br />
<br />
In the compiler directory there is an OS2 scriptfile named make.cmd. Different versions of Windows also see this as a script file, so remove it since what is needed for OS2 becomes a hindrance on Windows.<br />
<br />
=== When I cycle the compiler, I get: make[3]: ./ppc1.exe: Command not found ===<br />
<br />
I don't know why but somehow make has lost its path. Try to cycle with a<br />
basedir set like: make cycle BASEDIR=your_fpc_source_dir_herecompiler<br />
<br />
=== When I try to make Lazarus I get:===<br />
====make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2 ====<br />
You need to upgrade your make.<br />
<br />
====makefile:27: *** You need the GNU utils package to use this Makefile. Stop.====<br />
Make sure you didn't install FPC in a path with spaces in the name. The<br />
Makefile doesn't support it.<br />
<br />
<br />
<br />
===How can I give my program an XP look like lazarus has?===<br />
Project -> Project Options -> Check 'Use manifest to enables themes'.<br />
<br />
===When I run Windows program created in Lazarus it starts with a DOS window===<br />
Specify the -WG argument (Windows GUI) on the command line of the compiler or in the Lazarus IDE check the Windows GUI check box on the compiler options dialog box (Project menu -> Compiler Options -> Linking -> target OS Specific options.<br />
<br />
== Mac OS X ==<br />
<br />
=== Why does compiling a project fail with 'unknown section attribute: no_dead_strip'?===<br />
<br />
Dead code stripping is not supported by the assembler and linker before Xcode 1.5 (available for Mac OS X 10.3.9). Disable the compiler options <br />
<br />
*Code > Unit style > Smart linkable (-CX) <br />
*and Linking > Link Style > Link smart (-XX)<br />
<br />
== Licensing ==<br />
<br />
=== Can I make commercial applications with Lazarus ? ===<br />
<br />
Yes, the LCL is licensed under the LGPL with an exception, which allows you to link to it statically without releasing the source of your application. Modifications and enhancements to the LCL must be distributed with source. Lazarus, the IDE, is licensed under the GPL.<br />
<br />
=== Can I make commercial plug-ins for Lazarus ? ===<br />
<br />
Yes, the IDEIntf part of the IDE is licensed under the LGPL with the same exception, so that shared data structures in this part will not force you to license your plug-in or design-time package under the GPL. You are free to choose a plug-in of any license; we don't want to limit your choice. Therefore non-GPL compatible plug-ins are allowed. Note that it's not allowed to distribute a precompiled Lazarus with these non-GPL-compatible plugins included statically; however, we do not see this as a severe limitation, since recompiling Lazarus is easy.<br />
<br />
== Contributors and Comments ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq version].</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Faq/ko&diff=32371Lazarus Faq/ko2008-11-27T14:53:52Z<p>Oranke: /* 도대체 실행파일의 크기가 왜 이렇게 큰 겁니까? */</p>
<hr />
<div>{{Lazarus Faq}}<br />
<br />
이 문서는 원래 www.lazarus.freepascal.org 에 있던 것 입니다. 관리 및 확장 면에서 위키가 훨씬 더 유용하기 때문에 이 곳으로 복사되었습니다. <br />
<br />
== 일반적인 이야기 ==<br />
<br />
=== 더 많은 FAQ를 볼 수 있는 곳은 어디인가요? ===<br />
See the [http://www.lazarus.freepascal.org official website]. There is another FAQ as well.<br />
<br />
===도대체 실행파일의 크기가 왜 이렇게 큰 겁니까?===<br />
실행파일의 크기가 큰 이유는 GDB (GNU Debugger) 를 사용하기 위한 많은 정보들을 포함하고 있기 때문입니다. <br />
<br />
컴파일러에 이 디버깅 정보를 제거하기 위한 옵션 (-Xs) 이 있습니다만, 버전 2.0.2 이전의 컴파일러는 이 기능에 버그가 있기 때문에 제대로 동작하지 않습니다. 이 버그는 현재 개발버전에서는 수정되었습니다. <br />
<br />
"strip" 이라는 이름의 프로그램을 사용하면 실행파일로 부터 디버그 심볼을 삭제할 수 있습니다. 이 프로그램은 lazarus\pp\bin\i386-win32\ 에 있습니다. <br />
<br />
커맨드 라인에서 간단하게 "strip --strip-all <대상 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
실행파일을 좀 더 작게 만들려면, [http://upx.sourceforge.net/ UPX] 가 좋은 해법이 될 것입니다. UPX는 정말 멋진 실행파일 압축기 로서, 압축 해제에 추가적인 메모리가 필요없는 알고리즘을 사용합니다. (역자 주: 이 압축 알고리즘은 [http://www.oberhumer.com/opensource/lzo/ LZO] 라고 불리며, 오래 전 셀빅의 카마수트라 라는 어플에서 사용되었...^^) 또한 상당히 빠른 압축 해제 속도를 가지고 있습니다. (펜티엄 133에서 초당 10 MB 정도)<br />
<br />
커맨드 라인에서 간단하게 "upx <압축할 실행파일의 경로와 이름>" 을 입력 하세요.<br />
<br />
라자루스로 만든 간단한 GUI 어플리케이션의 경우 strip과 upx를 사용한 후 크기는 다음과 같습니다. <br />
* 리눅스 상에서는 ~ 700kb <br />
* 윈도우 상에서는 ~ 420kb<br />
<br />
A more detailed answer with the drawbacks of using UPX is given on [[Size Matters]].<br />
<br />
It's also important to note that the hello world lazarus software already includes a huge amount of features. It includes:<br />
<br />
* XML handling library<br />
* Image handling library for png, xpm, bmp and ico files<br />
* Almost all widgets from the Lazarus Component Library<br />
* All of the Free Pascal Runtime Library<br />
<br />
So it's very big, but it already includes almost everything a real world non-trivial app will need.<br />
<br />
Lazarus executable size starts big, but grows very slowly, because of the Free Pascal compiler and the way lazarus forms operate. A c++ project (just an example, but applies to other languages / tools too) starts very small on the hello world, but quickly grows exponentially when you need features to write a non-trivial application.<br />
<br />
[[Image:Lazarus_vs_cpp.png]]<br />
<br />
=== Why is the linking so slow on Windows? ===<br />
<br />
This problem is over from FPC 2.2 and Lazarus 0.9.24. Please update your Lazarus. For older versions read text below.<br />
<br />
Generally speaking, compilation on Windows takes more time then other platforms because the GNU Linker utilized by Free Pascal is slow on this platform. This problem only affects Windows, and is only bad on relatively old computers (less then 1Ghz) and computers with little RAM (128MB or less).<br />
<br />
Also, if you smartlink LCL the linking will be much slower. A study about this is located here: [[File size and smartlinking]]<br />
<br />
A internal linker was developed, and is ready, but will only be available when Free Pascal 2.2 is released (of course it's also available via subversion). It decreases the linking time dramatically.<br />
<br />
'''Note''': In 2.1.1 Windows uses an internal linker for win32/64/ce which speeds the process up a bit. A Lazarus recompile then eats about 280MB.<br />
<br />
=== Do I need ppc386.cfg or fpc.cfg? ===<br />
<br />
You only need fpc.cfg. This way the compiler knows where to find the libraries.<br />
<br />
=== How do I compile lazarus? ===<br />
<br />
Do something like this:<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
=== How do I build other projects based upon the LCL ===<br />
<br />
If you can't use the IDE to build your applications, use lazbuild. This is a command line version of the IDE to build lazarus projects and packages.<br />
If you want to build LCL applications without the IDE and without the lazbuild, add the following lines to the end of your ''fpc.cfg''<br />
<br />
# searchpath for other toolkits (Linux)<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{YourToolKit}<br />
<br />
# searchpath for other toolkits (Windows)<br />
-Fu/{YourLazarusDirectory}/components/units/{YourToolKit}<br />
<br />
:Where {YourToolKit} may be ''gtk2'', ''gnome'', ''qt'' or ''win32'' and run:<br />
::ppc386 your.project.pp<br />
<br />
'''Hint:''' Don't forget to install the development packages for your toolkit otherwise you might a receive something like: [[Linker message: cannot find -l]].<br />
<br />
=== What version of FPC is required? ===<br />
<br />
2.0.4 for MacOSX and 2.2.2 for all other systems. Warning: The 2.2.0 has a bug under MacOSX with case sensitive filenames.<br />
You can also use the svn version of fpc 2.2.3 and 2.3.x.<br />
<br />
=== I can't compile Lazarus ===<br />
<br />
# Check if the compiler has the correct version<br />
# Check if the (fpc)libraries are from the same version.<br />
# Check if you have a fpc.cfg and no old ppc386.cfg<br />
# Check also the OS-dependent FAQs<br />
<br />
=== When I try to compile a project, I have an error ===<br />
==== "Cannot find Unit interfaces". How can I solve this?====<br />
It means the compiler can not find the file 'interfaces.ppu' '''or''' it means it found one, but it is wrong or outdated.<br />
<br />
This unit can be found in {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu. For example: /home/username/lazarus/lcl/units/i386-linux/gtk/interfaces.ppu.<br />
<br />
Make sure, it is only there. If you have multiple versions of interfaces.ppu, then you probably have a wrong configuration (for instance you added a lcl directory to a search path). Remove all interfaces.ppu, but the one in the directory above.<br />
<br />
If you selected a different widgetset than you used to build lazarus, you need to build the LCL for this widgetset. <br />
<br />
If it is there, but you get this error, you are using a different compiler / rtl for compiling your project than you used for compiling your Lazarus IDE. You can do one of the following<br />
* Rebuild the LCL (or Lazarus completely) with the compiler selected in the Environmnent Options. You can do this with Tools -> Build Lazarus. Before doing this, check the current settings in Tools -> Configure Build Lazarus.<br />
* Change the compiler in the Environment Options to the one you used to compile Lazarus. Look carefully also in the Environment Options to see if you are using the correct paths for the Lazarus Directory and the FPC sources directory. Check that there is only one version of the compiler configuration file fpc.cfg - it should reside in /etc/ for Linux/Unix systems or in the same directory as the fpc compiler for Windows systems. Try to run "fpc -vt bogus" to check which fpc.cfg is being used in your system. Rogue copies often creep in if you have updated your compiler to a new version; they may be found in your home directory or in the same directory as the one in which you built your new compiler. DELETE THESE!!<br />
* You may also try to change the widgetset currently selected for the project. For example, the sample project "objectinspector" that comes with Lazarus is set to gtk by default. Compiling this project will surely give you "Can't find unit interfaces" in Windows platform. Changing widgetset to default(Win32) in Project | Compiler Options... | LCL Widget Type (various) should fix this issue.<br />
<br />
=== When I try to compile delphi projects under lazarus, I have an error ===<br />
==== at the line :{$R *.DFM} How can I solve this problem ? ====<br />
<br />
Lazarus (or better Linux) doesn't know about resources, so you can't use them in the way Delphi/Win32 does. However Lazarus uses a method pretty compatible with this. You can still use your Delphi layouts (.dfm files) if you use the following steps:<br />
<br />
*You need a textual version of the .dfm files. D5 and higher are doing this as default. If you have older files: ALT-F12 to see the layout as text and paste/copy. When you have a text .dfm file, just copy it to a .lfm file.<br />
*Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm<br />
*Add the following initialization section to<br />
<br />
initialization<br />
{$I yourform.lrs}<br />
<br />
Please keep in mind that not all properties in the dfm are supported yet by<br />
lazarus, so you might get a crash.<br />
<br />
==== 'Identifier not found LazarusResources'. ====<br />
<br />
When creating a form Lazarus automaticaly add some extra units to the uses section of your form unit. During the conversion of a delphi unit to a Lazarus unit this does not happen. So you need to add LResources to the Uses section of your form unit.<br />
<br />
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===<br />
<br />
Make sure, in the Project -> Project Inspector, that your project depends on the package 'LCL' and that you have installed the FPC sources.<br />
<br />
Lazarus is the IDE and the visual components library LCL.<br />
All other stuff, like IO, Database, FCL and RTL are provided by FPC.<br />
The IDE needs the paths to all sources.<br />
<br />
The FPC source path can be set via:<br />
Environment -> Environment Options -> Files -> FPC source directory<br />
<br />
===How to embed a small file in the executable, without the need of a separate file? How to embed a resource?===<br />
<br />
For example:<br />
/your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...<br />
will create sound.lrs from sound1.wav and sound2.wav.<br />
<br />
Then include it *behind* the form lrs file:<br />
<br />
...<br />
initialization<br />
{$i unit1.lrs} // this is main resource file (first)<br />
{$i sound.lrs} // user defined resource file<br />
<br />
end.<br />
In your program you can then use:<br />
Sound1AsString:=LazarusResources.Find('sound1').Value;<br />
<br />
=== How can I see debug output? ===<br />
<br />
The LCL has in the LCLProc unit two procedures to write debug output. They are named: <br />
* '''DebugLn:''' which works about the same as WriteLn, but accepts only strings.<br />
* '''DbgOut:''' which works about the same as Write, but accepts only strings.<br />
<br />
In normal circumstances the output is written to stdout. If stdout is closed, (for example when the application is {$AppType Gui} or compiled with -WG on Windows), no output is written.<br />
<br />
Debug output can also be written to file. The initialization code of the LCLProc unit checks Lazarus.exe's command line parameters for '--debug-log=<file>'. On finding this parameter any subsequent debug output is sent to <file>.<br />
<br />
If no '--debug-log' command line parameter has been given, it next checks if an operating system environment variable xxx_debuglog exists, where xxx is the program file name without extension. For Lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses the file specified in the lazarus_debuglog environment variable as file to receive debug output. Example: if you do:<br />
set lazarus_debuglog=c:\lazarus\debug.txt<br />
debug output will be written to c:\lazarus\debug.txt.<br />
<br />
Since this is implemented in lclproc, every application using lclproc, can use this output facility.<br />
<br />
;Debuging Lazarus : Most useful for Windows: If you want output on a console, add {$APPTYPE console} to lazarus.pp ; Then rebuild Lazarus.<br />
<br />
=== What is the meaning of the various file extensions used by Lazarus? ===<br />
<br />
The [[Lazarus Tutorial#The Lazarus files]] explains some extensions by an example.<br />
Here is a brief list:<br />
<br />
; <code>*.lpi</code> : Lazarus Project Information file (stored in XML; contains project-specific settings)<br />
; <code>*.lpr</code> : Lazarus Program file; contains Pascal source of main program<br />
; <code>*.lfm</code> : Lazarus Form file; contains configuration information for all objects on a form (stored in a Lazarus-specific textual format; the actions are described by Pascal source code in a corresponding <code>*.pas</code> file)<br />
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code (typically for a form stored in a corresponding <code>*.lfm</code> file)<br />
; <code>*.lrs</code> : Lazarus Resource file (this is a generated file; not to be confused with a Windows resource file). <br />
: This file can be created with lazres tool (in directory Lazarus/Tools) using commandline: lazres myfile.lrs myfile.lfm<br />
; <code>*.ppu</code> : Compiled unit<br />
; <code>*.lpk</code> : Lazarus package information file. (stored in XML; contains package-specific settings)<br />
<br />
=== I have fixed/improved lazarus. How can I add my changes to the official lazarus source? ===<br />
Create a patch and send it to the developers. For details see [[Creating A Patch]].<br />
=== When I do ''var mytext: text;'' to declare a text file, I get "Unit1.pas(32,15) Error: Error in type definition". How can I fix this?===<br />
The TControl class has a [[doc:lcl/controls/tcontrol.text.html|Text]] property. In a method of a form, that has higher visibility, the [[doc:rtl/system/text.html|Text]] type from the system unit. You can use the [[doc:rtl/system/textfile.html|TextFile]] type, which is just an alias for the Text type or you can add the unit to the type definition.<br />
var<br />
MyTextFile: TextFile;<br />
MyText: System.Text;<br />
A similar name clash exists with assigning and closing a text file. TForm has a ''assign'' and a [[doc:lcl/forms/tcustomform.close.html|Close]] method. You can use [[doc:rtl/objpas/assignfile.html|AssignFile]] and [[doc:rtl/objpas/closefile.html|CloseFile]] or add the unit name ''System''.<br />
<br />
=== I get an error when using Printer.BeginDoc ===<br />
<br />
The unit Printers must be added to the uses section.<br />
<br />
The Printer4Lazarus package must be added to your project requirement in the IDE under:<br />
Project|Project Inspector|Add|New Requirement|Package Name:<br />
<br />
If the package Printer4Lazarus package is not in the list when opening the dropdown box it must be installed. The package is part of the Lazarus installation and can be found in:<br />
[lazarus installed directory]\components\printers<br />
<br />
If you used the default installation directories [lazarus installed directory] is:<br />
*Windows: c:\lazarus <br />
*Linux: /usr/lib/lazarus<br />
<br />
The same solution also applies to the exception you can get when referencing Printer.Printers<br />
<br />
=== Why are TForm.ClientWidth/ClientHeight the same as TForm.Width/Height ===<br />
<br />
The TForm.Width/Height do no include the frame, because there was no way to retrieve the frame size on all platforms. Without a reliable way, the LCL would move the forms around on the screen or resize them endlessly.<br />
<br />
Eventually when there is a reliable way to get the size and position of a window with its frame on all platforms, then it will be changed. To keep compatibility with older LCL forms, a version number and some extra methods will be added.<br />
<br />
=== I created a Patch to dock the IDE Messages form on the "Source Code Editor" form (at bottom) ===<br />
<br />
Such patches will not be applied, because they only implement a small part of the needed docking. The goal is to create a complete dock manager and use that. A complete dock manager can dock all IDE windows and it allows to let the user define how to dock. For example dock the messages window above or below the source editor or ... or not at all. For instance:<br />
<br />
<pre><br />
+-------------------++--+<br />
|menu || |<br />
+-------------------+| |<br />
+--++---------------+| |<br />
|PI|| Source Editor ||CE|<br />
+--+| || |<br />
+--+| || |<br />
| |+---------------++--+<br />
|OI|+-------------------+<br />
| ||messages |<br />
+--++-------------------+<br />
</pre><br />
<br />
The dock manager can store the layout and restore it on next load. Preferably the dock manager can dock in pages too. The dock manager does not need to use drag and drop.<br />
All patches implementing docking without a dock manager makes it harder to implement a real dock manager and will be rejected.<br />
<br />
=== How can I become a developer lazarus and access management in the SVN and bug-tracker? ===<br />
<br />
First of all: you must learn about Lazarus, to prove your knowledge and skill.<br />
Start by reading the [[Lazarus_Documentation|wiki articles]], read the Lazarus source code, giving a look at the [http://www.lazarus.freepascal.org/mantis Lazarus Bug-Tracker], fix some bugs, and if you think you are ready, contact the developers on the [http://www.mail-archive.com/lazarus@miraclec.com mailing list].<br />
<br />
== Where is ... defined ==<br />
<br />
=== Virtual key constants ===<br />
Virtual key constants are defined in LCLType. Add LCLtype to your <b>uses</b>.<br />
<br />
== Using the IDE ==<br />
<br />
=== How can I use "identifier completion"? ===<br />
You can invoke identifier completion by pressing [ctrl][space].<br />
Under the menu item ''Environment -> Editor Options -> Code Tools -> Automatic Features'' you can set how quick this should happen automatically.<br />
<br />
== Linux ==<br />
<br />
=== How can I debug on Linux without the IDE? ===<br />
<br />
First of all you need a debugger. gdb is the standard debugger under linux and<br />
there are several GUI-frontends available. One common frontend is ddd, which is<br />
part of most common distributions. To compile lazarus/lcl with debug-information<br />
you should then use the following commands to start a debug session:<br />
<br />
$ make clean; make OPT=-dDEBUG<br />
$ ddd lazarus<br />
<br />
Be warned however, that ddd is not as comfortable as e.g. the Lazarus debugger.<br />
Specially if it comes to view the contents of a variable you have to take into<br />
account that ddd/gdb are case sensitive whereas Pascal is case-insensitive.<br />
Therefore you have to type all variable names in uppercase to see their<br />
contents. For more information take a look into the fpc-manuals.<br />
<br />
=== I can debug now but ddd does not find my sources or complains that they contain no code. Whats that? ===<br />
<br />
This is a path-related problem with either gdb or ddd. You can aviod this by<br />
<br />
* Use the "Change directory" command from the ddd menu and choose the directory where the sources are located. The drawback of this method is that you now can't use the source of the program you started with (e.g. lazarus). Thus it may be neccessary to change the directory multiple times.<br />
* In ddd goto [Edit] [gdb-settings] and set the search-path<br />
* Create a $(HOME)/.gdbinit file like:<br />
directory /your/path/to/lazarus<br />
directory /your/path/to/lazarus/lcl<br />
directory /your/path/to/lazarus/lcl/include<br />
<br />
=== I receive an error during the linking that states /usr/bin/ld can't find -l<some lib> ===<br />
<br />
; '''Package Based Distributions''' : You need to install the package that provides the lib<somelib>.so or lib<somelib>.a files. Dynamic libs under linux have the extension .so, while static libs have the extension .a. On some Linux distro's you have installed the package (rpm, deb) <packagename> which provides <some lib>, but you also need the development package (rpm, deb), normally called <packagename>-dev, which contains the .a (static lib) and/or the .so (dynamic lib). <br />
: Some distributions have commands to find which package contains a file:<br />
: '''Mandriva'''<br />
<br />
[]$ urpmf lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -devel<br />
<br />
: '''Debian'''<br />
<br />
:install the apt-file utility (apt-get install apt-file) then<br />
<br />
[]$ apt-file search lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -dev<br />
<br />
<br />
<br />
; '''Source Based Distributions and Manual Compilation (LFS)''' : Make sure that there is a lib<somelib>.a in the path, and that it contains the right version. To let the linker find the dynamic library, create a symlink called lib<some lib>.so to lib<some lib><version>-x,y.so if necessary (and/or for static lib; lib<some lib>.a to lib<some lib><version>-x,y.a).<br />
<br />
; '''FreeBSD''' : As source based distro's, and also make sure you have -Fl/usr/local/lib in your fpc.cfg and/or Lazarus library path. Keep in mind that GTK1.2 has "gtk12" as package name under FreeBSD. (same for glib) NOTE: This has changed as of late. Newest ports have gtk-12 and glib-12 as well. You might stumble on this problem, since FPC requires the "-less" ones, you will need to symlink them like this:<br />
<br />
[]# cd /usr/local/lib && ln -s libglib-12.so libglib12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgtk-12.so libgtk12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgdk-12.so libgdk12.so<br />
<br />
; '''NetBSD''' : As source based distro's, and also make sure you have -Fl/usr/pkg/lib in your fpc.cfg and/or Lazarus library path<br />
<br />
=== How can I convert a kylix 2 project into a lazarus project? ===<br />
<br />
Nearly the same way as converting a Kylix project into a Delphi/VCL project.<br />
<br />
The LCL (Lazarus Component Library) tries to be compatible to Delphis VCL.<br />
Kylix CLX tries to be QT compatible.<br />
Here are some general hints:<br />
<br />
* Rename all used CLX Q-units like QForms, QControls, QGraphics, ... into their VCL counterparts: Forms, Controls, Graphics, ...<br />
* Add LResources to the uses section of every form source<br />
* Rename or copy all .xfm files to .lfm files.<br />
* Rename or copy .dpr file to .lpr file.<br />
* Add "Interfaces" to the uses section in the .lpr file.<br />
* Remove {$R *.res} directive<br />
* Remove {$R *.xfm} directive<br />
* Add {$mode objfpc}{$H+} or {$mode delphi}{$H+} directive to .pas and .lpr files<br />
* Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):<br />
initialization<br />
{$I unit1.lrs}<br />
:The .lrs files can be created via the lazres tool in: (lazarusdir)/tools/lazres.<br />
:For example: ./lazres unit1.lrs unit1.lfm<br />
<br />
* Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.<br />
<br />
* To make it more platform independant, reduce unit libc (which is deprecated) references and substitute with native FPC units like baseunix/unix as much as possible. This will be necessary to support other targets than linux/x86 (including OS X, FreeBSD and Linux/x86_64)<br />
<br />
=== When compiling lazarus the compiler can not find a unit. e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB ===<br />
<br />
1. Check a clean rebuild: do a 'make clean all'<br />
<br />
2. Check if the compiler has the correct version (2.0.4 or higher)<br />
<br />
3. Check if the compiler is using the right config file. The normal installation creates /etc/fpc.cfg. But fpc also searches for ~/.ppc386.cfg, ~/.fpc.cfg, /etc/ppc386.cfg and it uses only the first it finds.<br />
<br />
:'''Hint:''' You can see which config file is used with 'ppc386 -vt bogus'<br />
:Remove any ppc386.cfg as it is really obsolete.<br />
<br />
4. Check if the config file (/etc/fpc.cfg) contains the right paths to your fpc libs. There must be three lines like this:<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*<br />
:The first part of these paths (/usr/lib/fpc) depends on your system. On some systems this can be for example /usr/local/lib/fpc/... .<br />
:'''Hint:''' You can see your searchpaths with 'ppc386 -vt bogus'<br />
<br />
5. Check that the config file (/etc/fpc.cfg) does not contain search paths to the lcl source files (.pp, .pas):<br />
forbidden: -Fu(lazarus_source_directory)/lcl<br />
forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk<br />
:If you want to add the lcl for all your fpc projects, make sure that the two paths look like the following and are placed after the above fpc lib paths:<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk<br />
<br />
6. Check if the missing unit (glib.ppu) exists in your fpc lib directory. For example the gtk.ppu can be found in /usr/lib/fpc/$fpcversion/units/i386-linux/gtk/. If it does not exists, the fpc lib is corrupt and should be reinstalled.<br />
<br />
7. Check if the sources are in a NFS mounted directory. In some cases the NFS updates created files incorrectly. Please, try to move the sources into a non NFS directory and compile there.<br />
<br />
8. If you are still not succeeded try to use samplecfg script as follows:<br />
<br />
''#'' cd /usr/lib/fpc/''version''/<br />
<br />
''#'' sudo ./samplecfg /usr/lib/fpc/''\$version'' /etc<br />
<br />
Note! Do not put - / - after etc because if you do that the system will create a file - /etc/fpc.cfg/fpc.cfg. In fact we want that samplecfg make a file - /etc/fpc.cfg - not the folder /etc/fpc.cfg.<br />
<br />
=== I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS ===<br />
<br />
Probably you are using a newer fpc package, than that used for building the<br />
lazarus binaries. The best solution is to download the sources and compile<br />
lazarus manually. You can download the source snapshot or get the source<br />
via svn:<br />
<br />
$ bash<br />
$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
Make sure that lazarus get the new source directory:<br />
Environment->General Options->Files->Lazarus Directory Top<br />
<br />
===Lazarus compiles, but linking fails with: libgdk-pixbuf not found===<br />
Install the gdk-pixbuf library for gtk1.x:<br />
<br />
Where to find the gdk-pixbuf library:<br />
<br />
RPMs:<br />
http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=<br />
<br />
Debian packages:<br />
libgdk-pixbuf-dev<br />
<br />
Sources:<br />
ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/<br />
<br />
===I have SuSE and I get /usr/bin/ld: cannot find -lgtk Error: Error while linking===<br />
SuSE installs the gtk devel libs under /opt/gnome/lib (or /opt/gnome/lib64 for 64 bits), which is not in<br />
the standard lib path. Simply add it to your /etc/fpc.cfg.<br />
(-Fl/opt/gnome/lib).<br />
<br />
===Lazarus crashes with runtime error 211 after I installed a component===<br />
After I installed a component, Lazarus crashes with the following message:<br />
Threading has been used before cthreads was initialized.<br />
Make cthreads one of the first units in your uses clause.<br />
Runtime error 211 at $0066E188<br />
How can I fix this?<br />
<br />
Your freshly installed component is using threads. FPC on *nix doesn't automatically include threading support, but it must be intialized. This initialization is done in the cthreads unit. Every application using the component needs to add this unit to the uses clause of the main program. Lazarus itself is no exception. This can be done in two ways:<br />
<br />
1) Open the package. In the package editor click on ''Options''. Under page ''Usage'' add to the ''custom'' options '''-dUseCThreads'''. Then rebuild the IDE. This way the cthreads unit will be automatically used by the IDE under unix and the cthreads are initialized.<br />
<br />
2) In order to avoid modifying package, a fpc compiler option could be used directly. Open menu Tools->Configure "build Lazarus". Configure "build Lazarus" dialog will be shown, in field "Options:" type -Facthreads and then press "OK" button. The next step is to install the package. Lazarus will be built with option -Facthreads which means that it will treat main program as if unit cthreads where first in uses clause. <br />
<br />
''Hint:'' Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.<br />
<br />
See also [[Multithreaded_Application_Tutorial#Units_needed_for_a_multithreaded_application]]<br />
<br />
===When I run a program with threads I get runtime error 232===<br />
The complete error message is:<br />
This binary has no thread support compiled in.<br />
Recompile the application with a thread-driver in the program uses<br />
clause before other units using thread.<br />
Runtime error 232<br />
'''Solution''': Add cthreads as first unit to the uses clause of your main program, usually the .lpr-file.<br />
<br />
===I have Ubuntu Breezy and my fonts in Lazarus IDE look too big===<br />
If Lazarus is compiled with Gtk1.2, the settings in Gnome Preferences/Font don't have any effect as<br />
they are related to Gtk2.<br />
You could try this solution:<br />
Create a file named .gtkrc.mine in your home directory (if it's not already there) and add<br />
these lines to it:<br />
<br />
<pre><br />
style "default-text" {<br />
fontset = "-*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\<br />
-*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"<br />
}<br />
<br />
class "GtkWidget" style "default-text"<br />
</pre><br />
<br />
If this is not enough try and create also a .gtkrc symlink to .gtkrc.mine . It worked in this way under Xubuntu 7.10.<br />
<br />
===How can my gtk programs use custom rc files?===<br />
<br />
Option a)<br />
Name the rc file ''yourprogram.gtkrc'' and put it in the same directory where the executable is.<br />
<br />
Option b)<br />
Use unit ''GtkInt'' and call ''GTKWidgetSet.SetRCFilename('your_preferred_rc_file');''<br />
Best done before ''Application.Initialize'' in the .lpr file with ''{$IFDEF LCLGtk}''.<br />
<br />
===I have Ubuntu and I cannot compile for Gtk2 due to missing libraries===<br />
Ubuntu has a problem with not creating all the symbolic links that you'll need even when the libraries are installed. Make sure that all missing libraries when trying to link for Gtk2 have their appropriate links. For instance, you might need to do:<br />
<br />
<pre><br />
cd /usr/lib<br />
sudo ln -s libgdk-x11-2.0.so.0 libgtk-x11-2.0.so<br />
</pre><br />
<br />
Make sure that the [whatever].so symbolic links are created and point to the actual libraries.<br />
<br />
===How can I compile a program for Gtk2?===<br />
<br />
At the moment, the Gtk2 compiled IDE is a little unstable, but you can compile software for Gtk2 using the Gtk1 IDE.<br />
<br />
To start with recompile LCL for Gtk2. Go to the menu "Tools"->"Configure Build Lazarus" and set LCL to clean+build and everything else to none.<br />
<br />
Now click Ok and go to the menu "Tools"->"Build Lazarus"<br />
<br />
Now you can compile your software with Gtk2 going on the Compiler options and changing the widgetset to Gtk2.<br />
<br />
===I get this message: "[WARNING] ** Multibyte character encodings (like UTF8) are not supported at the moment."===<br />
<br />
Since revision 10535 (0.9.21) this message doesn't exist anymore. <br />
Previously it was used to warn that a UTF-8 encoding was used. The internal keyhandling routines for the gtk1 widgetset couldn't handle such encoding for keypresses, with the result that keypresses with for instance accented chars were not or wrong detected.<br />
<br />
(original text for older versions of lazarus)<br><br />
<strike><br />
This warning message indicates that your locale enconding is set to utf-8. If you are using Gtk 1 this can be a serious problem and prevent the correct working of Lazarus or software created with Lazarus.<br />
<br />
To work around this, just change your locale to a non utf-8 before executing the program on the command line, like this:<br />
<br />
<pre><br />
export LC_CTYPE="pt_BR"<br />
export LANG="pt_BR"<br />
export LANGUAGE="pt_BR"<br />
./lazarus<br />
</pre><br />
<br />
Substitute pt_BR with the locale for your country. You can create a script to automate this.<br />
</strike><br />
<br />
== Windows ==<br />
<br />
=== When I cycle the compiler, I get:The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time. ===<br />
<br />
In the compiler directory there is an OS2 scriptfile named make.cmd. Different versions of Windows also see this as a script file, so remove it since what is needed for OS2 becomes a hindrance on Windows.<br />
<br />
=== When I cycle the compiler, I get: make[3]: ./ppc1.exe: Command not found ===<br />
<br />
I don't know why but somehow make has lost its path. Try to cycle with a<br />
basedir set like: make cycle BASEDIR=your_fpc_source_dir_herecompiler<br />
<br />
=== When I try to make Lazarus I get:===<br />
====make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2 ====<br />
You need to upgrade your make.<br />
<br />
====makefile:27: *** You need the GNU utils package to use this Makefile. Stop.====<br />
Make sure you didn't install FPC in a path with spaces in the name. The<br />
Makefile doesn't support it.<br />
<br />
<br />
<br />
===How can I give my program an XP look like lazarus has?===<br />
Project -> Project Options -> Check 'Use manifest to enables themes'.<br />
<br />
===When I run Windows program created in Lazarus it starts with a DOS window===<br />
Specify the -WG argument (Windows GUI) on the command line of the compiler or in the Lazarus IDE check the Windows GUI check box on the compiler options dialog box (Project menu -> Compiler Options -> Linking -> target OS Specific options.<br />
<br />
== Mac OS X ==<br />
<br />
=== Why does compiling a project fail with 'unknown section attribute: no_dead_strip'?===<br />
<br />
Dead code stripping is not supported by the assembler and linker before Xcode 1.5 (available for Mac OS X 10.3.9). Disable the compiler options <br />
<br />
*Code > Unit style > Smart linkable (-CX) <br />
*and Linking > Link Style > Link smart (-XX)<br />
<br />
== Licensing ==<br />
<br />
=== Can I make commercial applications with Lazarus ? ===<br />
<br />
Yes, the LCL is licensed under the LGPL with an exception, which allows you to link to it statically without releasing the source of your application. Modifications and enhancements to the LCL must be distributed with source. Lazarus, the IDE, is licensed under the GPL.<br />
<br />
=== Can I make commercial plug-ins for Lazarus ? ===<br />
<br />
Yes, the IDEIntf part of the IDE is licensed under the LGPL with the same exception, so that shared data structures in this part will not force you to license your plug-in or design-time package under the GPL. You are free to choose a plug-in of any license; we don't want to limit your choice. Therefore non-GPL compatible plug-ins are allowed. Note that it's not allowed to distribute a precompiled Lazarus with these non-GPL-compatible plugins included statically; however, we do not see this as a severe limitation, since recompiling Lazarus is easy.<br />
<br />
== Contributors and Comments ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq version].</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Faq/ko&diff=32369Lazarus Faq/ko2008-11-27T14:44:33Z<p>Oranke: /* 도대체 실행파일의 크기가 왜 이렇게 큰 겁니까? */</p>
<hr />
<div>{{Lazarus Faq}}<br />
<br />
이 문서는 원래 www.lazarus.freepascal.org 에 있던 것 입니다. 관리 및 확장 면에서 위키가 훨씬 더 유용하기 때문에 이 곳으로 복사되었습니다. <br />
<br />
== 일반적인 이야기 ==<br />
<br />
=== 더 많은 FAQ를 볼 수 있는 곳은 어디인가요? ===<br />
See the [http://www.lazarus.freepascal.org official website]. There is another FAQ as well.<br />
<br />
===도대체 실행파일의 크기가 왜 이렇게 큰 겁니까?===<br />
실행파일의 크기가 큰 이유는 GDB (GNU Debugger) 를 사용하기 위한 많은 정보들을 포함하고 있기 때문입니다. <br />
<br />
컴파일러에 이 디버깅 정보를 제거하기 위한 옵션 (-Xs) 이 있습니다만, 버전 2.0.2 이전의 컴파일러는 이 기능에 버그가 있기 때문에 제대로 동작하지 않습니다. 이 버그는 현재 개발버전에서는 수정되었습니다. <br />
<br />
"strip" 이라는 이름의 프로그램을 사용하면 실행파일로 부터 디버그 심볼을 삭제할 수 있습니다. 이 프로그램은 lazarus\pp\bin\i386-win32\ 에 있습니다. <br />
<br />
커맨드 라인에서 간단하게 "strip --strip-all <만든 실행파일의 경로명과 파일명>" 을 입력 하세요.<br />
<br />
실행파일을 좀 더 작게 만들려면, [http://upx.sourceforge.net/ UPX] 가 좋은 해법이 될 것입니다. UPX는 정말 멋진 실행파일 압축기 입니다. <br />
It includes no memory overhead due to in-place decompression. It also has a very fast decompression (~10 MB/sec on an Pentium 133).<br />
<br />
To use upx just type "upx <your executable file with path>" on the command line.<br />
<br />
after using both strip and upx a simple GUI Lazarus program gets:<br />
* ~ 700kb on Linux<br />
* ~ 420kb on Windows<br />
<br />
A more detailed answer with the drawbacks of using UPX is given on [[Size Matters]].<br />
<br />
It's also important to note that the hello world lazarus software already includes a huge amount of features. It includes:<br />
<br />
* XML handling library<br />
* Image handling library for png, xpm, bmp and ico files<br />
* Almost all widgets from the Lazarus Component Library<br />
* All of the Free Pascal Runtime Library<br />
<br />
So it's very big, but it already includes almost everything a real world non-trivial app will need.<br />
<br />
Lazarus executable size starts big, but grows very slowly, because of the Free Pascal compiler and the way lazarus forms operate. A c++ project (just an example, but applies to other languages / tools too) starts very small on the hello world, but quickly grows exponentially when you need features to write a non-trivial application.<br />
<br />
[[Image:Lazarus_vs_cpp.png]]<br />
<br />
=== Why is the linking so slow on Windows? ===<br />
<br />
This problem is over from FPC 2.2 and Lazarus 0.9.24. Please update your Lazarus. For older versions read text below.<br />
<br />
Generally speaking, compilation on Windows takes more time then other platforms because the GNU Linker utilized by Free Pascal is slow on this platform. This problem only affects Windows, and is only bad on relatively old computers (less then 1Ghz) and computers with little RAM (128MB or less).<br />
<br />
Also, if you smartlink LCL the linking will be much slower. A study about this is located here: [[File size and smartlinking]]<br />
<br />
A internal linker was developed, and is ready, but will only be available when Free Pascal 2.2 is released (of course it's also available via subversion). It decreases the linking time dramatically.<br />
<br />
'''Note''': In 2.1.1 Windows uses an internal linker for win32/64/ce which speeds the process up a bit. A Lazarus recompile then eats about 280MB.<br />
<br />
=== Do I need ppc386.cfg or fpc.cfg? ===<br />
<br />
You only need fpc.cfg. This way the compiler knows where to find the libraries.<br />
<br />
=== How do I compile lazarus? ===<br />
<br />
Do something like this:<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
=== How do I build other projects based upon the LCL ===<br />
<br />
If you can't use the IDE to build your applications, use lazbuild. This is a command line version of the IDE to build lazarus projects and packages.<br />
If you want to build LCL applications without the IDE and without the lazbuild, add the following lines to the end of your ''fpc.cfg''<br />
<br />
# searchpath for other toolkits (Linux)<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{YourToolKit}<br />
<br />
# searchpath for other toolkits (Windows)<br />
-Fu/{YourLazarusDirectory}/components/units/{YourToolKit}<br />
<br />
:Where {YourToolKit} may be ''gtk2'', ''gnome'', ''qt'' or ''win32'' and run:<br />
::ppc386 your.project.pp<br />
<br />
'''Hint:''' Don't forget to install the development packages for your toolkit otherwise you might a receive something like: [[Linker message: cannot find -l]].<br />
<br />
=== What version of FPC is required? ===<br />
<br />
2.0.4 for MacOSX and 2.2.2 for all other systems. Warning: The 2.2.0 has a bug under MacOSX with case sensitive filenames.<br />
You can also use the svn version of fpc 2.2.3 and 2.3.x.<br />
<br />
=== I can't compile Lazarus ===<br />
<br />
# Check if the compiler has the correct version<br />
# Check if the (fpc)libraries are from the same version.<br />
# Check if you have a fpc.cfg and no old ppc386.cfg<br />
# Check also the OS-dependent FAQs<br />
<br />
=== When I try to compile a project, I have an error ===<br />
==== "Cannot find Unit interfaces". How can I solve this?====<br />
It means the compiler can not find the file 'interfaces.ppu' '''or''' it means it found one, but it is wrong or outdated.<br />
<br />
This unit can be found in {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu. For example: /home/username/lazarus/lcl/units/i386-linux/gtk/interfaces.ppu.<br />
<br />
Make sure, it is only there. If you have multiple versions of interfaces.ppu, then you probably have a wrong configuration (for instance you added a lcl directory to a search path). Remove all interfaces.ppu, but the one in the directory above.<br />
<br />
If you selected a different widgetset than you used to build lazarus, you need to build the LCL for this widgetset. <br />
<br />
If it is there, but you get this error, you are using a different compiler / rtl for compiling your project than you used for compiling your Lazarus IDE. You can do one of the following<br />
* Rebuild the LCL (or Lazarus completely) with the compiler selected in the Environmnent Options. You can do this with Tools -> Build Lazarus. Before doing this, check the current settings in Tools -> Configure Build Lazarus.<br />
* Change the compiler in the Environment Options to the one you used to compile Lazarus. Look carefully also in the Environment Options to see if you are using the correct paths for the Lazarus Directory and the FPC sources directory. Check that there is only one version of the compiler configuration file fpc.cfg - it should reside in /etc/ for Linux/Unix systems or in the same directory as the fpc compiler for Windows systems. Try to run "fpc -vt bogus" to check which fpc.cfg is being used in your system. Rogue copies often creep in if you have updated your compiler to a new version; they may be found in your home directory or in the same directory as the one in which you built your new compiler. DELETE THESE!!<br />
* You may also try to change the widgetset currently selected for the project. For example, the sample project "objectinspector" that comes with Lazarus is set to gtk by default. Compiling this project will surely give you "Can't find unit interfaces" in Windows platform. Changing widgetset to default(Win32) in Project | Compiler Options... | LCL Widget Type (various) should fix this issue.<br />
<br />
=== When I try to compile delphi projects under lazarus, I have an error ===<br />
==== at the line :{$R *.DFM} How can I solve this problem ? ====<br />
<br />
Lazarus (or better Linux) doesn't know about resources, so you can't use them in the way Delphi/Win32 does. However Lazarus uses a method pretty compatible with this. You can still use your Delphi layouts (.dfm files) if you use the following steps:<br />
<br />
*You need a textual version of the .dfm files. D5 and higher are doing this as default. If you have older files: ALT-F12 to see the layout as text and paste/copy. When you have a text .dfm file, just copy it to a .lfm file.<br />
*Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm<br />
*Add the following initialization section to<br />
<br />
initialization<br />
{$I yourform.lrs}<br />
<br />
Please keep in mind that not all properties in the dfm are supported yet by<br />
lazarus, so you might get a crash.<br />
<br />
==== 'Identifier not found LazarusResources'. ====<br />
<br />
When creating a form Lazarus automaticaly add some extra units to the uses section of your form unit. During the conversion of a delphi unit to a Lazarus unit this does not happen. So you need to add LResources to the Uses section of your form unit.<br />
<br />
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===<br />
<br />
Make sure, in the Project -> Project Inspector, that your project depends on the package 'LCL' and that you have installed the FPC sources.<br />
<br />
Lazarus is the IDE and the visual components library LCL.<br />
All other stuff, like IO, Database, FCL and RTL are provided by FPC.<br />
The IDE needs the paths to all sources.<br />
<br />
The FPC source path can be set via:<br />
Environment -> Environment Options -> Files -> FPC source directory<br />
<br />
===How to embed a small file in the executable, without the need of a separate file? How to embed a resource?===<br />
<br />
For example:<br />
/your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...<br />
will create sound.lrs from sound1.wav and sound2.wav.<br />
<br />
Then include it *behind* the form lrs file:<br />
<br />
...<br />
initialization<br />
{$i unit1.lrs} // this is main resource file (first)<br />
{$i sound.lrs} // user defined resource file<br />
<br />
end.<br />
In your program you can then use:<br />
Sound1AsString:=LazarusResources.Find('sound1').Value;<br />
<br />
=== How can I see debug output? ===<br />
<br />
The LCL has in the LCLProc unit two procedures to write debug output. They are named: <br />
* '''DebugLn:''' which works about the same as WriteLn, but accepts only strings.<br />
* '''DbgOut:''' which works about the same as Write, but accepts only strings.<br />
<br />
In normal circumstances the output is written to stdout. If stdout is closed, (for example when the application is {$AppType Gui} or compiled with -WG on Windows), no output is written.<br />
<br />
Debug output can also be written to file. The initialization code of the LCLProc unit checks Lazarus.exe's command line parameters for '--debug-log=<file>'. On finding this parameter any subsequent debug output is sent to <file>.<br />
<br />
If no '--debug-log' command line parameter has been given, it next checks if an operating system environment variable xxx_debuglog exists, where xxx is the program file name without extension. For Lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses the file specified in the lazarus_debuglog environment variable as file to receive debug output. Example: if you do:<br />
set lazarus_debuglog=c:\lazarus\debug.txt<br />
debug output will be written to c:\lazarus\debug.txt.<br />
<br />
Since this is implemented in lclproc, every application using lclproc, can use this output facility.<br />
<br />
;Debuging Lazarus : Most useful for Windows: If you want output on a console, add {$APPTYPE console} to lazarus.pp ; Then rebuild Lazarus.<br />
<br />
=== What is the meaning of the various file extensions used by Lazarus? ===<br />
<br />
The [[Lazarus Tutorial#The Lazarus files]] explains some extensions by an example.<br />
Here is a brief list:<br />
<br />
; <code>*.lpi</code> : Lazarus Project Information file (stored in XML; contains project-specific settings)<br />
; <code>*.lpr</code> : Lazarus Program file; contains Pascal source of main program<br />
; <code>*.lfm</code> : Lazarus Form file; contains configuration information for all objects on a form (stored in a Lazarus-specific textual format; the actions are described by Pascal source code in a corresponding <code>*.pas</code> file)<br />
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code (typically for a form stored in a corresponding <code>*.lfm</code> file)<br />
; <code>*.lrs</code> : Lazarus Resource file (this is a generated file; not to be confused with a Windows resource file). <br />
: This file can be created with lazres tool (in directory Lazarus/Tools) using commandline: lazres myfile.lrs myfile.lfm<br />
; <code>*.ppu</code> : Compiled unit<br />
; <code>*.lpk</code> : Lazarus package information file. (stored in XML; contains package-specific settings)<br />
<br />
=== I have fixed/improved lazarus. How can I add my changes to the official lazarus source? ===<br />
Create a patch and send it to the developers. For details see [[Creating A Patch]].<br />
=== When I do ''var mytext: text;'' to declare a text file, I get "Unit1.pas(32,15) Error: Error in type definition". How can I fix this?===<br />
The TControl class has a [[doc:lcl/controls/tcontrol.text.html|Text]] property. In a method of a form, that has higher visibility, the [[doc:rtl/system/text.html|Text]] type from the system unit. You can use the [[doc:rtl/system/textfile.html|TextFile]] type, which is just an alias for the Text type or you can add the unit to the type definition.<br />
var<br />
MyTextFile: TextFile;<br />
MyText: System.Text;<br />
A similar name clash exists with assigning and closing a text file. TForm has a ''assign'' and a [[doc:lcl/forms/tcustomform.close.html|Close]] method. You can use [[doc:rtl/objpas/assignfile.html|AssignFile]] and [[doc:rtl/objpas/closefile.html|CloseFile]] or add the unit name ''System''.<br />
<br />
=== I get an error when using Printer.BeginDoc ===<br />
<br />
The unit Printers must be added to the uses section.<br />
<br />
The Printer4Lazarus package must be added to your project requirement in the IDE under:<br />
Project|Project Inspector|Add|New Requirement|Package Name:<br />
<br />
If the package Printer4Lazarus package is not in the list when opening the dropdown box it must be installed. The package is part of the Lazarus installation and can be found in:<br />
[lazarus installed directory]\components\printers<br />
<br />
If you used the default installation directories [lazarus installed directory] is:<br />
*Windows: c:\lazarus <br />
*Linux: /usr/lib/lazarus<br />
<br />
The same solution also applies to the exception you can get when referencing Printer.Printers<br />
<br />
=== Why are TForm.ClientWidth/ClientHeight the same as TForm.Width/Height ===<br />
<br />
The TForm.Width/Height do no include the frame, because there was no way to retrieve the frame size on all platforms. Without a reliable way, the LCL would move the forms around on the screen or resize them endlessly.<br />
<br />
Eventually when there is a reliable way to get the size and position of a window with its frame on all platforms, then it will be changed. To keep compatibility with older LCL forms, a version number and some extra methods will be added.<br />
<br />
=== I created a Patch to dock the IDE Messages form on the "Source Code Editor" form (at bottom) ===<br />
<br />
Such patches will not be applied, because they only implement a small part of the needed docking. The goal is to create a complete dock manager and use that. A complete dock manager can dock all IDE windows and it allows to let the user define how to dock. For example dock the messages window above or below the source editor or ... or not at all. For instance:<br />
<br />
<pre><br />
+-------------------++--+<br />
|menu || |<br />
+-------------------+| |<br />
+--++---------------+| |<br />
|PI|| Source Editor ||CE|<br />
+--+| || |<br />
+--+| || |<br />
| |+---------------++--+<br />
|OI|+-------------------+<br />
| ||messages |<br />
+--++-------------------+<br />
</pre><br />
<br />
The dock manager can store the layout and restore it on next load. Preferably the dock manager can dock in pages too. The dock manager does not need to use drag and drop.<br />
All patches implementing docking without a dock manager makes it harder to implement a real dock manager and will be rejected.<br />
<br />
=== How can I become a developer lazarus and access management in the SVN and bug-tracker? ===<br />
<br />
First of all: you must learn about Lazarus, to prove your knowledge and skill.<br />
Start by reading the [[Lazarus_Documentation|wiki articles]], read the Lazarus source code, giving a look at the [http://www.lazarus.freepascal.org/mantis Lazarus Bug-Tracker], fix some bugs, and if you think you are ready, contact the developers on the [http://www.mail-archive.com/lazarus@miraclec.com mailing list].<br />
<br />
== Where is ... defined ==<br />
<br />
=== Virtual key constants ===<br />
Virtual key constants are defined in LCLType. Add LCLtype to your <b>uses</b>.<br />
<br />
== Using the IDE ==<br />
<br />
=== How can I use "identifier completion"? ===<br />
You can invoke identifier completion by pressing [ctrl][space].<br />
Under the menu item ''Environment -> Editor Options -> Code Tools -> Automatic Features'' you can set how quick this should happen automatically.<br />
<br />
== Linux ==<br />
<br />
=== How can I debug on Linux without the IDE? ===<br />
<br />
First of all you need a debugger. gdb is the standard debugger under linux and<br />
there are several GUI-frontends available. One common frontend is ddd, which is<br />
part of most common distributions. To compile lazarus/lcl with debug-information<br />
you should then use the following commands to start a debug session:<br />
<br />
$ make clean; make OPT=-dDEBUG<br />
$ ddd lazarus<br />
<br />
Be warned however, that ddd is not as comfortable as e.g. the Lazarus debugger.<br />
Specially if it comes to view the contents of a variable you have to take into<br />
account that ddd/gdb are case sensitive whereas Pascal is case-insensitive.<br />
Therefore you have to type all variable names in uppercase to see their<br />
contents. For more information take a look into the fpc-manuals.<br />
<br />
=== I can debug now but ddd does not find my sources or complains that they contain no code. Whats that? ===<br />
<br />
This is a path-related problem with either gdb or ddd. You can aviod this by<br />
<br />
* Use the "Change directory" command from the ddd menu and choose the directory where the sources are located. The drawback of this method is that you now can't use the source of the program you started with (e.g. lazarus). Thus it may be neccessary to change the directory multiple times.<br />
* In ddd goto [Edit] [gdb-settings] and set the search-path<br />
* Create a $(HOME)/.gdbinit file like:<br />
directory /your/path/to/lazarus<br />
directory /your/path/to/lazarus/lcl<br />
directory /your/path/to/lazarus/lcl/include<br />
<br />
=== I receive an error during the linking that states /usr/bin/ld can't find -l<some lib> ===<br />
<br />
; '''Package Based Distributions''' : You need to install the package that provides the lib<somelib>.so or lib<somelib>.a files. Dynamic libs under linux have the extension .so, while static libs have the extension .a. On some Linux distro's you have installed the package (rpm, deb) <packagename> which provides <some lib>, but you also need the development package (rpm, deb), normally called <packagename>-dev, which contains the .a (static lib) and/or the .so (dynamic lib). <br />
: Some distributions have commands to find which package contains a file:<br />
: '''Mandriva'''<br />
<br />
[]$ urpmf lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -devel<br />
<br />
: '''Debian'''<br />
<br />
:install the apt-file utility (apt-get install apt-file) then<br />
<br />
[]$ apt-file search lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -dev<br />
<br />
<br />
<br />
; '''Source Based Distributions and Manual Compilation (LFS)''' : Make sure that there is a lib<somelib>.a in the path, and that it contains the right version. To let the linker find the dynamic library, create a symlink called lib<some lib>.so to lib<some lib><version>-x,y.so if necessary (and/or for static lib; lib<some lib>.a to lib<some lib><version>-x,y.a).<br />
<br />
; '''FreeBSD''' : As source based distro's, and also make sure you have -Fl/usr/local/lib in your fpc.cfg and/or Lazarus library path. Keep in mind that GTK1.2 has "gtk12" as package name under FreeBSD. (same for glib) NOTE: This has changed as of late. Newest ports have gtk-12 and glib-12 as well. You might stumble on this problem, since FPC requires the "-less" ones, you will need to symlink them like this:<br />
<br />
[]# cd /usr/local/lib && ln -s libglib-12.so libglib12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgtk-12.so libgtk12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgdk-12.so libgdk12.so<br />
<br />
; '''NetBSD''' : As source based distro's, and also make sure you have -Fl/usr/pkg/lib in your fpc.cfg and/or Lazarus library path<br />
<br />
=== How can I convert a kylix 2 project into a lazarus project? ===<br />
<br />
Nearly the same way as converting a Kylix project into a Delphi/VCL project.<br />
<br />
The LCL (Lazarus Component Library) tries to be compatible to Delphis VCL.<br />
Kylix CLX tries to be QT compatible.<br />
Here are some general hints:<br />
<br />
* Rename all used CLX Q-units like QForms, QControls, QGraphics, ... into their VCL counterparts: Forms, Controls, Graphics, ...<br />
* Add LResources to the uses section of every form source<br />
* Rename or copy all .xfm files to .lfm files.<br />
* Rename or copy .dpr file to .lpr file.<br />
* Add "Interfaces" to the uses section in the .lpr file.<br />
* Remove {$R *.res} directive<br />
* Remove {$R *.xfm} directive<br />
* Add {$mode objfpc}{$H+} or {$mode delphi}{$H+} directive to .pas and .lpr files<br />
* Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):<br />
initialization<br />
{$I unit1.lrs}<br />
:The .lrs files can be created via the lazres tool in: (lazarusdir)/tools/lazres.<br />
:For example: ./lazres unit1.lrs unit1.lfm<br />
<br />
* Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.<br />
<br />
* To make it more platform independant, reduce unit libc (which is deprecated) references and substitute with native FPC units like baseunix/unix as much as possible. This will be necessary to support other targets than linux/x86 (including OS X, FreeBSD and Linux/x86_64)<br />
<br />
=== When compiling lazarus the compiler can not find a unit. e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB ===<br />
<br />
1. Check a clean rebuild: do a 'make clean all'<br />
<br />
2. Check if the compiler has the correct version (2.0.4 or higher)<br />
<br />
3. Check if the compiler is using the right config file. The normal installation creates /etc/fpc.cfg. But fpc also searches for ~/.ppc386.cfg, ~/.fpc.cfg, /etc/ppc386.cfg and it uses only the first it finds.<br />
<br />
:'''Hint:''' You can see which config file is used with 'ppc386 -vt bogus'<br />
:Remove any ppc386.cfg as it is really obsolete.<br />
<br />
4. Check if the config file (/etc/fpc.cfg) contains the right paths to your fpc libs. There must be three lines like this:<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*<br />
:The first part of these paths (/usr/lib/fpc) depends on your system. On some systems this can be for example /usr/local/lib/fpc/... .<br />
:'''Hint:''' You can see your searchpaths with 'ppc386 -vt bogus'<br />
<br />
5. Check that the config file (/etc/fpc.cfg) does not contain search paths to the lcl source files (.pp, .pas):<br />
forbidden: -Fu(lazarus_source_directory)/lcl<br />
forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk<br />
:If you want to add the lcl for all your fpc projects, make sure that the two paths look like the following and are placed after the above fpc lib paths:<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk<br />
<br />
6. Check if the missing unit (glib.ppu) exists in your fpc lib directory. For example the gtk.ppu can be found in /usr/lib/fpc/$fpcversion/units/i386-linux/gtk/. If it does not exists, the fpc lib is corrupt and should be reinstalled.<br />
<br />
7. Check if the sources are in a NFS mounted directory. In some cases the NFS updates created files incorrectly. Please, try to move the sources into a non NFS directory and compile there.<br />
<br />
8. If you are still not succeeded try to use samplecfg script as follows:<br />
<br />
''#'' cd /usr/lib/fpc/''version''/<br />
<br />
''#'' sudo ./samplecfg /usr/lib/fpc/''\$version'' /etc<br />
<br />
Note! Do not put - / - after etc because if you do that the system will create a file - /etc/fpc.cfg/fpc.cfg. In fact we want that samplecfg make a file - /etc/fpc.cfg - not the folder /etc/fpc.cfg.<br />
<br />
=== I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS ===<br />
<br />
Probably you are using a newer fpc package, than that used for building the<br />
lazarus binaries. The best solution is to download the sources and compile<br />
lazarus manually. You can download the source snapshot or get the source<br />
via svn:<br />
<br />
$ bash<br />
$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
Make sure that lazarus get the new source directory:<br />
Environment->General Options->Files->Lazarus Directory Top<br />
<br />
===Lazarus compiles, but linking fails with: libgdk-pixbuf not found===<br />
Install the gdk-pixbuf library for gtk1.x:<br />
<br />
Where to find the gdk-pixbuf library:<br />
<br />
RPMs:<br />
http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=<br />
<br />
Debian packages:<br />
libgdk-pixbuf-dev<br />
<br />
Sources:<br />
ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/<br />
<br />
===I have SuSE and I get /usr/bin/ld: cannot find -lgtk Error: Error while linking===<br />
SuSE installs the gtk devel libs under /opt/gnome/lib (or /opt/gnome/lib64 for 64 bits), which is not in<br />
the standard lib path. Simply add it to your /etc/fpc.cfg.<br />
(-Fl/opt/gnome/lib).<br />
<br />
===Lazarus crashes with runtime error 211 after I installed a component===<br />
After I installed a component, Lazarus crashes with the following message:<br />
Threading has been used before cthreads was initialized.<br />
Make cthreads one of the first units in your uses clause.<br />
Runtime error 211 at $0066E188<br />
How can I fix this?<br />
<br />
Your freshly installed component is using threads. FPC on *nix doesn't automatically include threading support, but it must be intialized. This initialization is done in the cthreads unit. Every application using the component needs to add this unit to the uses clause of the main program. Lazarus itself is no exception. This can be done in two ways:<br />
<br />
1) Open the package. In the package editor click on ''Options''. Under page ''Usage'' add to the ''custom'' options '''-dUseCThreads'''. Then rebuild the IDE. This way the cthreads unit will be automatically used by the IDE under unix and the cthreads are initialized.<br />
<br />
2) In order to avoid modifying package, a fpc compiler option could be used directly. Open menu Tools->Configure "build Lazarus". Configure "build Lazarus" dialog will be shown, in field "Options:" type -Facthreads and then press "OK" button. The next step is to install the package. Lazarus will be built with option -Facthreads which means that it will treat main program as if unit cthreads where first in uses clause. <br />
<br />
''Hint:'' Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.<br />
<br />
See also [[Multithreaded_Application_Tutorial#Units_needed_for_a_multithreaded_application]]<br />
<br />
===When I run a program with threads I get runtime error 232===<br />
The complete error message is:<br />
This binary has no thread support compiled in.<br />
Recompile the application with a thread-driver in the program uses<br />
clause before other units using thread.<br />
Runtime error 232<br />
'''Solution''': Add cthreads as first unit to the uses clause of your main program, usually the .lpr-file.<br />
<br />
===I have Ubuntu Breezy and my fonts in Lazarus IDE look too big===<br />
If Lazarus is compiled with Gtk1.2, the settings in Gnome Preferences/Font don't have any effect as<br />
they are related to Gtk2.<br />
You could try this solution:<br />
Create a file named .gtkrc.mine in your home directory (if it's not already there) and add<br />
these lines to it:<br />
<br />
<pre><br />
style "default-text" {<br />
fontset = "-*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\<br />
-*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"<br />
}<br />
<br />
class "GtkWidget" style "default-text"<br />
</pre><br />
<br />
If this is not enough try and create also a .gtkrc symlink to .gtkrc.mine . It worked in this way under Xubuntu 7.10.<br />
<br />
===How can my gtk programs use custom rc files?===<br />
<br />
Option a)<br />
Name the rc file ''yourprogram.gtkrc'' and put it in the same directory where the executable is.<br />
<br />
Option b)<br />
Use unit ''GtkInt'' and call ''GTKWidgetSet.SetRCFilename('your_preferred_rc_file');''<br />
Best done before ''Application.Initialize'' in the .lpr file with ''{$IFDEF LCLGtk}''.<br />
<br />
===I have Ubuntu and I cannot compile for Gtk2 due to missing libraries===<br />
Ubuntu has a problem with not creating all the symbolic links that you'll need even when the libraries are installed. Make sure that all missing libraries when trying to link for Gtk2 have their appropriate links. For instance, you might need to do:<br />
<br />
<pre><br />
cd /usr/lib<br />
sudo ln -s libgdk-x11-2.0.so.0 libgtk-x11-2.0.so<br />
</pre><br />
<br />
Make sure that the [whatever].so symbolic links are created and point to the actual libraries.<br />
<br />
===How can I compile a program for Gtk2?===<br />
<br />
At the moment, the Gtk2 compiled IDE is a little unstable, but you can compile software for Gtk2 using the Gtk1 IDE.<br />
<br />
To start with recompile LCL for Gtk2. Go to the menu "Tools"->"Configure Build Lazarus" and set LCL to clean+build and everything else to none.<br />
<br />
Now click Ok and go to the menu "Tools"->"Build Lazarus"<br />
<br />
Now you can compile your software with Gtk2 going on the Compiler options and changing the widgetset to Gtk2.<br />
<br />
===I get this message: "[WARNING] ** Multibyte character encodings (like UTF8) are not supported at the moment."===<br />
<br />
Since revision 10535 (0.9.21) this message doesn't exist anymore. <br />
Previously it was used to warn that a UTF-8 encoding was used. The internal keyhandling routines for the gtk1 widgetset couldn't handle such encoding for keypresses, with the result that keypresses with for instance accented chars were not or wrong detected.<br />
<br />
(original text for older versions of lazarus)<br><br />
<strike><br />
This warning message indicates that your locale enconding is set to utf-8. If you are using Gtk 1 this can be a serious problem and prevent the correct working of Lazarus or software created with Lazarus.<br />
<br />
To work around this, just change your locale to a non utf-8 before executing the program on the command line, like this:<br />
<br />
<pre><br />
export LC_CTYPE="pt_BR"<br />
export LANG="pt_BR"<br />
export LANGUAGE="pt_BR"<br />
./lazarus<br />
</pre><br />
<br />
Substitute pt_BR with the locale for your country. You can create a script to automate this.<br />
</strike><br />
<br />
== Windows ==<br />
<br />
=== When I cycle the compiler, I get:The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time. ===<br />
<br />
In the compiler directory there is an OS2 scriptfile named make.cmd. Different versions of Windows also see this as a script file, so remove it since what is needed for OS2 becomes a hindrance on Windows.<br />
<br />
=== When I cycle the compiler, I get: make[3]: ./ppc1.exe: Command not found ===<br />
<br />
I don't know why but somehow make has lost its path. Try to cycle with a<br />
basedir set like: make cycle BASEDIR=your_fpc_source_dir_herecompiler<br />
<br />
=== When I try to make Lazarus I get:===<br />
====make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2 ====<br />
You need to upgrade your make.<br />
<br />
====makefile:27: *** You need the GNU utils package to use this Makefile. Stop.====<br />
Make sure you didn't install FPC in a path with spaces in the name. The<br />
Makefile doesn't support it.<br />
<br />
<br />
<br />
===How can I give my program an XP look like lazarus has?===<br />
Project -> Project Options -> Check 'Use manifest to enables themes'.<br />
<br />
===When I run Windows program created in Lazarus it starts with a DOS window===<br />
Specify the -WG argument (Windows GUI) on the command line of the compiler or in the Lazarus IDE check the Windows GUI check box on the compiler options dialog box (Project menu -> Compiler Options -> Linking -> target OS Specific options.<br />
<br />
== Mac OS X ==<br />
<br />
=== Why does compiling a project fail with 'unknown section attribute: no_dead_strip'?===<br />
<br />
Dead code stripping is not supported by the assembler and linker before Xcode 1.5 (available for Mac OS X 10.3.9). Disable the compiler options <br />
<br />
*Code > Unit style > Smart linkable (-CX) <br />
*and Linking > Link Style > Link smart (-XX)<br />
<br />
== Licensing ==<br />
<br />
=== Can I make commercial applications with Lazarus ? ===<br />
<br />
Yes, the LCL is licensed under the LGPL with an exception, which allows you to link to it statically without releasing the source of your application. Modifications and enhancements to the LCL must be distributed with source. Lazarus, the IDE, is licensed under the GPL.<br />
<br />
=== Can I make commercial plug-ins for Lazarus ? ===<br />
<br />
Yes, the IDEIntf part of the IDE is licensed under the LGPL with the same exception, so that shared data structures in this part will not force you to license your plug-in or design-time package under the GPL. You are free to choose a plug-in of any license; we don't want to limit your choice. Therefore non-GPL compatible plug-ins are allowed. Note that it's not allowed to distribute a precompiled Lazarus with these non-GPL-compatible plugins included statically; however, we do not see this as a severe limitation, since recompiling Lazarus is easy.<br />
<br />
== Contributors and Comments ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq version].</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Faq/ko&diff=32368Lazarus Faq/ko2008-11-27T14:44:11Z<p>Oranke: /* 도대체 실행파일의 크기가 왜 이렇게 큰 겁니까? */</p>
<hr />
<div>{{Lazarus Faq}}<br />
<br />
이 문서는 원래 www.lazarus.freepascal.org 에 있던 것 입니다. 관리 및 확장 면에서 위키가 훨씬 더 유용하기 때문에 이 곳으로 복사되었습니다. <br />
<br />
== 일반적인 이야기 ==<br />
<br />
=== 더 많은 FAQ를 볼 수 있는 곳은 어디인가요? ===<br />
See the [http://www.lazarus.freepascal.org official website]. There is another FAQ as well.<br />
<br />
===도대체 실행파일의 크기가 왜 이렇게 큰 겁니까?===<br />
실행파일의 크기가 큰 이유는 GDB (GNU Debugger) 를 사용하기 위한 많은 정보들을 포함하고 있기 때문입니다. <br />
<br />
컴파일러에 이 디버깅 정보를 제거하기 위한 옵션 (-Xs) 이 있습니다만, 버전 2.0.2 이전의 컴파일러는 이 기능에 버그가 있기 때문에 제대로 동작하지 않습니다. 이 버그는 현재 개발버전에서는 수정되었습니다. <br />
<br />
"strip" 이라는 이름의 프로그램을 사용하면 실행파일로 부터 디버그 심볼을 삭제할 수 있습니다. 이 프로그램은 lazarus\pp\bin\i386-win32\ 에 있습니다. <br />
<br />
커맨드 라인에서 간단하게 "strip --strip-all <만든 실행파일의 경로명과 파일명>" 을 입력 하세요.<br />
<br />
실행파일을 좀 더 작게 만들려면, [http://upx.sourceforge.net/ UPX] 가 좋은 해법이 될 것입니다. UPX는 강력 추천하는 실행파일 압축기 입니다. <br />
It includes no memory overhead due to in-place decompression. It also has a very fast decompression (~10 MB/sec on an Pentium 133).<br />
<br />
To use upx just type "upx <your executable file with path>" on the command line.<br />
<br />
after using both strip and upx a simple GUI Lazarus program gets:<br />
* ~ 700kb on Linux<br />
* ~ 420kb on Windows<br />
<br />
A more detailed answer with the drawbacks of using UPX is given on [[Size Matters]].<br />
<br />
It's also important to note that the hello world lazarus software already includes a huge amount of features. It includes:<br />
<br />
* XML handling library<br />
* Image handling library for png, xpm, bmp and ico files<br />
* Almost all widgets from the Lazarus Component Library<br />
* All of the Free Pascal Runtime Library<br />
<br />
So it's very big, but it already includes almost everything a real world non-trivial app will need.<br />
<br />
Lazarus executable size starts big, but grows very slowly, because of the Free Pascal compiler and the way lazarus forms operate. A c++ project (just an example, but applies to other languages / tools too) starts very small on the hello world, but quickly grows exponentially when you need features to write a non-trivial application.<br />
<br />
[[Image:Lazarus_vs_cpp.png]]<br />
<br />
=== Why is the linking so slow on Windows? ===<br />
<br />
This problem is over from FPC 2.2 and Lazarus 0.9.24. Please update your Lazarus. For older versions read text below.<br />
<br />
Generally speaking, compilation on Windows takes more time then other platforms because the GNU Linker utilized by Free Pascal is slow on this platform. This problem only affects Windows, and is only bad on relatively old computers (less then 1Ghz) and computers with little RAM (128MB or less).<br />
<br />
Also, if you smartlink LCL the linking will be much slower. A study about this is located here: [[File size and smartlinking]]<br />
<br />
A internal linker was developed, and is ready, but will only be available when Free Pascal 2.2 is released (of course it's also available via subversion). It decreases the linking time dramatically.<br />
<br />
'''Note''': In 2.1.1 Windows uses an internal linker for win32/64/ce which speeds the process up a bit. A Lazarus recompile then eats about 280MB.<br />
<br />
=== Do I need ppc386.cfg or fpc.cfg? ===<br />
<br />
You only need fpc.cfg. This way the compiler knows where to find the libraries.<br />
<br />
=== How do I compile lazarus? ===<br />
<br />
Do something like this:<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
=== How do I build other projects based upon the LCL ===<br />
<br />
If you can't use the IDE to build your applications, use lazbuild. This is a command line version of the IDE to build lazarus projects and packages.<br />
If you want to build LCL applications without the IDE and without the lazbuild, add the following lines to the end of your ''fpc.cfg''<br />
<br />
# searchpath for other toolkits (Linux)<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{YourToolKit}<br />
<br />
# searchpath for other toolkits (Windows)<br />
-Fu/{YourLazarusDirectory}/components/units/{YourToolKit}<br />
<br />
:Where {YourToolKit} may be ''gtk2'', ''gnome'', ''qt'' or ''win32'' and run:<br />
::ppc386 your.project.pp<br />
<br />
'''Hint:''' Don't forget to install the development packages for your toolkit otherwise you might a receive something like: [[Linker message: cannot find -l]].<br />
<br />
=== What version of FPC is required? ===<br />
<br />
2.0.4 for MacOSX and 2.2.2 for all other systems. Warning: The 2.2.0 has a bug under MacOSX with case sensitive filenames.<br />
You can also use the svn version of fpc 2.2.3 and 2.3.x.<br />
<br />
=== I can't compile Lazarus ===<br />
<br />
# Check if the compiler has the correct version<br />
# Check if the (fpc)libraries are from the same version.<br />
# Check if you have a fpc.cfg and no old ppc386.cfg<br />
# Check also the OS-dependent FAQs<br />
<br />
=== When I try to compile a project, I have an error ===<br />
==== "Cannot find Unit interfaces". How can I solve this?====<br />
It means the compiler can not find the file 'interfaces.ppu' '''or''' it means it found one, but it is wrong or outdated.<br />
<br />
This unit can be found in {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu. For example: /home/username/lazarus/lcl/units/i386-linux/gtk/interfaces.ppu.<br />
<br />
Make sure, it is only there. If you have multiple versions of interfaces.ppu, then you probably have a wrong configuration (for instance you added a lcl directory to a search path). Remove all interfaces.ppu, but the one in the directory above.<br />
<br />
If you selected a different widgetset than you used to build lazarus, you need to build the LCL for this widgetset. <br />
<br />
If it is there, but you get this error, you are using a different compiler / rtl for compiling your project than you used for compiling your Lazarus IDE. You can do one of the following<br />
* Rebuild the LCL (or Lazarus completely) with the compiler selected in the Environmnent Options. You can do this with Tools -> Build Lazarus. Before doing this, check the current settings in Tools -> Configure Build Lazarus.<br />
* Change the compiler in the Environment Options to the one you used to compile Lazarus. Look carefully also in the Environment Options to see if you are using the correct paths for the Lazarus Directory and the FPC sources directory. Check that there is only one version of the compiler configuration file fpc.cfg - it should reside in /etc/ for Linux/Unix systems or in the same directory as the fpc compiler for Windows systems. Try to run "fpc -vt bogus" to check which fpc.cfg is being used in your system. Rogue copies often creep in if you have updated your compiler to a new version; they may be found in your home directory or in the same directory as the one in which you built your new compiler. DELETE THESE!!<br />
* You may also try to change the widgetset currently selected for the project. For example, the sample project "objectinspector" that comes with Lazarus is set to gtk by default. Compiling this project will surely give you "Can't find unit interfaces" in Windows platform. Changing widgetset to default(Win32) in Project | Compiler Options... | LCL Widget Type (various) should fix this issue.<br />
<br />
=== When I try to compile delphi projects under lazarus, I have an error ===<br />
==== at the line :{$R *.DFM} How can I solve this problem ? ====<br />
<br />
Lazarus (or better Linux) doesn't know about resources, so you can't use them in the way Delphi/Win32 does. However Lazarus uses a method pretty compatible with this. You can still use your Delphi layouts (.dfm files) if you use the following steps:<br />
<br />
*You need a textual version of the .dfm files. D5 and higher are doing this as default. If you have older files: ALT-F12 to see the layout as text and paste/copy. When you have a text .dfm file, just copy it to a .lfm file.<br />
*Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm<br />
*Add the following initialization section to<br />
<br />
initialization<br />
{$I yourform.lrs}<br />
<br />
Please keep in mind that not all properties in the dfm are supported yet by<br />
lazarus, so you might get a crash.<br />
<br />
==== 'Identifier not found LazarusResources'. ====<br />
<br />
When creating a form Lazarus automaticaly add some extra units to the uses section of your form unit. During the conversion of a delphi unit to a Lazarus unit this does not happen. So you need to add LResources to the Uses section of your form unit.<br />
<br />
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===<br />
<br />
Make sure, in the Project -> Project Inspector, that your project depends on the package 'LCL' and that you have installed the FPC sources.<br />
<br />
Lazarus is the IDE and the visual components library LCL.<br />
All other stuff, like IO, Database, FCL and RTL are provided by FPC.<br />
The IDE needs the paths to all sources.<br />
<br />
The FPC source path can be set via:<br />
Environment -> Environment Options -> Files -> FPC source directory<br />
<br />
===How to embed a small file in the executable, without the need of a separate file? How to embed a resource?===<br />
<br />
For example:<br />
/your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...<br />
will create sound.lrs from sound1.wav and sound2.wav.<br />
<br />
Then include it *behind* the form lrs file:<br />
<br />
...<br />
initialization<br />
{$i unit1.lrs} // this is main resource file (first)<br />
{$i sound.lrs} // user defined resource file<br />
<br />
end.<br />
In your program you can then use:<br />
Sound1AsString:=LazarusResources.Find('sound1').Value;<br />
<br />
=== How can I see debug output? ===<br />
<br />
The LCL has in the LCLProc unit two procedures to write debug output. They are named: <br />
* '''DebugLn:''' which works about the same as WriteLn, but accepts only strings.<br />
* '''DbgOut:''' which works about the same as Write, but accepts only strings.<br />
<br />
In normal circumstances the output is written to stdout. If stdout is closed, (for example when the application is {$AppType Gui} or compiled with -WG on Windows), no output is written.<br />
<br />
Debug output can also be written to file. The initialization code of the LCLProc unit checks Lazarus.exe's command line parameters for '--debug-log=<file>'. On finding this parameter any subsequent debug output is sent to <file>.<br />
<br />
If no '--debug-log' command line parameter has been given, it next checks if an operating system environment variable xxx_debuglog exists, where xxx is the program file name without extension. For Lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses the file specified in the lazarus_debuglog environment variable as file to receive debug output. Example: if you do:<br />
set lazarus_debuglog=c:\lazarus\debug.txt<br />
debug output will be written to c:\lazarus\debug.txt.<br />
<br />
Since this is implemented in lclproc, every application using lclproc, can use this output facility.<br />
<br />
;Debuging Lazarus : Most useful for Windows: If you want output on a console, add {$APPTYPE console} to lazarus.pp ; Then rebuild Lazarus.<br />
<br />
=== What is the meaning of the various file extensions used by Lazarus? ===<br />
<br />
The [[Lazarus Tutorial#The Lazarus files]] explains some extensions by an example.<br />
Here is a brief list:<br />
<br />
; <code>*.lpi</code> : Lazarus Project Information file (stored in XML; contains project-specific settings)<br />
; <code>*.lpr</code> : Lazarus Program file; contains Pascal source of main program<br />
; <code>*.lfm</code> : Lazarus Form file; contains configuration information for all objects on a form (stored in a Lazarus-specific textual format; the actions are described by Pascal source code in a corresponding <code>*.pas</code> file)<br />
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code (typically for a form stored in a corresponding <code>*.lfm</code> file)<br />
; <code>*.lrs</code> : Lazarus Resource file (this is a generated file; not to be confused with a Windows resource file). <br />
: This file can be created with lazres tool (in directory Lazarus/Tools) using commandline: lazres myfile.lrs myfile.lfm<br />
; <code>*.ppu</code> : Compiled unit<br />
; <code>*.lpk</code> : Lazarus package information file. (stored in XML; contains package-specific settings)<br />
<br />
=== I have fixed/improved lazarus. How can I add my changes to the official lazarus source? ===<br />
Create a patch and send it to the developers. For details see [[Creating A Patch]].<br />
=== When I do ''var mytext: text;'' to declare a text file, I get "Unit1.pas(32,15) Error: Error in type definition". How can I fix this?===<br />
The TControl class has a [[doc:lcl/controls/tcontrol.text.html|Text]] property. In a method of a form, that has higher visibility, the [[doc:rtl/system/text.html|Text]] type from the system unit. You can use the [[doc:rtl/system/textfile.html|TextFile]] type, which is just an alias for the Text type or you can add the unit to the type definition.<br />
var<br />
MyTextFile: TextFile;<br />
MyText: System.Text;<br />
A similar name clash exists with assigning and closing a text file. TForm has a ''assign'' and a [[doc:lcl/forms/tcustomform.close.html|Close]] method. You can use [[doc:rtl/objpas/assignfile.html|AssignFile]] and [[doc:rtl/objpas/closefile.html|CloseFile]] or add the unit name ''System''.<br />
<br />
=== I get an error when using Printer.BeginDoc ===<br />
<br />
The unit Printers must be added to the uses section.<br />
<br />
The Printer4Lazarus package must be added to your project requirement in the IDE under:<br />
Project|Project Inspector|Add|New Requirement|Package Name:<br />
<br />
If the package Printer4Lazarus package is not in the list when opening the dropdown box it must be installed. The package is part of the Lazarus installation and can be found in:<br />
[lazarus installed directory]\components\printers<br />
<br />
If you used the default installation directories [lazarus installed directory] is:<br />
*Windows: c:\lazarus <br />
*Linux: /usr/lib/lazarus<br />
<br />
The same solution also applies to the exception you can get when referencing Printer.Printers<br />
<br />
=== Why are TForm.ClientWidth/ClientHeight the same as TForm.Width/Height ===<br />
<br />
The TForm.Width/Height do no include the frame, because there was no way to retrieve the frame size on all platforms. Without a reliable way, the LCL would move the forms around on the screen or resize them endlessly.<br />
<br />
Eventually when there is a reliable way to get the size and position of a window with its frame on all platforms, then it will be changed. To keep compatibility with older LCL forms, a version number and some extra methods will be added.<br />
<br />
=== I created a Patch to dock the IDE Messages form on the "Source Code Editor" form (at bottom) ===<br />
<br />
Such patches will not be applied, because they only implement a small part of the needed docking. The goal is to create a complete dock manager and use that. A complete dock manager can dock all IDE windows and it allows to let the user define how to dock. For example dock the messages window above or below the source editor or ... or not at all. For instance:<br />
<br />
<pre><br />
+-------------------++--+<br />
|menu || |<br />
+-------------------+| |<br />
+--++---------------+| |<br />
|PI|| Source Editor ||CE|<br />
+--+| || |<br />
+--+| || |<br />
| |+---------------++--+<br />
|OI|+-------------------+<br />
| ||messages |<br />
+--++-------------------+<br />
</pre><br />
<br />
The dock manager can store the layout and restore it on next load. Preferably the dock manager can dock in pages too. The dock manager does not need to use drag and drop.<br />
All patches implementing docking without a dock manager makes it harder to implement a real dock manager and will be rejected.<br />
<br />
=== How can I become a developer lazarus and access management in the SVN and bug-tracker? ===<br />
<br />
First of all: you must learn about Lazarus, to prove your knowledge and skill.<br />
Start by reading the [[Lazarus_Documentation|wiki articles]], read the Lazarus source code, giving a look at the [http://www.lazarus.freepascal.org/mantis Lazarus Bug-Tracker], fix some bugs, and if you think you are ready, contact the developers on the [http://www.mail-archive.com/lazarus@miraclec.com mailing list].<br />
<br />
== Where is ... defined ==<br />
<br />
=== Virtual key constants ===<br />
Virtual key constants are defined in LCLType. Add LCLtype to your <b>uses</b>.<br />
<br />
== Using the IDE ==<br />
<br />
=== How can I use "identifier completion"? ===<br />
You can invoke identifier completion by pressing [ctrl][space].<br />
Under the menu item ''Environment -> Editor Options -> Code Tools -> Automatic Features'' you can set how quick this should happen automatically.<br />
<br />
== Linux ==<br />
<br />
=== How can I debug on Linux without the IDE? ===<br />
<br />
First of all you need a debugger. gdb is the standard debugger under linux and<br />
there are several GUI-frontends available. One common frontend is ddd, which is<br />
part of most common distributions. To compile lazarus/lcl with debug-information<br />
you should then use the following commands to start a debug session:<br />
<br />
$ make clean; make OPT=-dDEBUG<br />
$ ddd lazarus<br />
<br />
Be warned however, that ddd is not as comfortable as e.g. the Lazarus debugger.<br />
Specially if it comes to view the contents of a variable you have to take into<br />
account that ddd/gdb are case sensitive whereas Pascal is case-insensitive.<br />
Therefore you have to type all variable names in uppercase to see their<br />
contents. For more information take a look into the fpc-manuals.<br />
<br />
=== I can debug now but ddd does not find my sources or complains that they contain no code. Whats that? ===<br />
<br />
This is a path-related problem with either gdb or ddd. You can aviod this by<br />
<br />
* Use the "Change directory" command from the ddd menu and choose the directory where the sources are located. The drawback of this method is that you now can't use the source of the program you started with (e.g. lazarus). Thus it may be neccessary to change the directory multiple times.<br />
* In ddd goto [Edit] [gdb-settings] and set the search-path<br />
* Create a $(HOME)/.gdbinit file like:<br />
directory /your/path/to/lazarus<br />
directory /your/path/to/lazarus/lcl<br />
directory /your/path/to/lazarus/lcl/include<br />
<br />
=== I receive an error during the linking that states /usr/bin/ld can't find -l<some lib> ===<br />
<br />
; '''Package Based Distributions''' : You need to install the package that provides the lib<somelib>.so or lib<somelib>.a files. Dynamic libs under linux have the extension .so, while static libs have the extension .a. On some Linux distro's you have installed the package (rpm, deb) <packagename> which provides <some lib>, but you also need the development package (rpm, deb), normally called <packagename>-dev, which contains the .a (static lib) and/or the .so (dynamic lib). <br />
: Some distributions have commands to find which package contains a file:<br />
: '''Mandriva'''<br />
<br />
[]$ urpmf lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -devel<br />
<br />
: '''Debian'''<br />
<br />
:install the apt-file utility (apt-get install apt-file) then<br />
<br />
[]$ apt-file search lib<somelib>.so<br />
<br />
:will list all packages containing the file named lib<somelib>.so, you'll have to install those ending in -dev<br />
<br />
<br />
<br />
; '''Source Based Distributions and Manual Compilation (LFS)''' : Make sure that there is a lib<somelib>.a in the path, and that it contains the right version. To let the linker find the dynamic library, create a symlink called lib<some lib>.so to lib<some lib><version>-x,y.so if necessary (and/or for static lib; lib<some lib>.a to lib<some lib><version>-x,y.a).<br />
<br />
; '''FreeBSD''' : As source based distro's, and also make sure you have -Fl/usr/local/lib in your fpc.cfg and/or Lazarus library path. Keep in mind that GTK1.2 has "gtk12" as package name under FreeBSD. (same for glib) NOTE: This has changed as of late. Newest ports have gtk-12 and glib-12 as well. You might stumble on this problem, since FPC requires the "-less" ones, you will need to symlink them like this:<br />
<br />
[]# cd /usr/local/lib && ln -s libglib-12.so libglib12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgtk-12.so libgtk12.so<br />
[]# cd /usr/X11R6/lib && ln -s libgdk-12.so libgdk12.so<br />
<br />
; '''NetBSD''' : As source based distro's, and also make sure you have -Fl/usr/pkg/lib in your fpc.cfg and/or Lazarus library path<br />
<br />
=== How can I convert a kylix 2 project into a lazarus project? ===<br />
<br />
Nearly the same way as converting a Kylix project into a Delphi/VCL project.<br />
<br />
The LCL (Lazarus Component Library) tries to be compatible to Delphis VCL.<br />
Kylix CLX tries to be QT compatible.<br />
Here are some general hints:<br />
<br />
* Rename all used CLX Q-units like QForms, QControls, QGraphics, ... into their VCL counterparts: Forms, Controls, Graphics, ...<br />
* Add LResources to the uses section of every form source<br />
* Rename or copy all .xfm files to .lfm files.<br />
* Rename or copy .dpr file to .lpr file.<br />
* Add "Interfaces" to the uses section in the .lpr file.<br />
* Remove {$R *.res} directive<br />
* Remove {$R *.xfm} directive<br />
* Add {$mode objfpc}{$H+} or {$mode delphi}{$H+} directive to .pas and .lpr files<br />
* Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):<br />
initialization<br />
{$I unit1.lrs}<br />
:The .lrs files can be created via the lazres tool in: (lazarusdir)/tools/lazres.<br />
:For example: ./lazres unit1.lrs unit1.lfm<br />
<br />
* Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.<br />
<br />
* To make it more platform independant, reduce unit libc (which is deprecated) references and substitute with native FPC units like baseunix/unix as much as possible. This will be necessary to support other targets than linux/x86 (including OS X, FreeBSD and Linux/x86_64)<br />
<br />
=== When compiling lazarus the compiler can not find a unit. e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB ===<br />
<br />
1. Check a clean rebuild: do a 'make clean all'<br />
<br />
2. Check if the compiler has the correct version (2.0.4 or higher)<br />
<br />
3. Check if the compiler is using the right config file. The normal installation creates /etc/fpc.cfg. But fpc also searches for ~/.ppc386.cfg, ~/.fpc.cfg, /etc/ppc386.cfg and it uses only the first it finds.<br />
<br />
:'''Hint:''' You can see which config file is used with 'ppc386 -vt bogus'<br />
:Remove any ppc386.cfg as it is really obsolete.<br />
<br />
4. Check if the config file (/etc/fpc.cfg) contains the right paths to your fpc libs. There must be three lines like this:<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl<br />
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*<br />
:The first part of these paths (/usr/lib/fpc) depends on your system. On some systems this can be for example /usr/local/lib/fpc/... .<br />
:'''Hint:''' You can see your searchpaths with 'ppc386 -vt bogus'<br />
<br />
5. Check that the config file (/etc/fpc.cfg) does not contain search paths to the lcl source files (.pp, .pas):<br />
forbidden: -Fu(lazarus_source_directory)/lcl<br />
forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk<br />
:If you want to add the lcl for all your fpc projects, make sure that the two paths look like the following and are placed after the above fpc lib paths:<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget<br />
-Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk<br />
<br />
6. Check if the missing unit (glib.ppu) exists in your fpc lib directory. For example the gtk.ppu can be found in /usr/lib/fpc/$fpcversion/units/i386-linux/gtk/. If it does not exists, the fpc lib is corrupt and should be reinstalled.<br />
<br />
7. Check if the sources are in a NFS mounted directory. In some cases the NFS updates created files incorrectly. Please, try to move the sources into a non NFS directory and compile there.<br />
<br />
8. If you are still not succeeded try to use samplecfg script as follows:<br />
<br />
''#'' cd /usr/lib/fpc/''version''/<br />
<br />
''#'' sudo ./samplecfg /usr/lib/fpc/''\$version'' /etc<br />
<br />
Note! Do not put - / - after etc because if you do that the system will create a file - /etc/fpc.cfg/fpc.cfg. In fact we want that samplecfg make a file - /etc/fpc.cfg - not the folder /etc/fpc.cfg.<br />
<br />
=== I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS ===<br />
<br />
Probably you are using a newer fpc package, than that used for building the<br />
lazarus binaries. The best solution is to download the sources and compile<br />
lazarus manually. You can download the source snapshot or get the source<br />
via svn:<br />
<br />
$ bash<br />
$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus<br />
$ cd lazarus<br />
$ make clean all<br />
<br />
Make sure that lazarus get the new source directory:<br />
Environment->General Options->Files->Lazarus Directory Top<br />
<br />
===Lazarus compiles, but linking fails with: libgdk-pixbuf not found===<br />
Install the gdk-pixbuf library for gtk1.x:<br />
<br />
Where to find the gdk-pixbuf library:<br />
<br />
RPMs:<br />
http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=<br />
<br />
Debian packages:<br />
libgdk-pixbuf-dev<br />
<br />
Sources:<br />
ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/<br />
<br />
===I have SuSE and I get /usr/bin/ld: cannot find -lgtk Error: Error while linking===<br />
SuSE installs the gtk devel libs under /opt/gnome/lib (or /opt/gnome/lib64 for 64 bits), which is not in<br />
the standard lib path. Simply add it to your /etc/fpc.cfg.<br />
(-Fl/opt/gnome/lib).<br />
<br />
===Lazarus crashes with runtime error 211 after I installed a component===<br />
After I installed a component, Lazarus crashes with the following message:<br />
Threading has been used before cthreads was initialized.<br />
Make cthreads one of the first units in your uses clause.<br />
Runtime error 211 at $0066E188<br />
How can I fix this?<br />
<br />
Your freshly installed component is using threads. FPC on *nix doesn't automatically include threading support, but it must be intialized. This initialization is done in the cthreads unit. Every application using the component needs to add this unit to the uses clause of the main program. Lazarus itself is no exception. This can be done in two ways:<br />
<br />
1) Open the package. In the package editor click on ''Options''. Under page ''Usage'' add to the ''custom'' options '''-dUseCThreads'''. Then rebuild the IDE. This way the cthreads unit will be automatically used by the IDE under unix and the cthreads are initialized.<br />
<br />
2) In order to avoid modifying package, a fpc compiler option could be used directly. Open menu Tools->Configure "build Lazarus". Configure "build Lazarus" dialog will be shown, in field "Options:" type -Facthreads and then press "OK" button. The next step is to install the package. Lazarus will be built with option -Facthreads which means that it will treat main program as if unit cthreads where first in uses clause. <br />
<br />
''Hint:'' Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.<br />
<br />
See also [[Multithreaded_Application_Tutorial#Units_needed_for_a_multithreaded_application]]<br />
<br />
===When I run a program with threads I get runtime error 232===<br />
The complete error message is:<br />
This binary has no thread support compiled in.<br />
Recompile the application with a thread-driver in the program uses<br />
clause before other units using thread.<br />
Runtime error 232<br />
'''Solution''': Add cthreads as first unit to the uses clause of your main program, usually the .lpr-file.<br />
<br />
===I have Ubuntu Breezy and my fonts in Lazarus IDE look too big===<br />
If Lazarus is compiled with Gtk1.2, the settings in Gnome Preferences/Font don't have any effect as<br />
they are related to Gtk2.<br />
You could try this solution:<br />
Create a file named .gtkrc.mine in your home directory (if it's not already there) and add<br />
these lines to it:<br />
<br />
<pre><br />
style "default-text" {<br />
fontset = "-*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\<br />
-*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"<br />
}<br />
<br />
class "GtkWidget" style "default-text"<br />
</pre><br />
<br />
If this is not enough try and create also a .gtkrc symlink to .gtkrc.mine . It worked in this way under Xubuntu 7.10.<br />
<br />
===How can my gtk programs use custom rc files?===<br />
<br />
Option a)<br />
Name the rc file ''yourprogram.gtkrc'' and put it in the same directory where the executable is.<br />
<br />
Option b)<br />
Use unit ''GtkInt'' and call ''GTKWidgetSet.SetRCFilename('your_preferred_rc_file');''<br />
Best done before ''Application.Initialize'' in the .lpr file with ''{$IFDEF LCLGtk}''.<br />
<br />
===I have Ubuntu and I cannot compile for Gtk2 due to missing libraries===<br />
Ubuntu has a problem with not creating all the symbolic links that you'll need even when the libraries are installed. Make sure that all missing libraries when trying to link for Gtk2 have their appropriate links. For instance, you might need to do:<br />
<br />
<pre><br />
cd /usr/lib<br />
sudo ln -s libgdk-x11-2.0.so.0 libgtk-x11-2.0.so<br />
</pre><br />
<br />
Make sure that the [whatever].so symbolic links are created and point to the actual libraries.<br />
<br />
===How can I compile a program for Gtk2?===<br />
<br />
At the moment, the Gtk2 compiled IDE is a little unstable, but you can compile software for Gtk2 using the Gtk1 IDE.<br />
<br />
To start with recompile LCL for Gtk2. Go to the menu "Tools"->"Configure Build Lazarus" and set LCL to clean+build and everything else to none.<br />
<br />
Now click Ok and go to the menu "Tools"->"Build Lazarus"<br />
<br />
Now you can compile your software with Gtk2 going on the Compiler options and changing the widgetset to Gtk2.<br />
<br />
===I get this message: "[WARNING] ** Multibyte character encodings (like UTF8) are not supported at the moment."===<br />
<br />
Since revision 10535 (0.9.21) this message doesn't exist anymore. <br />
Previously it was used to warn that a UTF-8 encoding was used. The internal keyhandling routines for the gtk1 widgetset couldn't handle such encoding for keypresses, with the result that keypresses with for instance accented chars were not or wrong detected.<br />
<br />
(original text for older versions of lazarus)<br><br />
<strike><br />
This warning message indicates that your locale enconding is set to utf-8. If you are using Gtk 1 this can be a serious problem and prevent the correct working of Lazarus or software created with Lazarus.<br />
<br />
To work around this, just change your locale to a non utf-8 before executing the program on the command line, like this:<br />
<br />
<pre><br />
export LC_CTYPE="pt_BR"<br />
export LANG="pt_BR"<br />
export LANGUAGE="pt_BR"<br />
./lazarus<br />
</pre><br />
<br />
Substitute pt_BR with the locale for your country. You can create a script to automate this.<br />
</strike><br />
<br />
== Windows ==<br />
<br />
=== When I cycle the compiler, I get:The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time. ===<br />
<br />
In the compiler directory there is an OS2 scriptfile named make.cmd. Different versions of Windows also see this as a script file, so remove it since what is needed for OS2 becomes a hindrance on Windows.<br />
<br />
=== When I cycle the compiler, I get: make[3]: ./ppc1.exe: Command not found ===<br />
<br />
I don't know why but somehow make has lost its path. Try to cycle with a<br />
basedir set like: make cycle BASEDIR=your_fpc_source_dir_herecompiler<br />
<br />
=== When I try to make Lazarus I get:===<br />
====make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2 ====<br />
You need to upgrade your make.<br />
<br />
====makefile:27: *** You need the GNU utils package to use this Makefile. Stop.====<br />
Make sure you didn't install FPC in a path with spaces in the name. The<br />
Makefile doesn't support it.<br />
<br />
<br />
<br />
===How can I give my program an XP look like lazarus has?===<br />
Project -> Project Options -> Check 'Use manifest to enables themes'.<br />
<br />
===When I run Windows program created in Lazarus it starts with a DOS window===<br />
Specify the -WG argument (Windows GUI) on the command line of the compiler or in the Lazarus IDE check the Windows GUI check box on the compiler options dialog box (Project menu -> Compiler Options -> Linking -> target OS Specific options.<br />
<br />
== Mac OS X ==<br />
<br />
=== Why does compiling a project fail with 'unknown section attribute: no_dead_strip'?===<br />
<br />
Dead code stripping is not supported by the assembler and linker before Xcode 1.5 (available for Mac OS X 10.3.9). Disable the compiler options <br />
<br />
*Code > Unit style > Smart linkable (-CX) <br />
*and Linking > Link Style > Link smart (-XX)<br />
<br />
== Licensing ==<br />
<br />
=== Can I make commercial applications with Lazarus ? ===<br />
<br />
Yes, the LCL is licensed under the LGPL with an exception, which allows you to link to it statically without releasing the source of your application. Modifications and enhancements to the LCL must be distributed with source. Lazarus, the IDE, is licensed under the GPL.<br />
<br />
=== Can I make commercial plug-ins for Lazarus ? ===<br />
<br />
Yes, the IDEIntf part of the IDE is licensed under the LGPL with the same exception, so that shared data structures in this part will not force you to license your plug-in or design-time package under the GPL. You are free to choose a plug-in of any license; we don't want to limit your choice. Therefore non-GPL compatible plug-ins are allowed. Note that it's not allowed to distribute a precompiled Lazarus with these non-GPL-compatible plugins included statically; however, we do not see this as a severe limitation, since recompiling Lazarus is easy.<br />
<br />
== Contributors and Comments ==<br />
<br />
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq version].</div>Orankehttps://wiki.freepascal.org/index.php?title=User_talk:Oranke&diff=32366User talk:Oranke2008-11-27T14:39:27Z<p>Oranke: /* 번역중... */</p>
<hr />
<div>라자루스 위키 번역작업중.<br />
<br />
=== 번역중... ===<br />
<br />
* [[Lazarus_Documentation/ko]]<br />
* [[Nomenclature/ko]]<br />
* [[DesignGuidelines/ko]]<br />
* [[Overview_of_Free_Pascal_and_Lazarus/ko]] - 한 줄이 번역 안됨.<br />
* [[FPC_documentation/ko]]<br />
<br />
=== 번역완료... ===<br />
<br />
* [[Main_Page/ko]] - Arilang님, Azrael님 고생하셨습니다.</div>Orankehttps://wiki.freepascal.org/index.php?title=User_talk:Oranke&diff=32365User talk:Oranke2008-11-27T14:38:58Z<p>Oranke: /* 번역중... */</p>
<hr />
<div>라자루스 위키 번역작업중.<br />
<br />
=== 번역중... ===<br />
<br />
* [[Lazarus_Documentation/ko]]<br />
* [[Nomenclature/ko]]<br />
* [[DesignGuidelines/ko]]<br />
* [[Overview_of_Free_Pascal_and_Lazarus/ko]]<br />
* [[FPC_documentation/ko]]<br />
<br />
=== 번역완료... ===<br />
<br />
* [[Main_Page/ko]] - Arilang님, Azrael님 고생하셨습니다.</div>Orankehttps://wiki.freepascal.org/index.php?title=FPC_documentation/ko&diff=32364FPC documentation/ko2008-11-27T14:37:56Z<p>Oranke: /* Misc info */</p>
<hr />
<div>{{FPC documentation}}<br />
<br />
<br />
이 페이지는 FPC와 관련되어, 공식 문서와 차이가 나거나 아직 포함되지 않은 내용들을 모아두고 있습니다.<br />
<br />
== 메인 컴포넌트 ==<br />
<br />
[[FPC|프리파스칼 컴파일러 (FPC)]] <br />
<br />
[[RTL|런타임 라이브러리 (RTL)]]<br />
<br />
[[FCL|프리 컴포넌트 라이브러리 (FCL)]]<br />
<br />
[[Packages Base]], [[Packages Extra]] 는 이제 [[Package List]]로 합쳐 관리합니다. <br />
<br />
[[Free Vision]]<br />
<br />
[[Textmode IDE]]<br />
<br />
[[Utilities]] ([[Fpcmake]], [[H2Pas]], [[PPUDump]], [[PPUMove]], [[PTop]])<br />
<br />
[[Contributed Units]]<br />
<br />
[[FPMake]]<br />
<br />
== 기타 정보 ==<br />
<br />
[[Platform list]]<br />
<br />
[[Pascal Bindings]]<br />
<br />
[[Road map]]<br />
<br />
[[Building the VCL with FPC]]<br />
<br />
[[Building the CLX with FPC]]<br />
<br />
[[Making the FPC libraries shared]]<br />
<br />
[[General Pascal and software Development remarks]]<br />
<br />
[[To Do lists]] (including answers to "How can I help?")<br />
<br />
[[Releasing|Releasing related resources]]<br />
<br />
[[Compiler development articles]]</div>Orankehttps://wiki.freepascal.org/index.php?title=FPC_documentation/ko&diff=32363FPC documentation/ko2008-11-27T14:37:28Z<p>Oranke: /* 메인 컴포넌트 */</p>
<hr />
<div>{{FPC documentation}}<br />
<br />
<br />
이 페이지는 FPC와 관련되어, 공식 문서와 차이가 나거나 아직 포함되지 않은 내용들을 모아두고 있습니다.<br />
<br />
== 메인 컴포넌트 ==<br />
<br />
[[FPC|프리파스칼 컴파일러 (FPC)]] <br />
<br />
[[RTL|런타임 라이브러리 (RTL)]]<br />
<br />
[[FCL|프리 컴포넌트 라이브러리 (FCL)]]<br />
<br />
[[Packages Base]], [[Packages Extra]] 는 이제 [[Package List]]로 합쳐 관리합니다. <br />
<br />
[[Free Vision]]<br />
<br />
[[Textmode IDE]]<br />
<br />
[[Utilities]] ([[Fpcmake]], [[H2Pas]], [[PPUDump]], [[PPUMove]], [[PTop]])<br />
<br />
[[Contributed Units]]<br />
<br />
[[FPMake]]<br />
<br />
== Misc info ==<br />
<br />
[[Platform list]]<br />
<br />
[[Pascal Bindings]]<br />
<br />
[[Road map]]<br />
<br />
[[Building the VCL with FPC]]<br />
<br />
[[Building the CLX with FPC]]<br />
<br />
[[Making the FPC libraries shared]]<br />
<br />
[[General Pascal and software Development remarks]]<br />
<br />
[[To Do lists]] (including answers to "How can I help?")<br />
<br />
[[Releasing|Releasing related resources]]<br />
<br />
[[Compiler development articles]]</div>Orankehttps://wiki.freepascal.org/index.php?title=FPC_documentation/ko&diff=32362FPC documentation/ko2008-11-27T14:36:07Z<p>Oranke: /* 메인 컴포넌트 */</p>
<hr />
<div>{{FPC documentation}}<br />
<br />
<br />
이 페이지는 FPC와 관련되어, 공식 문서와 차이가 나거나 아직 포함되지 않은 내용들을 모아두고 있습니다.<br />
<br />
== 메인 컴포넌트 ==<br />
<br />
[[FPC|프리파스칼 컴파일러 (FPC)]] <br />
<br />
[[RTL|런타임 라이브러리 (RTL)]]<br />
<br />
[[FCL|프리 컴포넌트 라이브러리 (FCL)]]<br />
<br />
[[Packages Base]], [[Packages Extra]] are now combined as [[Package List]]<br />
<br />
[[Free Vision]]<br />
<br />
[[Textmode IDE]]<br />
<br />
[[Utilities]] ([[Fpcmake]], [[H2Pas]], [[PPUDump]], [[PPUMove]], [[PTop]])<br />
<br />
[[Contributed Units]]<br />
<br />
[[FPMake]]<br />
<br />
== Misc info ==<br />
<br />
[[Platform list]]<br />
<br />
[[Pascal Bindings]]<br />
<br />
[[Road map]]<br />
<br />
[[Building the VCL with FPC]]<br />
<br />
[[Building the CLX with FPC]]<br />
<br />
[[Making the FPC libraries shared]]<br />
<br />
[[General Pascal and software Development remarks]]<br />
<br />
[[To Do lists]] (including answers to "How can I help?")<br />
<br />
[[Releasing|Releasing related resources]]<br />
<br />
[[Compiler development articles]]</div>Orankehttps://wiki.freepascal.org/index.php?title=FPC_documentation/ko&diff=32361FPC documentation/ko2008-11-27T14:35:38Z<p>Oranke: </p>
<hr />
<div>{{FPC documentation}}<br />
<br />
<br />
이 페이지는 FPC와 관련되어, 공식 문서와 차이가 나거나 아직 포함되지 않은 내용들을 모아두고 있습니다.<br />
<br />
== 메인 컴포넌트 ==<br />
<br />
[[FPC|프리파스칼 컴파일러 (FPC)]] <br />
<br />
[[RTL|런타임 라이브러리 (RTL)]]<br />
<br />
[[FCL|프리파스칼 라이브러리 (FCL)]]<br />
<br />
[[Packages Base]], [[Packages Extra]] are now combined as [[Package List]]<br />
<br />
[[Free Vision]]<br />
<br />
[[Textmode IDE]]<br />
<br />
[[Utilities]] ([[Fpcmake]], [[H2Pas]], [[PPUDump]], [[PPUMove]], [[PTop]])<br />
<br />
[[Contributed Units]]<br />
<br />
[[FPMake]]<br />
<br />
== Misc info ==<br />
<br />
[[Platform list]]<br />
<br />
[[Pascal Bindings]]<br />
<br />
[[Road map]]<br />
<br />
[[Building the VCL with FPC]]<br />
<br />
[[Building the CLX with FPC]]<br />
<br />
[[Making the FPC libraries shared]]<br />
<br />
[[General Pascal and software Development remarks]]<br />
<br />
[[To Do lists]] (including answers to "How can I help?")<br />
<br />
[[Releasing|Releasing related resources]]<br />
<br />
[[Compiler development articles]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Main_Page/ko&diff=32360Main Page/ko2008-11-27T14:34:55Z<p>Oranke: /* 프리 파스칼 문서 */</p>
<hr />
<div>__NOTOC__<br />
{{Main Page}}<br />
<br />
=라자루스와 프리파스칼 위키에 오신 것을 환영합니다=<br />
<br />
<br />
==개요==<br />
<br />
이 위키는, FPC, Lazarus, 그리고 [[Related projects|관련된 프로젝트]]의 정보를 모으는 것을 목적으로 하고 있습니다.<br />
<br />
FPC는 이미 몇가지 포멧으로 잘 문서화 되어 있습니다만, [[FPC development|FPC의 개발이나 조직에 관한 정보]] 그리고 [[FPC_documentation|아직 정리되지 않은 문서]]들은 이 위키에 모아두고 있습니다.<br />
<br />
또한 라자루스는 필연적으로 유저들에게 배포된 문서와는 약간의 차이가 있을 수 밖에 없으므로, 누구나 참여해 편집할 수 있는 이 "open document", 또는 "wiki"가 만들어지게 되었습니다. <br />
<br />
이 위키는 브라우저를 통해 쉽게 내용을 변경하거나 추가할 수 있습니다. 사용법을 익히시려면 [http://www.chat11.com/30_Second_Quick_Wiki_Tutorial 30분 속성 위키 설명서] 또는 [http://en.wikipedia.org/wiki/Wikipedia:Tutorial 위키페디아 설명서]를 참고하세요. 연습을 위해 [[Sand Box|모래상자]]가 제공됩니다. 위키 사용에 문제가 있다면 [http://sourceforge.net/users/vlx/ 관리자]에게 알려주시거나 [http://sourceforge.net/projects/lazarus-ccr Lazarus-CCR] 에 버그를 올려주세요. 그 외에 남기고 싶은 제안은 [[Site Feedback|사이트 피드백]] 페이지를 이용하세요.<br />
<br />
라자루스의 <b>개발 이력</b>은 [[History|이 곳]]을 참고하세요.<br />
<br />
==프리 파스칼 문서==<br />
;[[FPC documentation/ko|FPC 개발자 문서]]<br />
:개발자 및 기타 메시지 등을 다른 언어로 번역 해 주실 프리파스칼 컴파일러에 대한 공헌자들을 위한 문서 입니다.<br />
<br />
==라자루스 문서==<br />
;[[Lazarus Documentation/ko|라자루스 문서]]<br />
:모든 라자루스 IDE (프리파스칼 컴파일러 메뉴얼 포함) 에 대한 문서와 [[Lazarus_Documentation/ko#Lazarus_and_Pascal_Tutorials|튜토리얼]]은 [[Lazarus Documentation/ko|라자루스 문서]] 페이지에 있습니다. 많은 페이지가 "작업중"인 상태로 당신의 참여를 간절히 바라고 있습니다. 물론 새로운 페이지를 만들어 멋진 내용을 추가 해 주셔도 좋습니다.<br />
<br />
==다운로드==<br />
사용 가능한 컴포넌트와 패키지들은 [http://sourceforge.net/project/showfiles.php?group_id=92177 Lazarus-CCR 소스포지 파일 영역]에서 찾으실 수 있습니다. 프리파스칼 컴파일러와 라자루스의 현재 테스트버전은 [http://sourceforge.net/project/showfiles.php?group_id=89339 라자루스 소스포지 사이트]에서 찾으실 수 있습니다. 이 패키지에 대한 추가적인 문서는 [[Components and Code examples|컴포넌트와 코드 예제]] 페이지에 있습니다. 컴파일러와 많은 사람들에 의해 보내진 수 많은 코드들은 [http://www.freepascal.org/download.var 프리 파스클 컴파일러 다운로드 미러]와 [http://lazarus.freepascal.org 라자루스 IDE 웹사이트]에서 찾으실 수 있습니다. 라자루스 스냅샷은 [[Lazarus Snapshots Downloads | 이 곳]]에서 다운받으실 수 있습니다.<br />
<br />
==메일링 리스트==<br />
초보, 숙련자 누구나 Lazarus-ccr [http://lists.sourceforge.net/lists/listinfo/lazarus-ccr-announce 공지], 그리고 [http://lists.sourceforge.net/lists/listinfo/lazarus-ccr-general 일반] 메일링 리스트에 가입하세요.<br />
<br />
또한, [http://www.lazarus.freepascal.org/modules.php?op=modload&name=StaticPage&file=index&sURL=maill 라자루스] IDE 메일링 리스트와 [http://www.freepascal.org/maillist.html 프리파스칼] 개발자 또는 공지사항 메일링 리스트도 많은 도움이 될 것 입니다.<br />
<br />
==누가 무슨 작업을 하고 있나?==<br />
만약 당신이 현재 어떤 컴포넌트, 또는 라이브러리를 컨버팅 중이거나 그럴 필요를 느낀다면, 그 내용을 [[Current conversion projects|현재 변환중인 프로젝트]] 페이지에 올려주세요. 그렇게 함으로써 동일한 프로젝트를 두 사람 이상이 중복해 작업하는 일을 막을 수 있을 것입니다.<br />
<br />
==레퍼런스, 링크 그리고 리소스==<br />
<br />
===라자루스 IDE===<br />
라자루스 IDE에 대한 새 소식이나 정보는 [http://lazarus.freepascal.org 라자루스 IDE 웹사이트]에서 찾을 수 있습니다. 아이디어, 수정사항, 그리고 이후 개발계획은 [[Lazarus Development Process|라자루스 개발 프로세스]] 페이지를 참고하세요. 라자루스 IDE와 프리파스칼 컴파일러에 대한 다운로드도 그 곳에서 할 수 있습니다. 또한 [http://sourceforge.net/project/showfiles.php?group_id=89339 라자루스 파일 영역]에서 다운로드 가능한 컴파일러와 IDE의 최종 패키지를 얻을 수 있습니다..<br />
<br />
====라자루스 프로젝트의 활성화====<br />
<br />
[[Projects using Lazarus|라자루스 적용 프로젝트]] 페이지는 라자루스와 연관된 많은 자료에 대한 웹사이트와 다운로드 링크를 제공합니다. <br />
<br />
[[Lazarus Application Gallery|라자루스 어플리케이션 갤러리]]에서는 라자루스로 만들어진 어플리케이션의 스크린샷을 구경할 수 있습니다.<br />
<br />
====유용한 링크====<br />
[[Page Of Code Sites|코드 사이트 모음]] 페이지에서 델파이/카일릭스와 관련된 사이트들의 정보를 얻을 수 있습니다. 혹시라도 이 페이지에 없는 멋진 사이트를 알고 계시다면, 언제든지 추가 해 주세요.<br />
<br />
====특화된 검색엔진====<br />
새로운 기술과 문제 해결을 위해 온라인을 기반으로한 유용한 검색과 지식엔진이 있습니다. <br />
Tamarack 연합은 볼랜드 유즈넷의 문서들의 검색을 위해 특별히 빠른 [http://www.tamaracka.com/search.htm 검색엔진]을 운영합니다.<br />
Mer Systems Inc.는 유사한 [http://www.mers.com/searchsite.html 검색엔진]을 제공하고 있습니다.<br />
사이트 검색 능력을 진행하는 또 다른 정보소스는 Earl F. Glynnd의 컴퓨터랩과 레퍼런스 [http://www.efg2.com/ 라이브러리]입니다.<br />
<br />
====마케팅 사례 연구====<br />
[[Marketing_Case_Studies|라자루스 사용자들을 위한 기회]]로 라자루스가 왜 선택받은 IDE인지를 설명합니다.<br />
<br />
<br />
<br />
====FPC/라자루스 컨테스트와 전시회 출품====<br />
FPC/Lazarus는 독일 뮌헨의 [[Systems 2005]], [[Systems 2006]]과 [[Systems 2007]]에 부스를 만들어 출품 되었습니다. 이러한 전시회의 경험을 바탕으로한 [[Preparing a booth on a trade show|정보]]수집은 앞으로 전시회의 부스 준비를 돕기위해 만들어졌습니다.<br />
라자루스와 관련 프로젝트들은 그밖의 여러 컨테스트에 참여하고 있고 [[Contests|위키 페이지]]는 앞으로의 컨테스트 자료를위해 준비되고 있습니다.<br />
<br />
=Translations=<br />
<br />
* [[Main Page/ar | عربي (Arabic)]]<br />
* [[Main Page/es | Español (Spanish)]]<br />
* [[Main Page/de | Deutsch (German)]]<br />
* [[Main Page/fr | Français (French)]]<br />
* [[Main Page/id | Bahasa Indonesia (Indonesian)]]<br />
* [[Main Page/it | Italiano (Italian)]]<br />
* [[Main Page/ja | Japanese (Japanese)]]<br />
* [[Main Page/ko | Korean (한국어)]]<br />
* [[Main Page/nl | Nederlands (Dutch)]]<br />
* [[Main Page/pl | Polski (Polish)]]<br />
* [[Main Page/pt | Português (Portuguese)]]<br />
* [[Main Page/ru | Русский (Russian)]]<br />
* [[Main Page/sk | Slovensky (Slovak)]]<br />
* [[Main Page/fi | Suomi (Finnish)]]<br />
* [[Main Page/uk | Українська (Ukrainian)]]<br />
* [[Main Page/zh_CN | Chinese 中文(简体)]]<br />
* [[Main Page/zh_TW | Chinese 中文(正體)]]<br />
* [[Main Page/vn | Vietnamese (Việt Nam)]]<br />
<br />
=예전의 위키=<br />
이 페이지들은 예전의 위키포맷에서 변환되어져 왔습니다. 전의 위키페이지는 [http://lazarus-ccr.sourceforge.net/index.php?wiki=FrontPage 여기]에서 찾을 수 있습니다.<br />
<br />
원본 제공 [[User:VlxAdmin]].</div>Orankehttps://wiki.freepascal.org/index.php?title=FPC_documentation/ko&diff=32359FPC documentation/ko2008-11-27T14:33:59Z<p>Oranke: New page: {{FPC documentation}} 이 페이지는 FPC와 관련되어, 공식 문서와 차이가 나거나 아직 포함되지 않은 내용에 대한 정보를 모아두고 있습니다. == 메...</p>
<hr />
<div>{{FPC documentation}}<br />
<br />
<br />
이 페이지는 FPC와 관련되어, 공식 문서와 차이가 나거나 아직 포함되지 않은 내용에 대한 정보를 모아두고 있습니다. <br />
<br />
== 메인 컴포넌트 ==<br />
<br />
[[FPC|프리파스칼 컴파일러 (FPC)]] <br />
<br />
[[RTL|런타임 라이브러리 (RTL)]]<br />
<br />
[[FCL|프리파스칼 라이브러리 (FCL)]]<br />
<br />
[[Packages Base]], [[Packages Extra]] are now combined as [[Package List]]<br />
<br />
[[Free Vision]]<br />
<br />
[[Textmode IDE]]<br />
<br />
[[Utilities]] ([[Fpcmake]], [[H2Pas]], [[PPUDump]], [[PPUMove]], [[PTop]])<br />
<br />
[[Contributed Units]]<br />
<br />
[[FPMake]]<br />
<br />
== Misc info ==<br />
<br />
[[Platform list]]<br />
<br />
[[Pascal Bindings]]<br />
<br />
[[Road map]]<br />
<br />
[[Building the VCL with FPC]]<br />
<br />
[[Building the CLX with FPC]]<br />
<br />
[[Making the FPC libraries shared]]<br />
<br />
[[General Pascal and software Development remarks]]<br />
<br />
[[To Do lists]] (including answers to "How can I help?")<br />
<br />
[[Releasing|Releasing related resources]]<br />
<br />
[[Compiler development articles]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Template:FPC_documentation&diff=32358Template:FPC documentation2008-11-27T14:32:02Z<p>Oranke: </p>
<hr />
<div><small><br />
[[FPC documentation/de| '''Deutsch (de)''']] |<br />
[[FPC documentation|'''English (en)''']] |<br />
[[FPC documentation/fr|'''Français (fr)''']] |<br />
[[FPC documentation/id|'''Bahasa Indonesia (id)''']] |<br />
[[FPC documentation/ja|'''Japanese (ja)''']] |<br />
[[FPC documentation/ko|'''한국어 (ko)''']] |<br />
[[FPC documentation/zh_CN|'''中文(简体)(zh_CN)''']] |<br />
[[FPC documentation/zh_TW|'''正體中文 (zh_TW)''']] <br />
</small></div>Orankehttps://wiki.freepascal.org/index.php?title=Hardware_Access/ko&diff=32347Hardware Access/ko2008-11-27T08:13:38Z<p>Oranke: /* 외부 링크 */</p>
<hr />
<div>{{Hardware Access}}<br />
__TOC__<br />
==개관==<br />
이 페이지는 라자루스상에서 하드웨어 장치(디바이스)에 접근하기위한 튜토리얼의 시작입니다. 이 장치들은 ISA, PCI, USB, parallel port, serial port 등을 포함하지만 이것들에 제한된것은 아닙니다.<br />
완전한 멀티 플랫폼상에서 하드웨어에 접근하는 것은 프리파스칼 라이브러리나 LCL에의해 구현되지는 않았으므로 이 튜토리얼은 다른 플랫폼상에서의 기초적인 하드웨어 접근 방법을 다룰 것 입니다. 조건적인 컴파일에 의해 다른 플랫폼에서 컴파일된 코드는 다음과 같을 것이다:<br />
<delphi><br />
uses<br />
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,<br />
{$IFDEF WIN32}<br />
Windows;<br />
{$ENDIF}<br />
{$IFDEF Unix}<br />
ports;<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 시점에서 Mac OX/x86이 HW 접근을 허용하는지는 아직 확실치는 않다. 이 경우에서는 내가 가정하듯이 위의 방법이 허용되지 않을 수 있지만 곧 io.dll같은 드라이버가 나타날 것이다.<br />
<br />
==패러랠과 시리얼 의 비교==<br />
ISA카드, PCI 카드 및 패러랠 포트는 '''parallel''' 프로토콜에 의해 컴퓨터와 통신을 한다. 시리얼 포트와 USB장치는 '''serial''' 프로토콜로 통신한다. 프로세서와 프로그래밍 언어는 모두 데이터에 패러랠한 접근을 통해 작업을 수행하기 때문에 이런 종류의 프로토콜에 대한 접근은 소프트웨어 측면에서 보면 구현하기가 더 쉽다.예를 들어, Integer 변수에 접근할 때, 단일 명령으로 그 값에 접근할 수가 있다. 그러나 시리얼 포트 프로토콜에서는 동시에 한개의 비트만을 알 수 밖에 없으며 데이터를 이해하기 위해서는 그 비트 조각들을 붙여 놓을 필요가 있다.<br />
<br />
시리얼 툥신은 직접적으로 구현하기가 어렵지만, 미리 만들어 놓은(pre-made) 컴포넌트를 사용한다면 매우 쉽게 구현할 수가 있다.이는 하드웨어 측면에서도 역시 어려운건 마찬가지이기 때문에 많은 장치들은 그것을 구현하기 위해 특별한 통합 써킷이나 마이크로 컨트롤러를 사용한다.<br />
<br />
이제 다음에 하드웨어 접근 프로토콜에 대한 간략한 비교가 있다:<br />
<br />
{| border=2 width="100%"<br />
<br />
|-<br />
!<br />
! 속도<br />
! 하드웨어 구현의 난이도<br />
<br />
|-<br />
! 시리얼 포트<br />
| align="center" | 매우 느림 (< E5 bit/s)<br />
| align="center" | 중간<br />
<br />
|-<br />
! 패러랠 포트<br />
| align="center" | 느림 (~ E6 bit/s)<br />
| align="center" | 쉬움<br />
<br />
|-<br />
<br />
! ISA 카드<br />
| align="center" | 중간(~ E7 bit/s)<br />
| align="center" | 중간<br />
<br />
|-<br />
! USB<br />
| align="center" | 중간(~ E7 bit/s)<br />
| align="center" | 어려움<br />
<br />
|-<br />
! PCI 카드<br />
| align="center" | 매우 빠름 (> E9 bit/s)<br />
| align="center" | 매우 어려움<br />
<br />
|}<br />
<br />
==패러랠 통신==<br />
<br />
===윈도우에서 inpout32.dll의 이용===<br />
윈도우즈는 9x시리즈와 NT시리즈에서 하드웨어 접근에 있어서 다른 방법을 취하고 있다. 9x 시리즈(95, 98, Me)에서 프로그램은 DOS상에서 했듯이 하드웨어에 직접 접근 할 수가 있었다. 그러나 NT 시리즈(Windows NT and XP)에서는 이런 접근방법을 허용하고 있지 않다. 이 구조에서 하드웨어 포트와의 모든 통신은 디바이스 드라이버를 통해 이루어진다. 이것은 보안 메커니즘이지만, 작은 프로젝트에서도 드라이버 개발에 시간과 비용 등 많은 댓가를 추가하게 된다.<br />
<br />
행복하게도 이 문제를 해결할 수 있는 라이브러리가 있다. 만약 Windows NT가 탐지 된다면, HWInterface.sys 커널 디바이스 드라이버의 압축을 해제하고 설치를 한다. 만약 Windows 9x가 탐지된다면 하드웨어 접근은 단순히 어셈블러 opcode를 이용한다.<br />
<br />
그렇지만 이 라이브러리를 어떻게 사용할까요? 간단합니다! 이것은 Inp32 와 Out32 등의 단지 두개의 함수만이 있으므로 사용법은 매우 직관적이다<br />
<br />
라이브러리를 동적으로 로드하므로, 먼저 두개의 함수를 정의해 보자:<br />
<br />
<delphi><br />
type<br />
TInp32 = function(Address: SmallInt): SmallInt; stdcall;<br />
TOut32 = procedure(Address: SmallInt; Data: SmallInt); stdcall;<br />
</delphi><br />
<br />
* Address는 접근하려는 포트의 어드레스를 표시한다<br />
* Out32는 지정한 Address의 포트로 Data를 전송한다<br />
* Inp32는 지정한 포트로부터 한개의 byte를 되돌려 준다<br />
<br />
이제 라이브러리를 로드한다. 이것은 작성한 프로그램의 메인폼의 OnCreate 메소드같은 곳에서 구현할 수가 있다:<br />
<br />
<delphi><br />
type<br />
TMyForm = class(TForm)<br />
.........<br />
private<br />
{ private declarations }<br />
Inpout32: THandle;<br />
Inp32: TInp32;<br />
Out32: TOut32;<br />
.........<br />
implementation<br />
.........<br />
procedure TMyForm.FormCreate(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
Inpout32 := LoadLibrary('inpout32.dll');<br />
if (Inpout32 <> 0) then<br />
begin<br />
// needs overtyping, plain Delphi's @Inp32 = GetProc... leads to compile errors<br />
Inp32 := TInp32(GetProcAddress(Inpout32, 'Inp32'));<br />
if (@Inp32 = nil) then Caption := 'Error';<br />
Out32 := TOut32(GetProcAddress(Inpout32, 'Out32'));<br />
if (@Out32 = nil) then Caption := 'Error';<br />
end<br />
else Caption := 'Error';<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
OnCreate 에서 라이브러리를 로드했으면 OnDestroy에서 언로드하는 것을 잊으면 안된다:<br />
<br />
<delphi><br />
procedure TMyForm.FormDestroy(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
FreeLibrary(Inpout32);<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
다음에 Inp32 함수를 이용하는 방법에 관한 단순한 예제가 있다:<br />
<br />
<delphi><br />
{$IFDEF WIN32}<br />
myLabel.Caption := IntToStr(Inp32($0220));<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 코드는 Windows XP상의 포트 $0220에 있는 커스텀 ISA카드에서 Lazarus 0.9.10으로 터스트하였다. 물론 이코드를 실행하기 위해서는 uses 절에 Windows를 넣어야 한다. 개발을 위해 할 일은 작성하는 응용프로그램과 같은 디렉토리에 있는"inpout32.dll"를 인클루드(include)하기만 하면 된다.<br />
<br />
이 라이브러리에 관한 홈페이지는 다음과 같다: [http://www.logix4u.net/inpout32.htm www.logix4u.net/inpout32.htm] *토론을 보세요*<br />
<br />
===Windows 9x에서 어셈블러 사용===<br />
<br />
Windows 9x에서 역시 어셈블러 코드를 사용할 수 있다. $CC를 $320 포트에 쓰고싶다고 가정해보자. 다음 코드가 그렇게 해줄 것이다:<br />
<br />
<delphi><br />
{$ASMMODE ATT}<br />
...<br />
asm<br />
movl $0x320, %edx<br />
movb $0xCC, %al<br />
outb %al, %dx<br />
end ['EAX','EDX'];<br />
</delphi><br />
<br />
===Windows상에서 문제 해결===<br />
<br />
Windows상에서 플럭앤플레이를 지원하지 않는 패러랠 하드웨어를 사용할 때 문제를 일으키는 가능한 한가지는 당신의 하드웨어에 의해 사용되고 있는 포트를 다른 하드웨어에 할당할 때 일어난다. Windows가 당신의 디바이스 주소에 플럭앤플레이 디바이스를 할당하지 못하도록 하는 방법을 아래 URL에서 그에 대해 설명된 것을 찾을 수 있을 것이다:<br />
<br />
http://support.microsoft.com/kb/135168<br />
<br />
===리눅스상에서 포트 접근을 위해서는 ioperm을 사용===<br />
<br />
리눅스에서 하드웨어에 접근하는 가장 좋은 방법은 디바이스 드라이버를 통해 하는 것이지만 드라이버를 만드는 작업이 너무 복잡함으로 인해 가끔은 빠른 방법이 매우 유용하다. <br />
<br />
리눅스에서 "[[doc:rtl/ports|ports]]" unit를 이용하기 위해서는 프로그램은 root로 실행해야만 하며 포트접근을 위한 적절한 퍼미션 설정을 위해 IOPerm을 콜해야 한다. "[[doc:rtl/ports|ports]]" 유닛에 관한 문서는 다음에서 찾을 수 있다.<br />
[http://www.freepascal.org/docs-html/rtl/ports/index.html 이곳].<br />
<br />
첫번째 할 일은 (g)libc를 링크하고 IOPerm을 콜하는 것이다. 유닛과 연결된 완전한 (g)libc가 프리파스칼에 존재하지만 이 유닛은 어플리케이션이 직접 사용할 때 문제를 야기하고, 또한 이것을 완전한 (g)libc 라이브러리에 정적으로 연결하는 것은 호환되지 않은 방법으로 버전이 변화하기 때문에 좋은 생각은 아니다. 그러나 ioperm같은 함수는 변하지 않을 것 같다.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external 'libc';<br />
{$ENDIF}<br />
</delphi><br />
<br />
* "from" 은 접근할 수 있는 첫번째 포트를 표시한다.<br />
* "num" 은 첫번째 접근한 다음의 포트 수이므로 ioperm(&220, 8, 1)은 프로그램에게 $220과 $227를 포함한 그 사이의 모든 포트를 접근하게 할 것이다.<br />
<br />
IOPerm에 링크 한 후 포트에 접근하기 위해 port[<Address>]를 사용할 수 있다.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
i := ioperm($220, 8, 1);<br />
port[$220] := $00;<br />
myLabel.Caption := 'ioperm: ' + IntToStr(i);<br />
i := Integer(port[$220]);<br />
myOtherLabel.Caption := 'response: ' + IntToStr(i);<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 코드는 커스텀 ISA 카드의 포트 $0220에서 테스트 하였으며, Mandriva Linux 2005 와 Damn Small Linux 1.5상에서 Lazarus 0.9.10을 사용하였다.<br />
<br />
===일반적인 유닉스 하드웨어 접근===<br />
<br />
<delphi><br />
{$IFDEF Unix}<br />
Uses Clib; // libc 라이브러리 이름을 가져옴.<br />
{$ENDIF}<br />
<br />
{$IFDEF Unix}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external clib;<br />
{$ENDIF}<br />
</delphi><br />
<br />
<br />
'''Note 1''' :FPC는 "fpioperm"이라 불리는 ioperm에 대한 추상화를 [[doc:rtl/x86/index.html|unit x86]]에서 제공하며 또한 out과 inport 함수를 제공한다. 이 함수들은 현재 Linux/x86 과 FreeBSD/x86에서도 구현되어 있다.<br />
<br />
배포와 이동성 기능 때문에 반드시 필요한 것이 아니라면 libc에 링크하는 것은 추천하지 않는다. 또한 위에서 한 것처럼 수동으로 libc에 링크(다른 곳에 필요한 함수 때문에 특별히 libc 임포트를 선언하여)하는 것도 추천되지 않는다.(예, 위의 libc 임포트(import) 라인은 표준(standard) C lib가 BeOS상의 libroot나 비표준 C심볼을 가진 플랫폼같이 libc에 의해 콜되지 않으면 실패하게 된다. <br />
<br />
'''Note 2''' _unit_ libc를 사용하는 것 역시 Kylix 호환을 제외한 어떤 환경하에서도 추천되지 않는다. 이것은 유닛은 상대적으로 이동성이 떨어지며(구조체와 다른 private 심볼의 과도한 노출(excessive exposure)) Kylix와 호환이 되지 않는 것에서는 가능한 적은 수정만이 필요하기 때문이다.<br />
<br />
==시리얼 통신==<br />
<br />
시리얼 통신 소프트웨어를 빌드하는 것은 [http://synapse.ararat.cz/doku.php Synaser library]를 이용하면 매우 쉽다. [http://synapse.ararat.cz/doc/help/synaser.html Synaser 문서]와 함께 사용한 예는 이해하기가 쉬워야 한다. 가장 중요한 부분은 속도(초당 bits)와 데이터 비트, 패리티 비트, 스톱 비트 및 핸드쉐이크 프로토콜 등을 조정하는 TBlockSerial.Config이다. 다음의 코드는 COM 1에 연결된 시리얼 마우스에서 테스트 하였다.<br />
<br />
<delphi><br />
program comm;<br />
<br />
{$apptype console}<br />
<br />
uses<br />
Classes, SysUtils, Synaser;<br />
<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('COM1');<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
while True do<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
finally<br />
ser.free;<br />
end;<br />
end.<br />
</delphi><br />
<br />
다음의 코드-에제는 상기에 있는 예제의 또 다른 버전이다. 위에 보인 예는, 정확히 말하자면 메인 컨셉에서 결정적으로 잘못된 것이 있어 보인다. 이 부분은 "while true do..."이다. 테스트에서 시스템(Asus A6T 랩탑으로 Digitus USB가 RS232 어댑터에 연결되어 있으며 Ubuntu 8.04.1를 사용한다)에서 이 부분은 다음과 같은 에러를 일으켰다: 어플리케이션은 세션당 단 한번 만 성공적으로 실행이 되었고, 어플리케이션을 다시 시작하면, 어프리케이션은 시리얼 포트에 연결할 수가 없었다. 그러므로 사용자가 어플리케이션을 다시 시작할 때마다 리부트가 필요했으므로, 이는 정말 불쾌한 버그인 것이다.<br />
<br />
이유를 이해하는 것은 어렵지 않다: 어플리케이션은 while true do 루프에 있게 되면, 그것은 정확히 말하면 무한 루프이다. 중단할 방법이 없기 때문에 어플리케이션을 중단시킬 유일한 방법은 터미널을 닫거나 CTRL-C를 누르는 것 뿐이다. 그러나 어플리케이션을 이런 방법으로 종료한다면, 시리얼 포트를 해제하는 "ser.free"의 중요한 부분이 콜되지 않는다. 이 문제는 다음의 독일의 라자루스 포럼[http://www.lazarusforum.de/viewtopic.php?f=10&t=2082 http://www.lazarusforum.de/viewtopic.php?f=10&t=2082]에 설명되어 있다.<br />
<br />
각 사용자가 CTRL-C를 누르지 않고 클리어하기 위한 메인 어플리케이션에서의 코드는 약간 만 필요하다. /dev/ttyUSB0를 com-포트를 위해 사용하는 것에 대해 걱정하는 사람은 테스트 시스템상의 USB-시리얼 어댑터(Digitus) 때문이다.만약 ㅅ스템에 내장된 시리얼 포트를 가지고 있다면 'Com0'를 사용하는 것이 좋다.- 위의 예와 같이 코드와 같이 선언해서.<br />
<br />
<delphi><br />
<br />
program serialtest;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$IFDEF UNIX}{$IFDEF UseCThreads}<br />
cthreads,<br />
{$ENDIF}{$ENDIF}<br />
Classes,SysUtils,Synaser,Crt<br />
{ you can add units after this };<br />
<br />
var l:boolean;<br />
<br />
function check_affirmation():boolean;<br />
var k:string;<br />
begin<br />
Writeln('To quit the application please do NOT use CTRL-C! Instead, please press any key to quit the application! '+<br />
'Please confirm this notification before the application continues! '+<br />
'[0]=Quit, [1]=Confirm, please continue! ');<br />
Writeln('Your decision: ');<br />
Read(k);<br />
if StrtoInt(k) = 1 then<br />
begin<br />
check_affirmation:=true;<br />
Writeln('OK, application continues ...');<br />
end<br />
else<br />
begin<br />
check_affirmation:=false;<br />
Writeln('Abort');<br />
end<br />
end;<br />
<br />
procedure RS232_connect;<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('/dev/ttyUSB0'); //ComPort<br />
Sleep(1000);<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
Write('Device: ' + ser.Device + ' Status: ' + ser.LastErrorDesc +' '+<br />
Inttostr(ser.LastError));<br />
Sleep(1000);<br />
repeat<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
until keypressed; //Important!!!<br />
finally<br />
Writeln('Serial Port will be freed...');<br />
ser.free;<br />
Writeln('Serial Port was freed successfully!');<br />
end;<br />
end;<br />
<br />
begin<br />
l:=check_affirmation();<br />
if l=true then<br />
RS232_connect()<br />
else<br />
Writeln('Program quit! ');<br />
end.<br />
<br />
</delphi><br />
<br />
또한,[[Hardware Access#External Links | 외부 링크]] 섹션에 유닉스와 윈도우즈 시리얼 포트 튜토리얼이 있다.<br />
<br />
==USB==<br />
<br />
===libusb===<br />
<br />
<br />
[http://libusb.sourceforge.net/ libusb] 는 Linux, BSDs 및 Mac OS X 등의 크로스 플랫폼을 지원합니다.<br />
<br />
헤더를 구할 수 있는 링크는 다음과 같습니다. http://www.freepascal.org/contrib/db.php3?category=Miscellaneous :<br />
<br />
{|cellpadding="4"<br />
|-<br />
! 이름 !! 제작자 !! 버전 !! 일자 !! 링크 !! 비고<br />
|-<br />
| libusb.pp || nowrap | Uwe Zimmermann || 0.1.12 || nowrap | 2006-06-29 || http://www.sciencetronics.com/download/fpc_libusb.tgz || <br />
|-<br />
| libusb.pas || Johann Glaser || || nowrap | 2005-01-14 || http://www.johann-glaser.at/projects/libusb.pas || <br />
|-<br />
| fpcusb || Joe Jared || 0.11-14 || nowrap | 2006-02-02 || http://relays.osirusoft.com/fpcusb.tgz || nowrap | 다운로드 링크 깨짐<br />
|}<br />
<br />
===FTDI===<br />
<br />
만약 [http://www.ftdichip.com/ FTDI]의 칩 중의 하나를 사용한다면, 칩을 위한 dll 인터페이스용 파스칼 헤더를 사용할 수 있다.<br />
<br />
==외부 링크==<br />
<br />
통신 프로토콜 속도 비교:<br />
<br />
# http://en.wikipedia.org/wiki/Serial_port#Speed<br />
# http://www.lvr.com/jansfaq.htm - Jan Axelson의 패러랠 포트 FAQ<br />
# http://en.wikipedia.org/wiki/USB#Transfer_Speed<br />
# http://en.wikipedia.org/wiki/PCI#Conventional_PCI_bus_specifications<br />
<br />
시리얼 통신 링크:<br />
<br />
# UNIX에서: [http://www.easysw.com/~mike/serial/serial.html]<br />
# Windows에서: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp<br />
# Synaser 콤포넌트: http://synapse.ararat.cz/<br />
# Comport 델파이 패키지e: http://sourceforge.net/projects/comport/<br />
<br />
ISA 디지탈 오실로 스코프- 하드웨어 접근에 대한 완전 소스가 포함된 예제:<br />
<br />
[http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/]<br />
<br />
----<br />
[[네트워킹]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Hardware_Access/ko&diff=32346Hardware Access/ko2008-11-27T08:12:59Z<p>Oranke: /* libusb */</p>
<hr />
<div>{{Hardware Access}}<br />
__TOC__<br />
==개관==<br />
이 페이지는 라자루스상에서 하드웨어 장치(디바이스)에 접근하기위한 튜토리얼의 시작입니다. 이 장치들은 ISA, PCI, USB, parallel port, serial port 등을 포함하지만 이것들에 제한된것은 아닙니다.<br />
완전한 멀티 플랫폼상에서 하드웨어에 접근하는 것은 프리파스칼 라이브러리나 LCL에의해 구현되지는 않았으므로 이 튜토리얼은 다른 플랫폼상에서의 기초적인 하드웨어 접근 방법을 다룰 것 입니다. 조건적인 컴파일에 의해 다른 플랫폼에서 컴파일된 코드는 다음과 같을 것이다:<br />
<delphi><br />
uses<br />
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,<br />
{$IFDEF WIN32}<br />
Windows;<br />
{$ENDIF}<br />
{$IFDEF Unix}<br />
ports;<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 시점에서 Mac OX/x86이 HW 접근을 허용하는지는 아직 확실치는 않다. 이 경우에서는 내가 가정하듯이 위의 방법이 허용되지 않을 수 있지만 곧 io.dll같은 드라이버가 나타날 것이다.<br />
<br />
==패러랠과 시리얼 의 비교==<br />
ISA카드, PCI 카드 및 패러랠 포트는 '''parallel''' 프로토콜에 의해 컴퓨터와 통신을 한다. 시리얼 포트와 USB장치는 '''serial''' 프로토콜로 통신한다. 프로세서와 프로그래밍 언어는 모두 데이터에 패러랠한 접근을 통해 작업을 수행하기 때문에 이런 종류의 프로토콜에 대한 접근은 소프트웨어 측면에서 보면 구현하기가 더 쉽다.예를 들어, Integer 변수에 접근할 때, 단일 명령으로 그 값에 접근할 수가 있다. 그러나 시리얼 포트 프로토콜에서는 동시에 한개의 비트만을 알 수 밖에 없으며 데이터를 이해하기 위해서는 그 비트 조각들을 붙여 놓을 필요가 있다.<br />
<br />
시리얼 툥신은 직접적으로 구현하기가 어렵지만, 미리 만들어 놓은(pre-made) 컴포넌트를 사용한다면 매우 쉽게 구현할 수가 있다.이는 하드웨어 측면에서도 역시 어려운건 마찬가지이기 때문에 많은 장치들은 그것을 구현하기 위해 특별한 통합 써킷이나 마이크로 컨트롤러를 사용한다.<br />
<br />
이제 다음에 하드웨어 접근 프로토콜에 대한 간략한 비교가 있다:<br />
<br />
{| border=2 width="100%"<br />
<br />
|-<br />
!<br />
! 속도<br />
! 하드웨어 구현의 난이도<br />
<br />
|-<br />
! 시리얼 포트<br />
| align="center" | 매우 느림 (< E5 bit/s)<br />
| align="center" | 중간<br />
<br />
|-<br />
! 패러랠 포트<br />
| align="center" | 느림 (~ E6 bit/s)<br />
| align="center" | 쉬움<br />
<br />
|-<br />
<br />
! ISA 카드<br />
| align="center" | 중간(~ E7 bit/s)<br />
| align="center" | 중간<br />
<br />
|-<br />
! USB<br />
| align="center" | 중간(~ E7 bit/s)<br />
| align="center" | 어려움<br />
<br />
|-<br />
! PCI 카드<br />
| align="center" | 매우 빠름 (> E9 bit/s)<br />
| align="center" | 매우 어려움<br />
<br />
|}<br />
<br />
==패러랠 통신==<br />
<br />
===윈도우에서 inpout32.dll의 이용===<br />
윈도우즈는 9x시리즈와 NT시리즈에서 하드웨어 접근에 있어서 다른 방법을 취하고 있다. 9x 시리즈(95, 98, Me)에서 프로그램은 DOS상에서 했듯이 하드웨어에 직접 접근 할 수가 있었다. 그러나 NT 시리즈(Windows NT and XP)에서는 이런 접근방법을 허용하고 있지 않다. 이 구조에서 하드웨어 포트와의 모든 통신은 디바이스 드라이버를 통해 이루어진다. 이것은 보안 메커니즘이지만, 작은 프로젝트에서도 드라이버 개발에 시간과 비용 등 많은 댓가를 추가하게 된다.<br />
<br />
행복하게도 이 문제를 해결할 수 있는 라이브러리가 있다. 만약 Windows NT가 탐지 된다면, HWInterface.sys 커널 디바이스 드라이버의 압축을 해제하고 설치를 한다. 만약 Windows 9x가 탐지된다면 하드웨어 접근은 단순히 어셈블러 opcode를 이용한다.<br />
<br />
그렇지만 이 라이브러리를 어떻게 사용할까요? 간단합니다! 이것은 Inp32 와 Out32 등의 단지 두개의 함수만이 있으므로 사용법은 매우 직관적이다<br />
<br />
라이브러리를 동적으로 로드하므로, 먼저 두개의 함수를 정의해 보자:<br />
<br />
<delphi><br />
type<br />
TInp32 = function(Address: SmallInt): SmallInt; stdcall;<br />
TOut32 = procedure(Address: SmallInt; Data: SmallInt); stdcall;<br />
</delphi><br />
<br />
* Address는 접근하려는 포트의 어드레스를 표시한다<br />
* Out32는 지정한 Address의 포트로 Data를 전송한다<br />
* Inp32는 지정한 포트로부터 한개의 byte를 되돌려 준다<br />
<br />
이제 라이브러리를 로드한다. 이것은 작성한 프로그램의 메인폼의 OnCreate 메소드같은 곳에서 구현할 수가 있다:<br />
<br />
<delphi><br />
type<br />
TMyForm = class(TForm)<br />
.........<br />
private<br />
{ private declarations }<br />
Inpout32: THandle;<br />
Inp32: TInp32;<br />
Out32: TOut32;<br />
.........<br />
implementation<br />
.........<br />
procedure TMyForm.FormCreate(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
Inpout32 := LoadLibrary('inpout32.dll');<br />
if (Inpout32 <> 0) then<br />
begin<br />
// needs overtyping, plain Delphi's @Inp32 = GetProc... leads to compile errors<br />
Inp32 := TInp32(GetProcAddress(Inpout32, 'Inp32'));<br />
if (@Inp32 = nil) then Caption := 'Error';<br />
Out32 := TOut32(GetProcAddress(Inpout32, 'Out32'));<br />
if (@Out32 = nil) then Caption := 'Error';<br />
end<br />
else Caption := 'Error';<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
OnCreate 에서 라이브러리를 로드했으면 OnDestroy에서 언로드하는 것을 잊으면 안된다:<br />
<br />
<delphi><br />
procedure TMyForm.FormDestroy(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
FreeLibrary(Inpout32);<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
다음에 Inp32 함수를 이용하는 방법에 관한 단순한 예제가 있다:<br />
<br />
<delphi><br />
{$IFDEF WIN32}<br />
myLabel.Caption := IntToStr(Inp32($0220));<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 코드는 Windows XP상의 포트 $0220에 있는 커스텀 ISA카드에서 Lazarus 0.9.10으로 터스트하였다. 물론 이코드를 실행하기 위해서는 uses 절에 Windows를 넣어야 한다. 개발을 위해 할 일은 작성하는 응용프로그램과 같은 디렉토리에 있는"inpout32.dll"를 인클루드(include)하기만 하면 된다.<br />
<br />
이 라이브러리에 관한 홈페이지는 다음과 같다: [http://www.logix4u.net/inpout32.htm www.logix4u.net/inpout32.htm] *토론을 보세요*<br />
<br />
===Windows 9x에서 어셈블러 사용===<br />
<br />
Windows 9x에서 역시 어셈블러 코드를 사용할 수 있다. $CC를 $320 포트에 쓰고싶다고 가정해보자. 다음 코드가 그렇게 해줄 것이다:<br />
<br />
<delphi><br />
{$ASMMODE ATT}<br />
...<br />
asm<br />
movl $0x320, %edx<br />
movb $0xCC, %al<br />
outb %al, %dx<br />
end ['EAX','EDX'];<br />
</delphi><br />
<br />
===Windows상에서 문제 해결===<br />
<br />
Windows상에서 플럭앤플레이를 지원하지 않는 패러랠 하드웨어를 사용할 때 문제를 일으키는 가능한 한가지는 당신의 하드웨어에 의해 사용되고 있는 포트를 다른 하드웨어에 할당할 때 일어난다. Windows가 당신의 디바이스 주소에 플럭앤플레이 디바이스를 할당하지 못하도록 하는 방법을 아래 URL에서 그에 대해 설명된 것을 찾을 수 있을 것이다:<br />
<br />
http://support.microsoft.com/kb/135168<br />
<br />
===리눅스상에서 포트 접근을 위해서는 ioperm을 사용===<br />
<br />
리눅스에서 하드웨어에 접근하는 가장 좋은 방법은 디바이스 드라이버를 통해 하는 것이지만 드라이버를 만드는 작업이 너무 복잡함으로 인해 가끔은 빠른 방법이 매우 유용하다. <br />
<br />
리눅스에서 "[[doc:rtl/ports|ports]]" unit를 이용하기 위해서는 프로그램은 root로 실행해야만 하며 포트접근을 위한 적절한 퍼미션 설정을 위해 IOPerm을 콜해야 한다. "[[doc:rtl/ports|ports]]" 유닛에 관한 문서는 다음에서 찾을 수 있다.<br />
[http://www.freepascal.org/docs-html/rtl/ports/index.html 이곳].<br />
<br />
첫번째 할 일은 (g)libc를 링크하고 IOPerm을 콜하는 것이다. 유닛과 연결된 완전한 (g)libc가 프리파스칼에 존재하지만 이 유닛은 어플리케이션이 직접 사용할 때 문제를 야기하고, 또한 이것을 완전한 (g)libc 라이브러리에 정적으로 연결하는 것은 호환되지 않은 방법으로 버전이 변화하기 때문에 좋은 생각은 아니다. 그러나 ioperm같은 함수는 변하지 않을 것 같다.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external 'libc';<br />
{$ENDIF}<br />
</delphi><br />
<br />
* "from" 은 접근할 수 있는 첫번째 포트를 표시한다.<br />
* "num" 은 첫번째 접근한 다음의 포트 수이므로 ioperm(&220, 8, 1)은 프로그램에게 $220과 $227를 포함한 그 사이의 모든 포트를 접근하게 할 것이다.<br />
<br />
IOPerm에 링크 한 후 포트에 접근하기 위해 port[<Address>]를 사용할 수 있다.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
i := ioperm($220, 8, 1);<br />
port[$220] := $00;<br />
myLabel.Caption := 'ioperm: ' + IntToStr(i);<br />
i := Integer(port[$220]);<br />
myOtherLabel.Caption := 'response: ' + IntToStr(i);<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 코드는 커스텀 ISA 카드의 포트 $0220에서 테스트 하였으며, Mandriva Linux 2005 와 Damn Small Linux 1.5상에서 Lazarus 0.9.10을 사용하였다.<br />
<br />
===일반적인 유닉스 하드웨어 접근===<br />
<br />
<delphi><br />
{$IFDEF Unix}<br />
Uses Clib; // libc 라이브러리 이름을 가져옴.<br />
{$ENDIF}<br />
<br />
{$IFDEF Unix}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external clib;<br />
{$ENDIF}<br />
</delphi><br />
<br />
<br />
'''Note 1''' :FPC는 "fpioperm"이라 불리는 ioperm에 대한 추상화를 [[doc:rtl/x86/index.html|unit x86]]에서 제공하며 또한 out과 inport 함수를 제공한다. 이 함수들은 현재 Linux/x86 과 FreeBSD/x86에서도 구현되어 있다.<br />
<br />
배포와 이동성 기능 때문에 반드시 필요한 것이 아니라면 libc에 링크하는 것은 추천하지 않는다. 또한 위에서 한 것처럼 수동으로 libc에 링크(다른 곳에 필요한 함수 때문에 특별히 libc 임포트를 선언하여)하는 것도 추천되지 않는다.(예, 위의 libc 임포트(import) 라인은 표준(standard) C lib가 BeOS상의 libroot나 비표준 C심볼을 가진 플랫폼같이 libc에 의해 콜되지 않으면 실패하게 된다. <br />
<br />
'''Note 2''' _unit_ libc를 사용하는 것 역시 Kylix 호환을 제외한 어떤 환경하에서도 추천되지 않는다. 이것은 유닛은 상대적으로 이동성이 떨어지며(구조체와 다른 private 심볼의 과도한 노출(excessive exposure)) Kylix와 호환이 되지 않는 것에서는 가능한 적은 수정만이 필요하기 때문이다.<br />
<br />
==시리얼 통신==<br />
<br />
시리얼 통신 소프트웨어를 빌드하는 것은 [http://synapse.ararat.cz/doku.php Synaser library]를 이용하면 매우 쉽다. [http://synapse.ararat.cz/doc/help/synaser.html Synaser 문서]와 함께 사용한 예는 이해하기가 쉬워야 한다. 가장 중요한 부분은 속도(초당 bits)와 데이터 비트, 패리티 비트, 스톱 비트 및 핸드쉐이크 프로토콜 등을 조정하는 TBlockSerial.Config이다. 다음의 코드는 COM 1에 연결된 시리얼 마우스에서 테스트 하였다.<br />
<br />
<delphi><br />
program comm;<br />
<br />
{$apptype console}<br />
<br />
uses<br />
Classes, SysUtils, Synaser;<br />
<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('COM1');<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
while True do<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
finally<br />
ser.free;<br />
end;<br />
end.<br />
</delphi><br />
<br />
다음의 코드-에제는 상기에 있는 예제의 또 다른 버전이다. 위에 보인 예는, 정확히 말하자면 메인 컨셉에서 결정적으로 잘못된 것이 있어 보인다. 이 부분은 "while true do..."이다. 테스트에서 시스템(Asus A6T 랩탑으로 Digitus USB가 RS232 어댑터에 연결되어 있으며 Ubuntu 8.04.1를 사용한다)에서 이 부분은 다음과 같은 에러를 일으켰다: 어플리케이션은 세션당 단 한번 만 성공적으로 실행이 되었고, 어플리케이션을 다시 시작하면, 어프리케이션은 시리얼 포트에 연결할 수가 없었다. 그러므로 사용자가 어플리케이션을 다시 시작할 때마다 리부트가 필요했으므로, 이는 정말 불쾌한 버그인 것이다.<br />
<br />
이유를 이해하는 것은 어렵지 않다: 어플리케이션은 while true do 루프에 있게 되면, 그것은 정확히 말하면 무한 루프이다. 중단할 방법이 없기 때문에 어플리케이션을 중단시킬 유일한 방법은 터미널을 닫거나 CTRL-C를 누르는 것 뿐이다. 그러나 어플리케이션을 이런 방법으로 종료한다면, 시리얼 포트를 해제하는 "ser.free"의 중요한 부분이 콜되지 않는다. 이 문제는 다음의 독일의 라자루스 포럼[http://www.lazarusforum.de/viewtopic.php?f=10&t=2082 http://www.lazarusforum.de/viewtopic.php?f=10&t=2082]에 설명되어 있다.<br />
<br />
각 사용자가 CTRL-C를 누르지 않고 클리어하기 위한 메인 어플리케이션에서의 코드는 약간 만 필요하다. /dev/ttyUSB0를 com-포트를 위해 사용하는 것에 대해 걱정하는 사람은 테스트 시스템상의 USB-시리얼 어댑터(Digitus) 때문이다.만약 ㅅ스템에 내장된 시리얼 포트를 가지고 있다면 'Com0'를 사용하는 것이 좋다.- 위의 예와 같이 코드와 같이 선언해서.<br />
<br />
<delphi><br />
<br />
program serialtest;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$IFDEF UNIX}{$IFDEF UseCThreads}<br />
cthreads,<br />
{$ENDIF}{$ENDIF}<br />
Classes,SysUtils,Synaser,Crt<br />
{ you can add units after this };<br />
<br />
var l:boolean;<br />
<br />
function check_affirmation():boolean;<br />
var k:string;<br />
begin<br />
Writeln('To quit the application please do NOT use CTRL-C! Instead, please press any key to quit the application! '+<br />
'Please confirm this notification before the application continues! '+<br />
'[0]=Quit, [1]=Confirm, please continue! ');<br />
Writeln('Your decision: ');<br />
Read(k);<br />
if StrtoInt(k) = 1 then<br />
begin<br />
check_affirmation:=true;<br />
Writeln('OK, application continues ...');<br />
end<br />
else<br />
begin<br />
check_affirmation:=false;<br />
Writeln('Abort');<br />
end<br />
end;<br />
<br />
procedure RS232_connect;<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('/dev/ttyUSB0'); //ComPort<br />
Sleep(1000);<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
Write('Device: ' + ser.Device + ' Status: ' + ser.LastErrorDesc +' '+<br />
Inttostr(ser.LastError));<br />
Sleep(1000);<br />
repeat<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
until keypressed; //Important!!!<br />
finally<br />
Writeln('Serial Port will be freed...');<br />
ser.free;<br />
Writeln('Serial Port was freed successfully!');<br />
end;<br />
end;<br />
<br />
begin<br />
l:=check_affirmation();<br />
if l=true then<br />
RS232_connect()<br />
else<br />
Writeln('Program quit! ');<br />
end.<br />
<br />
</delphi><br />
<br />
또한,[[Hardware Access#External Links | 외부 링크]] 섹션에 유닉스와 윈도우즈 시리얼 포트 튜토리얼이 있다.<br />
<br />
==USB==<br />
<br />
===libusb===<br />
<br />
<br />
[http://libusb.sourceforge.net/ libusb] 는 Linux, BSDs 및 Mac OS X 등의 크로스 플랫폼을 지원합니다.<br />
<br />
헤더를 구할 수 있는 링크는 다음과 같습니다. http://www.freepascal.org/contrib/db.php3?category=Miscellaneous :<br />
<br />
{|cellpadding="4"<br />
|-<br />
! 이름 !! 제작자 !! 버전 !! 일자 !! 링크 !! 비고<br />
|-<br />
| libusb.pp || nowrap | Uwe Zimmermann || 0.1.12 || nowrap | 2006-06-29 || http://www.sciencetronics.com/download/fpc_libusb.tgz || <br />
|-<br />
| libusb.pas || Johann Glaser || || nowrap | 2005-01-14 || http://www.johann-glaser.at/projects/libusb.pas || <br />
|-<br />
| fpcusb || Joe Jared || 0.11-14 || nowrap | 2006-02-02 || http://relays.osirusoft.com/fpcusb.tgz || nowrap | 다운로드 링크 깨짐<br />
|}<br />
<br />
===FTDI===<br />
<br />
만약 [http://www.ftdichip.com/ FTDI]의 칩 중의 하나를 사용한다면, 칩을 위한 dll 인터페이스용 파스칼 헤더를 사용할 수 있다.<br />
<br />
==외부 링크==<br />
<br />
통신 프로토콜 속도 비교:<br />
<br />
# http://en.wikipedia.org/wiki/Serial_port#Speed<br />
# http://www.lvr.com/jansfaq.htm - Jan Axelson의 패어랠 포트 FAQ<br />
# http://en.wikipedia.org/wiki/USB#Transfer_Speed<br />
# http://en.wikipedia.org/wiki/PCI#Conventional_PCI_bus_specifications<br />
<br />
시리얼 통신 링크:<br />
<br />
# UNIX에서: [http://www.easysw.com/~mike/serial/serial.html]<br />
# Windows에서: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp<br />
# Synaser 콤포넌트: http://synapse.ararat.cz/<br />
# Comport 델파이 패키지e: http://sourceforge.net/projects/comport/<br />
<br />
ISA 디지탈 오실로 스코프- 하드웨어 접근에대한 완전 소스가 포함된 예제:<br />
<br />
[http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/]<br />
<br />
----<br />
[[네트워킹]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Hardware_Access/ko&diff=32345Hardware Access/ko2008-11-27T08:12:38Z<p>Oranke: /* libusb */</p>
<hr />
<div>{{Hardware Access}}<br />
__TOC__<br />
==개관==<br />
이 페이지는 라자루스상에서 하드웨어 장치(디바이스)에 접근하기위한 튜토리얼의 시작입니다. 이 장치들은 ISA, PCI, USB, parallel port, serial port 등을 포함하지만 이것들에 제한된것은 아닙니다.<br />
완전한 멀티 플랫폼상에서 하드웨어에 접근하는 것은 프리파스칼 라이브러리나 LCL에의해 구현되지는 않았으므로 이 튜토리얼은 다른 플랫폼상에서의 기초적인 하드웨어 접근 방법을 다룰 것 입니다. 조건적인 컴파일에 의해 다른 플랫폼에서 컴파일된 코드는 다음과 같을 것이다:<br />
<delphi><br />
uses<br />
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,<br />
{$IFDEF WIN32}<br />
Windows;<br />
{$ENDIF}<br />
{$IFDEF Unix}<br />
ports;<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 시점에서 Mac OX/x86이 HW 접근을 허용하는지는 아직 확실치는 않다. 이 경우에서는 내가 가정하듯이 위의 방법이 허용되지 않을 수 있지만 곧 io.dll같은 드라이버가 나타날 것이다.<br />
<br />
==패러랠과 시리얼 의 비교==<br />
ISA카드, PCI 카드 및 패러랠 포트는 '''parallel''' 프로토콜에 의해 컴퓨터와 통신을 한다. 시리얼 포트와 USB장치는 '''serial''' 프로토콜로 통신한다. 프로세서와 프로그래밍 언어는 모두 데이터에 패러랠한 접근을 통해 작업을 수행하기 때문에 이런 종류의 프로토콜에 대한 접근은 소프트웨어 측면에서 보면 구현하기가 더 쉽다.예를 들어, Integer 변수에 접근할 때, 단일 명령으로 그 값에 접근할 수가 있다. 그러나 시리얼 포트 프로토콜에서는 동시에 한개의 비트만을 알 수 밖에 없으며 데이터를 이해하기 위해서는 그 비트 조각들을 붙여 놓을 필요가 있다.<br />
<br />
시리얼 툥신은 직접적으로 구현하기가 어렵지만, 미리 만들어 놓은(pre-made) 컴포넌트를 사용한다면 매우 쉽게 구현할 수가 있다.이는 하드웨어 측면에서도 역시 어려운건 마찬가지이기 때문에 많은 장치들은 그것을 구현하기 위해 특별한 통합 써킷이나 마이크로 컨트롤러를 사용한다.<br />
<br />
이제 다음에 하드웨어 접근 프로토콜에 대한 간략한 비교가 있다:<br />
<br />
{| border=2 width="100%"<br />
<br />
|-<br />
!<br />
! 속도<br />
! 하드웨어 구현의 난이도<br />
<br />
|-<br />
! 시리얼 포트<br />
| align="center" | 매우 느림 (< E5 bit/s)<br />
| align="center" | 중간<br />
<br />
|-<br />
! 패러랠 포트<br />
| align="center" | 느림 (~ E6 bit/s)<br />
| align="center" | 쉬움<br />
<br />
|-<br />
<br />
! ISA 카드<br />
| align="center" | 중간(~ E7 bit/s)<br />
| align="center" | 중간<br />
<br />
|-<br />
! USB<br />
| align="center" | 중간(~ E7 bit/s)<br />
| align="center" | 어려움<br />
<br />
|-<br />
! PCI 카드<br />
| align="center" | 매우 빠름 (> E9 bit/s)<br />
| align="center" | 매우 어려움<br />
<br />
|}<br />
<br />
==패러랠 통신==<br />
<br />
===윈도우에서 inpout32.dll의 이용===<br />
윈도우즈는 9x시리즈와 NT시리즈에서 하드웨어 접근에 있어서 다른 방법을 취하고 있다. 9x 시리즈(95, 98, Me)에서 프로그램은 DOS상에서 했듯이 하드웨어에 직접 접근 할 수가 있었다. 그러나 NT 시리즈(Windows NT and XP)에서는 이런 접근방법을 허용하고 있지 않다. 이 구조에서 하드웨어 포트와의 모든 통신은 디바이스 드라이버를 통해 이루어진다. 이것은 보안 메커니즘이지만, 작은 프로젝트에서도 드라이버 개발에 시간과 비용 등 많은 댓가를 추가하게 된다.<br />
<br />
행복하게도 이 문제를 해결할 수 있는 라이브러리가 있다. 만약 Windows NT가 탐지 된다면, HWInterface.sys 커널 디바이스 드라이버의 압축을 해제하고 설치를 한다. 만약 Windows 9x가 탐지된다면 하드웨어 접근은 단순히 어셈블러 opcode를 이용한다.<br />
<br />
그렇지만 이 라이브러리를 어떻게 사용할까요? 간단합니다! 이것은 Inp32 와 Out32 등의 단지 두개의 함수만이 있으므로 사용법은 매우 직관적이다<br />
<br />
라이브러리를 동적으로 로드하므로, 먼저 두개의 함수를 정의해 보자:<br />
<br />
<delphi><br />
type<br />
TInp32 = function(Address: SmallInt): SmallInt; stdcall;<br />
TOut32 = procedure(Address: SmallInt; Data: SmallInt); stdcall;<br />
</delphi><br />
<br />
* Address는 접근하려는 포트의 어드레스를 표시한다<br />
* Out32는 지정한 Address의 포트로 Data를 전송한다<br />
* Inp32는 지정한 포트로부터 한개의 byte를 되돌려 준다<br />
<br />
이제 라이브러리를 로드한다. 이것은 작성한 프로그램의 메인폼의 OnCreate 메소드같은 곳에서 구현할 수가 있다:<br />
<br />
<delphi><br />
type<br />
TMyForm = class(TForm)<br />
.........<br />
private<br />
{ private declarations }<br />
Inpout32: THandle;<br />
Inp32: TInp32;<br />
Out32: TOut32;<br />
.........<br />
implementation<br />
.........<br />
procedure TMyForm.FormCreate(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
Inpout32 := LoadLibrary('inpout32.dll');<br />
if (Inpout32 <> 0) then<br />
begin<br />
// needs overtyping, plain Delphi's @Inp32 = GetProc... leads to compile errors<br />
Inp32 := TInp32(GetProcAddress(Inpout32, 'Inp32'));<br />
if (@Inp32 = nil) then Caption := 'Error';<br />
Out32 := TOut32(GetProcAddress(Inpout32, 'Out32'));<br />
if (@Out32 = nil) then Caption := 'Error';<br />
end<br />
else Caption := 'Error';<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
OnCreate 에서 라이브러리를 로드했으면 OnDestroy에서 언로드하는 것을 잊으면 안된다:<br />
<br />
<delphi><br />
procedure TMyForm.FormDestroy(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
FreeLibrary(Inpout32);<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
다음에 Inp32 함수를 이용하는 방법에 관한 단순한 예제가 있다:<br />
<br />
<delphi><br />
{$IFDEF WIN32}<br />
myLabel.Caption := IntToStr(Inp32($0220));<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 코드는 Windows XP상의 포트 $0220에 있는 커스텀 ISA카드에서 Lazarus 0.9.10으로 터스트하였다. 물론 이코드를 실행하기 위해서는 uses 절에 Windows를 넣어야 한다. 개발을 위해 할 일은 작성하는 응용프로그램과 같은 디렉토리에 있는"inpout32.dll"를 인클루드(include)하기만 하면 된다.<br />
<br />
이 라이브러리에 관한 홈페이지는 다음과 같다: [http://www.logix4u.net/inpout32.htm www.logix4u.net/inpout32.htm] *토론을 보세요*<br />
<br />
===Windows 9x에서 어셈블러 사용===<br />
<br />
Windows 9x에서 역시 어셈블러 코드를 사용할 수 있다. $CC를 $320 포트에 쓰고싶다고 가정해보자. 다음 코드가 그렇게 해줄 것이다:<br />
<br />
<delphi><br />
{$ASMMODE ATT}<br />
...<br />
asm<br />
movl $0x320, %edx<br />
movb $0xCC, %al<br />
outb %al, %dx<br />
end ['EAX','EDX'];<br />
</delphi><br />
<br />
===Windows상에서 문제 해결===<br />
<br />
Windows상에서 플럭앤플레이를 지원하지 않는 패러랠 하드웨어를 사용할 때 문제를 일으키는 가능한 한가지는 당신의 하드웨어에 의해 사용되고 있는 포트를 다른 하드웨어에 할당할 때 일어난다. Windows가 당신의 디바이스 주소에 플럭앤플레이 디바이스를 할당하지 못하도록 하는 방법을 아래 URL에서 그에 대해 설명된 것을 찾을 수 있을 것이다:<br />
<br />
http://support.microsoft.com/kb/135168<br />
<br />
===리눅스상에서 포트 접근을 위해서는 ioperm을 사용===<br />
<br />
리눅스에서 하드웨어에 접근하는 가장 좋은 방법은 디바이스 드라이버를 통해 하는 것이지만 드라이버를 만드는 작업이 너무 복잡함으로 인해 가끔은 빠른 방법이 매우 유용하다. <br />
<br />
리눅스에서 "[[doc:rtl/ports|ports]]" unit를 이용하기 위해서는 프로그램은 root로 실행해야만 하며 포트접근을 위한 적절한 퍼미션 설정을 위해 IOPerm을 콜해야 한다. "[[doc:rtl/ports|ports]]" 유닛에 관한 문서는 다음에서 찾을 수 있다.<br />
[http://www.freepascal.org/docs-html/rtl/ports/index.html 이곳].<br />
<br />
첫번째 할 일은 (g)libc를 링크하고 IOPerm을 콜하는 것이다. 유닛과 연결된 완전한 (g)libc가 프리파스칼에 존재하지만 이 유닛은 어플리케이션이 직접 사용할 때 문제를 야기하고, 또한 이것을 완전한 (g)libc 라이브러리에 정적으로 연결하는 것은 호환되지 않은 방법으로 버전이 변화하기 때문에 좋은 생각은 아니다. 그러나 ioperm같은 함수는 변하지 않을 것 같다.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external 'libc';<br />
{$ENDIF}<br />
</delphi><br />
<br />
* "from" 은 접근할 수 있는 첫번째 포트를 표시한다.<br />
* "num" 은 첫번째 접근한 다음의 포트 수이므로 ioperm(&220, 8, 1)은 프로그램에게 $220과 $227를 포함한 그 사이의 모든 포트를 접근하게 할 것이다.<br />
<br />
IOPerm에 링크 한 후 포트에 접근하기 위해 port[<Address>]를 사용할 수 있다.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
i := ioperm($220, 8, 1);<br />
port[$220] := $00;<br />
myLabel.Caption := 'ioperm: ' + IntToStr(i);<br />
i := Integer(port[$220]);<br />
myOtherLabel.Caption := 'response: ' + IntToStr(i);<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 코드는 커스텀 ISA 카드의 포트 $0220에서 테스트 하였으며, Mandriva Linux 2005 와 Damn Small Linux 1.5상에서 Lazarus 0.9.10을 사용하였다.<br />
<br />
===일반적인 유닉스 하드웨어 접근===<br />
<br />
<delphi><br />
{$IFDEF Unix}<br />
Uses Clib; // libc 라이브러리 이름을 가져옴.<br />
{$ENDIF}<br />
<br />
{$IFDEF Unix}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external clib;<br />
{$ENDIF}<br />
</delphi><br />
<br />
<br />
'''Note 1''' :FPC는 "fpioperm"이라 불리는 ioperm에 대한 추상화를 [[doc:rtl/x86/index.html|unit x86]]에서 제공하며 또한 out과 inport 함수를 제공한다. 이 함수들은 현재 Linux/x86 과 FreeBSD/x86에서도 구현되어 있다.<br />
<br />
배포와 이동성 기능 때문에 반드시 필요한 것이 아니라면 libc에 링크하는 것은 추천하지 않는다. 또한 위에서 한 것처럼 수동으로 libc에 링크(다른 곳에 필요한 함수 때문에 특별히 libc 임포트를 선언하여)하는 것도 추천되지 않는다.(예, 위의 libc 임포트(import) 라인은 표준(standard) C lib가 BeOS상의 libroot나 비표준 C심볼을 가진 플랫폼같이 libc에 의해 콜되지 않으면 실패하게 된다. <br />
<br />
'''Note 2''' _unit_ libc를 사용하는 것 역시 Kylix 호환을 제외한 어떤 환경하에서도 추천되지 않는다. 이것은 유닛은 상대적으로 이동성이 떨어지며(구조체와 다른 private 심볼의 과도한 노출(excessive exposure)) Kylix와 호환이 되지 않는 것에서는 가능한 적은 수정만이 필요하기 때문이다.<br />
<br />
==시리얼 통신==<br />
<br />
시리얼 통신 소프트웨어를 빌드하는 것은 [http://synapse.ararat.cz/doku.php Synaser library]를 이용하면 매우 쉽다. [http://synapse.ararat.cz/doc/help/synaser.html Synaser 문서]와 함께 사용한 예는 이해하기가 쉬워야 한다. 가장 중요한 부분은 속도(초당 bits)와 데이터 비트, 패리티 비트, 스톱 비트 및 핸드쉐이크 프로토콜 등을 조정하는 TBlockSerial.Config이다. 다음의 코드는 COM 1에 연결된 시리얼 마우스에서 테스트 하였다.<br />
<br />
<delphi><br />
program comm;<br />
<br />
{$apptype console}<br />
<br />
uses<br />
Classes, SysUtils, Synaser;<br />
<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('COM1');<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
while True do<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
finally<br />
ser.free;<br />
end;<br />
end.<br />
</delphi><br />
<br />
다음의 코드-에제는 상기에 있는 예제의 또 다른 버전이다. 위에 보인 예는, 정확히 말하자면 메인 컨셉에서 결정적으로 잘못된 것이 있어 보인다. 이 부분은 "while true do..."이다. 테스트에서 시스템(Asus A6T 랩탑으로 Digitus USB가 RS232 어댑터에 연결되어 있으며 Ubuntu 8.04.1를 사용한다)에서 이 부분은 다음과 같은 에러를 일으켰다: 어플리케이션은 세션당 단 한번 만 성공적으로 실행이 되었고, 어플리케이션을 다시 시작하면, 어프리케이션은 시리얼 포트에 연결할 수가 없었다. 그러므로 사용자가 어플리케이션을 다시 시작할 때마다 리부트가 필요했으므로, 이는 정말 불쾌한 버그인 것이다.<br />
<br />
이유를 이해하는 것은 어렵지 않다: 어플리케이션은 while true do 루프에 있게 되면, 그것은 정확히 말하면 무한 루프이다. 중단할 방법이 없기 때문에 어플리케이션을 중단시킬 유일한 방법은 터미널을 닫거나 CTRL-C를 누르는 것 뿐이다. 그러나 어플리케이션을 이런 방법으로 종료한다면, 시리얼 포트를 해제하는 "ser.free"의 중요한 부분이 콜되지 않는다. 이 문제는 다음의 독일의 라자루스 포럼[http://www.lazarusforum.de/viewtopic.php?f=10&t=2082 http://www.lazarusforum.de/viewtopic.php?f=10&t=2082]에 설명되어 있다.<br />
<br />
각 사용자가 CTRL-C를 누르지 않고 클리어하기 위한 메인 어플리케이션에서의 코드는 약간 만 필요하다. /dev/ttyUSB0를 com-포트를 위해 사용하는 것에 대해 걱정하는 사람은 테스트 시스템상의 USB-시리얼 어댑터(Digitus) 때문이다.만약 ㅅ스템에 내장된 시리얼 포트를 가지고 있다면 'Com0'를 사용하는 것이 좋다.- 위의 예와 같이 코드와 같이 선언해서.<br />
<br />
<delphi><br />
<br />
program serialtest;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$IFDEF UNIX}{$IFDEF UseCThreads}<br />
cthreads,<br />
{$ENDIF}{$ENDIF}<br />
Classes,SysUtils,Synaser,Crt<br />
{ you can add units after this };<br />
<br />
var l:boolean;<br />
<br />
function check_affirmation():boolean;<br />
var k:string;<br />
begin<br />
Writeln('To quit the application please do NOT use CTRL-C! Instead, please press any key to quit the application! '+<br />
'Please confirm this notification before the application continues! '+<br />
'[0]=Quit, [1]=Confirm, please continue! ');<br />
Writeln('Your decision: ');<br />
Read(k);<br />
if StrtoInt(k) = 1 then<br />
begin<br />
check_affirmation:=true;<br />
Writeln('OK, application continues ...');<br />
end<br />
else<br />
begin<br />
check_affirmation:=false;<br />
Writeln('Abort');<br />
end<br />
end;<br />
<br />
procedure RS232_connect;<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('/dev/ttyUSB0'); //ComPort<br />
Sleep(1000);<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
Write('Device: ' + ser.Device + ' Status: ' + ser.LastErrorDesc +' '+<br />
Inttostr(ser.LastError));<br />
Sleep(1000);<br />
repeat<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
until keypressed; //Important!!!<br />
finally<br />
Writeln('Serial Port will be freed...');<br />
ser.free;<br />
Writeln('Serial Port was freed successfully!');<br />
end;<br />
end;<br />
<br />
begin<br />
l:=check_affirmation();<br />
if l=true then<br />
RS232_connect()<br />
else<br />
Writeln('Program quit! ');<br />
end.<br />
<br />
</delphi><br />
<br />
또한,[[Hardware Access#External Links | 외부 링크]] 섹션에 유닉스와 윈도우즈 시리얼 포트 튜토리얼이 있다.<br />
<br />
==USB==<br />
<br />
===libusb===<br />
<br />
<br />
[http://libusb.sourceforge.net/ libusb] 는 Linux, BSDs 및 Mac OS X 등 크로스 플랫폼을 지원합니다.<br />
<br />
헤더를 구할 수 있는 링크는 다음과 같습니다. http://www.freepascal.org/contrib/db.php3?category=Miscellaneous :<br />
<br />
{|cellpadding="4"<br />
|-<br />
! 이름 !! 제작자 !! 버전 !! 일자 !! 링크 !! 비고<br />
|-<br />
| libusb.pp || nowrap | Uwe Zimmermann || 0.1.12 || nowrap | 2006-06-29 || http://www.sciencetronics.com/download/fpc_libusb.tgz || <br />
|-<br />
| libusb.pas || Johann Glaser || || nowrap | 2005-01-14 || http://www.johann-glaser.at/projects/libusb.pas || <br />
|-<br />
| fpcusb || Joe Jared || 0.11-14 || nowrap | 2006-02-02 || http://relays.osirusoft.com/fpcusb.tgz || nowrap | 다운로드 링크 깨짐<br />
|}<br />
<br />
===FTDI===<br />
<br />
만약 [http://www.ftdichip.com/ FTDI]의 칩 중의 하나를 사용한다면, 칩을 위한 dll 인터페이스용 파스칼 헤더를 사용할 수 있다.<br />
<br />
==외부 링크==<br />
<br />
통신 프로토콜 속도 비교:<br />
<br />
# http://en.wikipedia.org/wiki/Serial_port#Speed<br />
# http://www.lvr.com/jansfaq.htm - Jan Axelson의 패어랠 포트 FAQ<br />
# http://en.wikipedia.org/wiki/USB#Transfer_Speed<br />
# http://en.wikipedia.org/wiki/PCI#Conventional_PCI_bus_specifications<br />
<br />
시리얼 통신 링크:<br />
<br />
# UNIX에서: [http://www.easysw.com/~mike/serial/serial.html]<br />
# Windows에서: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp<br />
# Synaser 콤포넌트: http://synapse.ararat.cz/<br />
# Comport 델파이 패키지e: http://sourceforge.net/projects/comport/<br />
<br />
ISA 디지탈 오실로 스코프- 하드웨어 접근에대한 완전 소스가 포함된 예제:<br />
<br />
[http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/]<br />
<br />
----<br />
[[네트워킹]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Documentation/ko&diff=32330Lazarus Documentation/ko2008-11-27T02:09:27Z<p>Oranke: /* 라자루스와 파스칼 튜토리얼 */</p>
<hr />
<div>{{Lazarus Documentation}}<br />
<br />
==라자루스와 파스칼 튜토리얼==<br />
*[[Overview of Free Pascal and Lazarus/ko|프리파스칼과 라자루스 살펴보기]] - 간략한 소개글 입니다.<br />
*[[Lazarus Tutorial/ko|라자루스 튜토리얼]] - 라자루스 IDE에 대해 자세히 다루고 있는 초보자를 위한 설명서 입니다.<br />
*[[Lazarus IDE Tools|라자루스 IDE 툴]] - 코드 자동완성을 비롯한 기타 IDE의 내용들을 다루는 중급자용 설명서 입니다.<br />
*[[Lazarus Database Tutorial|라자루스 데이터베이스 튜토리얼]] - 데이터베이스 개발에 라자루스를 사용하기 위한 소개서 입니다.<br />
*[[Developing with Graphics|그래픽 개발]] - 그래픽 프로그래밍을 위한 기본적인 예제들 입니다.<br />
*[[Pascal Tutorial]] - [http://www.taoyue.com/ Tao Yue's] [http://www.taoyue.com/tutorials/pascal/ Pascal Tutorial] (reposted with permission).<br />
*[[Object Oriented Programming with FreePascal and Lazarus|프리파스칼과 라자루스를 사용한 객체 지향 프로그래밍]] - 파스칼 이상의 파스칼<br />
*[[Console Mode Pascal|콘솔 모드 파스칼]] - 라자루스 IDE를 사용해 텍스트 모드에서 구동되는 프로그램 만들기 입니다.<br />
*[[Executing External Programs|외부 프로그램 실행]] - 외부 프로그램을 실행시키는 방법에 대한 간단한 설명서 입니다.<br />
*[[TXMLPropStorage]] - Using TXMLPropStorage to save user preferences.<br />
*[[Hardware Access/ko|하드웨어 제어]] - ISA, PCI카드, 패러랠, 시리얼, USB 디바이스 등의 하드웨어 접근법 입니다.<br />
*[[Networking|네트워킹]] - Tutorials about TCP/IP protocol, creating secure network programs, WebServices, etc.<br />
*[[XML Tutorial|XML 튜토리얼]] - XML 파일 읽고 쓰기에 대한 내용 입니다.<br />
*[[Multithreaded Application Tutorial|멀티쓰레드 어플리케이션 튜토리얼]] - 프리파스칼과 라자루스를 사용한 멀티쓰레드 어플리케이션 제작법 입니다.<br />
*[[Streaming components|스트리밍 컴포넌트]] - 스트림에 컴포넌트를 저장하고, 다시 읽어들여 생성하는 방법 입니다.<br />
*[[OpenGL Tutorial|OpenGL 튜토리얼]] - GLUT 라이브러리를 라자루스에서 사용하는 방법 입니다.<br />
*[[Creating bindings for C libraries|C 라이브러리와 연결]] - C 헤더파일을 (.h) 파스칼 유니트로 변환하는 방법에 대해 설명합니다.<br />
*[[Lazarus/FPC Libraries]] - How to create dynamic libraries (.so, .dll, .dylib) and how to use them<br />
*[[Translations / i18n / localizations for programs]] - How to provide localized versions of your programs and packages<br />
*[[Daemons and Services]] - 윈도의 서비스, 또는 리눅스의 데몬을 만드는 법에 대해 이야기 합니다.<br />
*[[Office Automation]] - How to interact with office software and create spreadsheets, text documents, presentations, etc.<br />
*[[Lazarus Inline Assembler]] - a getting started guide.<br />
*[[VirtualTreeview Example for Lazarus]] - Using VirtualTreeview on Lazarus.<br />
*[http://es.wikibooks.org/wiki/Programaci%C3%B3n_en_Pascal Programando en Pascal] - Spanish tutorial focused on FPC/Lazarus, hosted in Wikibooks.<br />
<br />
==라자루스 사용자 가이드==<br />
*[[Lazarus Faq/ko|라자루스 FAQ]] - 리눅스 및 윈도 유저를 위한 일반적인 정보들 입니다..<br />
*[[Lazarus DB Faq|라자루스 DB FAQ]] - 라자루스에서 DB를 다룰 때 만나는 문제들에 대한 FAQ 입니다.<br />
*[[Databases in Lazarus|라자루스와 데이터베이스]] - 라자루스에서 데이터베이스를 사용하는 것에 대한 간략한 안내 입니다.<br />
*[[Code Examples|예제 모음]] - 라자루스 예제 모음 입니다.<br />
*[[Feature_Ideas|Wishlist/Wanted Features]] - Features that you would like to see in Lazarus<br />
*[[How do I create a bug report]] - You think you found a bug in Lazarus, how can you report it?<br />
<br />
===설치하기=== <br />
*[[Installing Lazarus|라자루스 설치]] - 설치 방법에 대한 안내 입니다.<br />
*[[Getting Lazarus|라자루스 구하기]] - 라자루스의 릴리즈버전, 또는 SVN을 통한 개발버전을 얻는 방법에 대한 안내 입니다. <br />
*[[Multiple Lazarus|여러 버전의 라자루스]] - 한 대의 컴퓨터에 여러 버전의 라자루스를 설치하는 방법에 대한 안내 입니다. <br />
<br />
===IDE===<br />
*[[IDE tricks]] - Tips, tricks and hidden features<br />
*[[Lazarus IDE]] - The IDE windows<br />
*[[Lazarus IDE Shortcuts]] - The key mapping and shortcuts.<br />
*[[Lazarus Packages]] - A guide for creating a package under Lazarus<br />
*[[Install Packages]] - A small guide to install packages<br />
*[[Extending the IDE]] - How to add functionality to the Lazarus IDE<br />
*[[Adding Kylix Help]] - How to use the Borland Help files within the IDE editor.<br />
*[[Using Lazarus for other computer languages]] - How to use the IDE for C, Java, etc.<br />
*[[IDE Development]] - Various pages about current development of the IDE.<br />
<br />
===LCL===<br />
*[[doc:lcl/|LCL documentation]] - On line help for LCL (work in progress).<br />
*[[The LCL in various platforms]] - A brief discussion about LCL features which behave differently in different platforms.<br />
*[[Autosize / Layout]] - How to design forms that work on all platforms.<br />
*[[Main Loop Hooks]] - How to handle multiple event sources<br />
*[[Asynchronous Calls]] - How to queue methods for later execution<br />
*[[File size and smartlinking]] - How to smartlink applications and create smaller executables.<br />
*[[Accessing the Interfaces directly]] - Example how to access the LCL widgetsets<br />
*[[Add Help to Your Application]] - How to create a Online Help for your application<br />
*[[Anchor Sides]] - Description of Anchor Sides Feature<br />
*[[LCL Tips]] - Tips and tricks<br />
*[[LCL Defines]] - Choosing the right options to recompile LCL<br />
<br />
===Developing===<br />
*[[The Power of Proper Planning and Practices]] - common-sense programming best practices for the Free Pascal and Lazarus developer<br />
*[[Multiplatform Programming Guide]] - How to develop cross-platform applications and how to port from one platform to another<br />
*[[Using Pascal Libraries with .NET and Mono]] - yes, you can use your Free Pascal code with .NET and Mono<br />
*[[Deploying Your Application]] - How to create an installer for your application<br />
*[[Cross compiling]] - Creating executables of one platform, on another.<br />
*[[Remote Debugging]] - How to debug your Lazarus application from another machine.<br />
*[[Application Icon]] - Setting the application icon<br />
<br />
===플랫폼 별 유용한 팁===<br />
*[[OS X Programming Tips]] - Lazarus installation, useful tools, Unix commands, and more...<br />
*[[WinCE Programming Tips]] - Using the telephone API, sending SMSes, and more...<br />
<br />
===함께 하면 유용한 도구들===<br />
*[[Lazarus Documentation Editor]] - Using "lazde" to create documentation<br />
*[[LazDoc]] - An integrated editor for documentation files<br />
*[[FPDoc Updater]] - A GUI tool for updating FPDoc files<br />
*[[lazbuild]] - Compiling projects and packages without the IDE<br />
*[[LazSVNPkg]] - Lazarus SVN IDE Plugin<br />
<br />
===델파이 사용자를 위한 안내===<br />
*[[Lazarus Components|라자루스 컴포넌트]] - 라자루스와 터보델파이 컴포넌트들의 차이점에 대한 정보 입니다. <br />
*[[Lazarus For Delphi Users|델파이 사용자와 라자루스]] - 라자루스를 시작하려는 델파이 사용자를 위한 정보들 입니다.<br />
*[[Code Conversion Guide|코드 변환 가이드]] - 델파이와 카일릭스용 코드 및 컴포넌트를 라자루스에서 사용하는 방법에 대해 다룹니다.<br />
<br />
==라자루스 개발자 가이드==<br />
*[[Lazarus Development Process|라자루스 개발 프로세스]] - 로드맵, 아이디어, 그리고 현재.<br />
*[[How To Help Developing Lazarus|라자루스 개발을 돕는 법]] - 라자루스의 성능 개선을 위해 도움을 주려는 새로운 개발자가 참고할만한 내용들<br />
*[[Version Numbering|버전 번호 붙이기]] - 라자루스의 버전 번호의 차이점에 대한 설명 <br />
*[[Creating A Patch| 패치 만들기]] - 개선된 기능을 라자루스에 적용하기 위해 패치를 만드는 방법<br />
*[[Creating a Backtrace with GDB|GBD용 백트레이스 생성]] - 디버깅을 위해 백트레이스를 만드는 방법<br />
*[[Nomenclature/ko|이름 붙이기]] - 메소드나 프로퍼티에 이름 붙이는 방법에 대한 설명<br />
*[[DesignGuidelines/ko|디자인 가이드 라인]] - 라자루스 소스 코드 변경시 준수해야 할 규칙<br />
*[[GUI design]] - Notes on guidelines when designing the lazarus GUI<br />
*[[Roadmap]] - An idea of the current status of the various parts of Lazarus<br />
*[[Road To 1.0]] - What needs to be done for Lazarus 1.0 and To Do lists<br />
*[[Moderating the bug tracker]] - Guidelines for lazarus developers and moderators for using the [http://www.freepascal.org/mantis/ bug tracker].<br />
*[[Codetools]] - How the codetools are integrated into the IDE<br />
*[[Creating IDE Help]] - How to extend the IDE documentation<br />
*[[Unit not found - How to find units]] - How to setup the IDE and source files<br />
*[[Bounties]] - Need a particular new feature soon? Set a price here. <br />
<br />
===LCL - 라자루스 컴포넌트 라이브러리===<br />
*[[LCL Messages]] - Guide related to LCL Messages<br />
*[[LCL Internals]] - Some info about the inner workings of the LCL<br />
*[[LCL Key Handling]] - Help! A key press, what now?<br />
*[[LCL Internals - Resizing, Moving]] - How the LCL communicates with the LCL interface to resize, move controls<br />
*[[LCL Unicode Support]] - Road to Unicode enabled Lazarus<br />
*[[LCL Documentation Roadmap]] - Which units have to be documented<br />
*[[LCL Bindings]] - Bindings to use LCL on other languages<br />
<br />
===Interfaces===<br />
*[[Lazarus known issues (things that will never be fixed)]] - A list of interface compatibility issues<br />
*[[Win32/64 Interface]] - The winapi interface for Windows 95/98/Me/2K/XP/Vista, but not CE<br />
*[[GTK1 Interface]] - The gtk1.2 for Unixes, Mac OS X, Windows<br />
*[[GTK2 Interface]] - The gtk2 for Unixes, Mac OS X, Windows<br />
*[[Carbon Interface]] - The Carbon Interface for Mac OS X<br />
*[[Qt Interface]] - The Qt 4 Interface for Unixes, Mac OS X and linux-based PDAs<br />
*[[Windows CE Interface]] - For Pocket PC and Smartphones<br />
*[[fpGUI Interface]] - A widgetset completely written in Object Pascal<br />
*[[Cocoa Interface]] - The Cocoa Interface for Mac OS X<br />
<br />
===Translations===<br />
* [[Getting translation strings right]] A few notes for programmers on how to create and use translateable strings in your application. Quickly discusses general things about creating strings, offers a few hints on implementation issues and points out some things to consider when using English as base language in particular.<br />
* '''Localization Notes:'''<br />
:* [[German localization notes|German]] - Notes and guidelines for translating the Lazarus IDE to German, including a small dictionary to look up often used translations.<br />
:* [[Portuguese-Brazilian Localization Notes|Portuguese-Brazilian]] - Small dictionary containing common translations of terms used in the Lazarus IDE for the Portuguese-Brazilian translation.<br />
:* [[Russian localization notes|Russian]] - Notes and guidelines for translating the Lazarus IDE to Russian.<br />
<!-- *[[TO-DO]] Remaining Tasks --><br />
* [[Help:Add language bar | Add language bar]] explains how you can add a list of translations to the top of a wiki page.<br />
<br />
==Additional Components Documentation==<br />
*[[Pascal Script]] and [[Pascal Script Examples]] - How to use the pascal script components in Lazarus<br />
*[[OpenGL]] - How to use OpenGL in Lazarus<br />
*[[KOL-CE]] - Free Pascal/Lazarus port of KOL&MCK library. How to create very compact applications for Win32/WinCE in Lazarus.<br />
<br />
==Free Pascal Compiler Documentation==<br />
In addition to [http://lazarus-ccr.sourceforge.net/fpcdoc/ this site], the latest version of the documentation can also be found online and in a variety of downloadable formats on the main [http://www.freepascal.org/docs.html Free Pascal Compiler site].<br />
There is now also a WiKi site for FreePascal [http://www.freepascal.org/wiki/index.php/Main_Page] very similar in style to this one, to allow developers to submit documentation in addition to the official FPC documents below.<br />
<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/user/user.html User's guide]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/prog/prog.html Programmer's guide]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/ref/ref.html Reference guide for the system unit, and supported Pascal constructs]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/rtl/index.html Run-Time Library reference manual]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/fcl/index.html Free Component Library reference manual]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/fpdoc/fpdoc.html Free Pascal documentation tool manual]<br />
*[[Build messages]]<br />
<br />
==Lazarus related blogs and websites==<br />
'''Blogs'''<br />
*[[Adventures of a Newbie]] - A blog of a newbie getting started with some tutorial information in a running log.<br />
*[http://lazarusroad.blogspot.com/ On the road with Lazarus/Freepascal] - A blog dedicated to register my experiences while programming with Lazarus and Freepascal (by Luiz Américo)<br />
*[http://port2laz.blogspot.com/ Porting to Lazarus] - This blog describes the porting of a medium-sized application (~100 kloc) from D7 with CLX to Lazarus (by Alexsander da Rosa)<br />
*[http://living-lazarus.blogspot.com/ Living Lazarus] - One mans exploration into the possibilities of an open source RAD (by [[User:Wibblytim|Wibblytim]]).<br />
*[http://beeography.wordpress.com/tag/object-pascal/ Bee.ography] just (another) Bee’s buzz!<br />
*[http://donaldshimoda.blogspot.com/ Parallel Pascal Worlds] Donald Shimoda.<br />
<br />
'''Websites'''<br />
*[[swainbrain pascal wiki]] - unique free pascal tutorials and info [http://mercury.it.swin.edu.au/swinbrain/index.php/Pascal#Pascal_Development_Tools swainbrain]</div>Orankehttps://wiki.freepascal.org/index.php?title=Hardware_Access/ko&diff=32329Hardware Access/ko2008-11-27T02:07:17Z<p>Oranke: /* Parallel Communication */</p>
<hr />
<div>{{Hardware Access}}<br />
__TOC__<br />
==개관==<br />
이 페이지는 라자루스상에서 하드웨어 장치(디바이스)에 접근하기위한 뉴토리얼의 시작입니다. 이 장치들은 ISA, PCI, USB, parallel port, serial port 등을 포함하지만 이것들에 제한된것은 아닙니다.<br />
완전한 멀티 플랫폼상에서 하드웨어에 접근하는 것은 프리파스칼 라이브러리나 LCL에의해 구현되지는 않았으므로 이 튜토리얼은 다른 플랫폼상에서의 기초적인 하드웨어 접근 방법을 다룰 것 입니다. 조건적인 컴파일에 의해 다른 플랫폼에서 컴파일된 코드는 다음과 같을 것이다:<br />
<delphi><br />
uses<br />
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,<br />
{$IFDEF WIN32}<br />
Windows;<br />
{$ENDIF}<br />
{$IFDEF Unix}<br />
ports;<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 시점에서 Mac OX/x86이 HW 접근을 허용하는지는 아직 확실치는 않다. 이 경우에서는 내가 가정하듯이 위의 방법이 허용되지 않을 수 있지만 곧 io.dll같은 드라이버가 나타날 것이다.<br />
<br />
==패러랠과 시리얼 의 비교==<br />
ISA카드, PCI 카드 및 패러랠 포트는 '''parallel''' 프로토콜에 의해 컴퓨터와 통신을 한다. 시리얼 포트와 USB장치는 '''serial''' 프로토콜로 통신한다. 프로세서와 프로그래밍 언어는 모두 데이터에 패러랠한 접근을 통해 작업을 수행하기 때문에 이런 종류의 프로토콜에 대한 접근은 소프트웨어 측면에서 보면 구현하기가 더 쉽다.예를 들어, Integer 변수에 접근할 때, 단일 명령으로 그 값에 접근할 수가 있다. 그러나 시리얼 포트 프로토콜에서는 동시에 한개의 비트만을 알 수 밖에 없으며 데이터를 이해하기 위해서는 그 비트 조각들을 붙여 놓을 필요가 있다.<br />
<br />
시리얼 툥신은 직접적으로 구현하기가 어렵지만, 미리 만들어 놓은(pre-made) 컴포넌트를 사용한다면 매우 쉽게 구현할 수가 있다.이는 하드웨어 측면에서도 역시 어려운건 마찬가지이기 때문에 많은 장치들은 그것을 구현하기 위해 특별한 통합 써킷이나 마이크로 컨트롤러를 사용한다.<br />
<br />
이제 다음에 하드웨어 접근 프로토콜에 대한 간략한 비교가 있다:<br />
<br />
{| border=2 width="100%"<br />
<br />
|-<br />
!<br />
! 속도<br />
! 하드웨어 구현의 난이도<br />
<br />
|-<br />
! 시리얼 포트<br />
| align="center" | 매우 느림 (< E5 bit/s)<br />
| align="center" | 중간<br />
<br />
|-<br />
! 패러랠 포트<br />
| align="center" | 느림 (~ E6 bit/s)<br />
| align="center" | 쉬움<br />
<br />
|-<br />
<br />
! ISA 카드<br />
| align="center" | 중간(~ E7 bit/s)<br />
| align="center" | 중간<br />
<br />
|-<br />
! USB<br />
| align="center" | 중간(~ E7 bit/s)<br />
| align="center" | 어려움<br />
<br />
|-<br />
! PCI 카드<br />
| align="center" | 매우 빠름 (> E9 bit/s)<br />
| align="center" | 매우 어려움<br />
<br />
|}<br />
<br />
==패러랠 통신==<br />
<br />
===윈도우에서 inpout32.dll의 이용===<br />
윈도우즈는 9x시리즈와 NT시리즈에서 하드웨어 접근에 있어서 다른 방법을 취하고 있다. 9x 시리즈(95, 98, Me)에서 프로그램은 DOS상에서 했듯이 하드웨어에 직접 접근 할 수가 있었다. 그러나 NT 시리즈(Windows NT and XP)에서는 이런 접근방법을 허용하고 있지가 않다. 이 구조에서 하드웨어 포트와의 모든 통신은 디바이스 드라이버를 통해 이루어진다. 이것은 보안 메커니즘이지만, 드라이버 개발에 작은 프로젝트에서도 시간과 비용등 많은 비용을 추가하게 된다.<br />
<br />
행복하게도 이 문제를 해결할 수 있는 라이브러리가 있다. 만약 Windows NT가 탐지 된다면, HWInterface.sys 커널 디바이스 드라이버의 압축을 해제하고 설치를 한다. 만약 Windows 9x가 탐지된다면 하드웨어 접근은 단순히 어셈블러 opcode를 이용한다.<br />
<br />
그렇지만 이 라이브러리를 어떻게 사용할까요? 간단합니다! 이것은 Inp32 와 Out32 등의 단지 두개의 함수만이 있으므로 사용법은 매우 직관적이다<br />
<br />
라이브러리를 동적으로 로드하므로, 먼저 두개의 함수를 정의해 보자:<br />
<br />
<delphi><br />
type<br />
TInp32 = function(Address: SmallInt): SmallInt; stdcall;<br />
TOut32 = procedure(Address: SmallInt; Data: SmallInt); stdcall;<br />
</delphi><br />
<br />
* Address는 접근하려는 포트의 어드레스를 표시한다<br />
* Out32는 지정한 Address의 포트로 Data를 전송한다<br />
* Inp32는 지정한 포트로부터 한개의 byte를 되돌린다<br />
<br />
이제 라이브러리를 로드한다. 이것은 작성한 프로그램의 메인폼의 OnCreate 메소드같은곳에서 구현할 수가 있다:<br />
<br />
<delphi><br />
type<br />
TMyForm = class(TForm)<br />
.........<br />
private<br />
{ private declarations }<br />
Inpout32: THandle;<br />
Inp32: TInp32;<br />
Out32: TOut32;<br />
.........<br />
implementation<br />
.........<br />
procedure TMyForm.FormCreate(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
Inpout32 := LoadLibrary('inpout32.dll');<br />
if (Inpout32 <> 0) then<br />
begin<br />
// needs overtyping, plain Delphi's @Inp32 = GetProc... leads to compile errors<br />
Inp32 := TInp32(GetProcAddress(Inpout32, 'Inp32'));<br />
if (@Inp32 = nil) then Caption := 'Error';<br />
Out32 := TOut32(GetProcAddress(Inpout32, 'Out32'));<br />
if (@Out32 = nil) then Caption := 'Error';<br />
end<br />
else Caption := 'Error';<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
OnCreate 에서 라이브러리를 로드했으면 OnDestroy에서 언로드하는 것을 있으면 안된다:<br />
<br />
<delphi><br />
procedure TMyForm.FormDestroy(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
FreeLibrary(Inpout32);<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
다음에 Inp32 함수를 이용하는 방법에 관한 단<br />
Here is a simple example of how to use Inp32 function:<br />
<br />
<delphi><br />
{$IFDEF WIN32}<br />
myLabel.Caption := IntToStr(Inp32($0220));<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Windows XP. Of course you will need to have Windows on your uses clause in order for this code to run. For deployment you only need to include "inpout32.dll" in the same directory of our application.<br />
<br />
This is the homepage for the library: [http://www.logix4u.net/inpout32.htm www.logix4u.net/inpout32.htm] *see discussion*<br />
<br />
<br />
===Using assembler on Windows 9x===<br />
<br />
On Windows 9x you can also use assembler code. Suppose you wish to write $CC to the $320 port. The following code will do it:<br />
<br />
<delphi><br />
{$ASMMODE ATT}<br />
...<br />
asm<br />
movl $0x320, %edx<br />
movb $0xCC, %al<br />
outb %al, %dx<br />
end ['EAX','EDX'];<br />
</delphi><br />
<br />
===Troubleshooting on Windows===<br />
<br />
One possible source of trouble using parallel hardware that does not support Plug And Play on Windows is that Windows may assign the port utilized by your hardware to another device. You can find instructions on the URL below about how to tell Windows not to assign the address of your device to Plug And Play devices:<br />
<br />
http://support.microsoft.com/kb/135168<br />
<br />
===Using ioperm to access ports on Linux===<br />
<br />
The best way to access the hardware on Linux is throught device drivers, but, due to the complexity of the task of creating a driver, sometimes a quick method is very useful.<br />
<br />
In order to use the "[[doc:rtl/ports|ports]]" unit under Linux your program must be run as root, and IOPerm must be called to set appropriate permissions on the port access. You can find documentation about the "[[doc:rtl/ports|ports]]" unit [http://www.freepascal.org/docs-html/rtl/ports/index.html here].<br />
<br />
The first thing to do is link to (g)libc and call IOPerm. A unit that links to the entire (g)libc exists on free pascal, but this unit gives problems when used directly by application and linking statically to the entire (g)libc library is not a very good idea because it changes often between version in an incompatible manner. Functions like ioperm, however, are unlikely to change.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external 'libc';<br />
{$ENDIF}<br />
</delphi><br />
<br />
* "from" represents the first port to be accessed.<br />
* "num" is the number of ports after the first to be accessed, so ioperm($220, 8, 1) will give access for the program for all ports between and including $220 and $227.<br />
<br />
After linking to IOPerm you can port[<Address>] to access the ports.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
i := ioperm($220, 8, 1);<br />
port[$220] := $00;<br />
myLabel.Caption := 'ioperm: ' + IntToStr(i);<br />
i := Integer(port[$220]);<br />
myOtherLabel.Caption := 'response: ' + IntToStr(i);<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Mandriva Linux 2005 and Damn Small Linux 1.5<br />
<br />
===General UNIX Hardware Access===<br />
<br />
<delphi><br />
{$IFDEF Unix}<br />
Uses Clib; // retrieve libc library name.<br />
{$ENDIF}<br />
<br />
{$IFDEF Unix}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external clib;<br />
{$ENDIF}<br />
</delphi><br />
<br />
<br />
'''Note''' that FPC provides an abstraction for ioperm called "fpioperm" in [[doc:rtl/x86/index.html|unit x86]], and also defines out and inport functions. These functions are currently implemented for Linux/x86 and FreeBSD/x86.<br />
<br />
It is not recommended to link to libc unless absolutely necessary due to possible deployment and portability functions.<br />
Also manual linking to libc (by declaring ad hoc libc imports for functions that are available elsewhere) like done above is not recommended (e.g. the above libc import line will unnecessarily fail if the standard C lib is not called libc, like e.g. libroot on BeOS, or on platforms with a non standard C symbol mangling).<br />
<br />
'''Note 2''' Using _unit_ libc is not recommended under any circumstances other than Kylix compability. This because the unit is relatively unportable (due to excessive exposure of structures and other private symbols) and must only be modified as little as possible out of Kylix compability issues.<br />
<br />
==Serial Communication==<br />
<br />
It is very easy to build a serial communication software using the [http://synapse.ararat.cz/doku.php Synaser library]. The example when used together with the [http://synapse.ararat.cz/doc/help/synaser.html Synaser documentation] should be trivial to understand. The most important part is TBlockSerial.Config to configure the speed (in bits per second), data bits, parity bits, stop bits and handshake protocol, if any. The following code was tested with a serial mouse connected to COM 1.<br />
<br />
<delphi><br />
program comm;<br />
<br />
{$apptype console}<br />
<br />
uses<br />
Classes, SysUtils, Synaser;<br />
<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('COM1');<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
while True do<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
finally<br />
ser.free;<br />
end;<br />
end.<br />
</delphi><br />
<br />
The following code-example is an alternative version of the example above. The example above seems to have a critically fault in its main concept, to be exactly, it is the part with "while true do...". On the Test - System (Asus A6T Laptop with Digitus USB to RS232 Adapter, Ubuntu 8.04.1), this part caused the following error: The application ran only one time successfully per session, when the application was started again, the application was unable to connect to the serial port. Thus, a reboot was necessary everytime the user tried to relaunch the application, which is/was a really annoying bug. <br />
<br />
The reason is not difficult to understand: The application is in the while true do - loop, which is, to be more precisely, an endless loop. There is no abort-condition, so the only way to close the application is to close the terminal or to press CTRL-C. But if you quit the application this way, the important part with "ser.free", which frees the serial port, will never be called. This problem is described in the following thread in the German Lazarus-Forum [http://www.lazarusforum.de/viewtopic.php?f=10&t=2082 http://www.lazarusforum.de/viewtopic.php?f=10&t=2082]<br />
<br />
There is a bit code around the main application to make every user clear, not to press CTRL-C. If anyone is worrying, why /dev/ttyUSB0 is used for com-port: this is due to the USB to Serial Adapter (from Digitus) on the test-system. If you have an built-in serial port, please use the 'Com0' - declaration like in the code - example above. <br />
<br />
<delphi><br />
<br />
program serialtest;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$IFDEF UNIX}{$IFDEF UseCThreads}<br />
cthreads,<br />
{$ENDIF}{$ENDIF}<br />
Classes,SysUtils,Synaser,Crt<br />
{ you can add units after this };<br />
<br />
var l:boolean;<br />
<br />
function check_affirmation():boolean;<br />
var k:string;<br />
begin<br />
Writeln('To quit the application please do NOT use CTRL-C! Instead, please press any key to quit the application! '+<br />
'Please confirm this notification before the application continues! '+<br />
'[0]=Quit, [1]=Confirm, please continue! ');<br />
Writeln('Your decision: ');<br />
Read(k);<br />
if StrtoInt(k) = 1 then<br />
begin<br />
check_affirmation:=true;<br />
Writeln('OK, application continues ...');<br />
end<br />
else<br />
begin<br />
check_affirmation:=false;<br />
Writeln('Abort');<br />
end<br />
end;<br />
<br />
procedure RS232_connect;<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('/dev/ttyUSB0'); //ComPort<br />
Sleep(1000);<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
Write('Device: ' + ser.Device + ' Status: ' + ser.LastErrorDesc +' '+<br />
Inttostr(ser.LastError));<br />
Sleep(1000);<br />
repeat<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
until keypressed; //Important!!!<br />
finally<br />
Writeln('Serial Port will be freed...');<br />
ser.free;<br />
Writeln('Serial Port was freed successfully!');<br />
end;<br />
end;<br />
<br />
begin<br />
l:=check_affirmation();<br />
if l=true then<br />
RS232_connect()<br />
else<br />
Writeln('Program quit! ');<br />
end.<br />
<br />
</delphi><br />
<br />
Also, the [[Hardware Access#External Links | External Links]] section has UNIX and Windows serial port tutorials.<br />
<br />
==USB==<br />
<br />
===libusb===<br />
<br />
A cross platform possibility for Linux, BSDs and Mac OS X is [http://libusb.sourceforge.net/ libusb].<br />
<br />
Headers are listed in http://www.freepascal.org/contrib/db.php3?category=Miscellaneous:<br />
<br />
{|cellpadding="4"<br />
|-<br />
! name !! author !! version !! date !! link !! remarks<br />
|-<br />
| libusb.pp || nowrap | Uwe Zimmermann || 0.1.12 || nowrap | 2006-06-29 || http://www.sciencetronics.com/download/fpc_libusb.tgz || <br />
|-<br />
| libusb.pas || Johann Glaser || || nowrap | 2005-01-14 || http://www.johann-glaser.at/projects/libusb.pas || <br />
|-<br />
| fpcusb || Joe Jared || 0.11-14 || nowrap | 2006-02-02 || http://relays.osirusoft.com/fpcusb.tgz || nowrap | download link broken<br />
|}<br />
<br />
===FTDI===<br />
<br />
If you use one of the chips from [http://www.ftdichip.com/ FTDI], you can use their pascal headers for their dll interface to the chips.<br />
<br />
==External Links==<br />
<br />
Communication Protocols speed comparison:<br />
<br />
# http://en.wikipedia.org/wiki/Serial_port#Speed<br />
# http://www.lvr.com/jansfaq.htm - Jan Axelson's Parallel Port FAQ<br />
# http://en.wikipedia.org/wiki/USB#Transfer_Speed<br />
# http://en.wikipedia.org/wiki/PCI#Conventional_PCI_bus_specifications<br />
<br />
Serial Communication Links:<br />
<br />
# On UNIX: [http://www.easysw.com/~mike/serial/serial.html]<br />
# On Windows: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp<br />
# Synaser component: http://synapse.ararat.cz/<br />
# Comport Delphi package: http://sourceforge.net/projects/comport/<br />
<br />
ISA Digital Oscilloscope - A example of hardware access with full source included:<br />
<br />
[http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/]<br />
<br />
----<br />
[[Networking]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Hardware_Access/ko&diff=32328Hardware Access/ko2008-11-27T02:05:52Z<p>Oranke: /* Parallel and Serial Comparison */</p>
<hr />
<div>{{Hardware Access}}<br />
__TOC__<br />
==개관==<br />
이 페이지는 라자루스상에서 하드웨어 장치(디바이스)에 접근하기위한 뉴토리얼의 시작입니다. 이 장치들은 ISA, PCI, USB, parallel port, serial port 등을 포함하지만 이것들에 제한된것은 아닙니다.<br />
완전한 멀티 플랫폼상에서 하드웨어에 접근하는 것은 프리파스칼 라이브러리나 LCL에의해 구현되지는 않았으므로 이 튜토리얼은 다른 플랫폼상에서의 기초적인 하드웨어 접근 방법을 다룰 것 입니다. 조건적인 컴파일에 의해 다른 플랫폼에서 컴파일된 코드는 다음과 같을 것이다:<br />
<delphi><br />
uses<br />
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,<br />
{$IFDEF WIN32}<br />
Windows;<br />
{$ENDIF}<br />
{$IFDEF Unix}<br />
ports;<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 시점에서 Mac OX/x86이 HW 접근을 허용하는지는 아직 확실치는 않다. 이 경우에서는 내가 가정하듯이 위의 방법이 허용되지 않을 수 있지만 곧 io.dll같은 드라이버가 나타날 것이다.<br />
<br />
==패러랠과 시리얼 의 비교==<br />
ISA카드, PCI 카드 및 패러랠 포트는 '''parallel''' 프로토콜에 의해 컴퓨터와 통신을 한다. 시리얼 포트와 USB장치는 '''serial''' 프로토콜로 통신한다. 프로세서와 프로그래밍 언어는 모두 데이터에 패러랠한 접근을 통해 작업을 수행하기 때문에 이런 종류의 프로토콜에 대한 접근은 소프트웨어 측면에서 보면 구현하기가 더 쉽다.예를 들어, Integer 변수에 접근할 때, 단일 명령으로 그 값에 접근할 수가 있다. 그러나 시리얼 포트 프로토콜에서는 동시에 한개의 비트만을 알 수 밖에 없으며 데이터를 이해하기 위해서는 그 비트 조각들을 붙여 놓을 필요가 있다.<br />
<br />
시리얼 툥신은 직접적으로 구현하기가 어렵지만, 미리 만들어 놓은(pre-made) 컴포넌트를 사용한다면 매우 쉽게 구현할 수가 있다.이는 하드웨어 측면에서도 역시 어려운건 마찬가지이기 때문에 많은 장치들은 그것을 구현하기 위해 특별한 통합 써킷이나 마이크로 컨트롤러를 사용한다.<br />
<br />
이제 다음에 하드웨어 접근 프로토콜에 대한 간략한 비교가 있다:<br />
<br />
{| border=2 width="100%"<br />
<br />
|-<br />
!<br />
! 속도<br />
! 하드웨어 구현의 난이도<br />
<br />
|-<br />
! 시리얼 포트<br />
| align="center" | 매우 느림 (< E5 bit/s)<br />
| align="center" | 중간<br />
<br />
|-<br />
! 패러랠 포트<br />
| align="center" | 느림 (~ E6 bit/s)<br />
| align="center" | 쉬움<br />
<br />
|-<br />
<br />
! ISA 카드<br />
| align="center" | 중간(~ E7 bit/s)<br />
| align="center" | 중간<br />
<br />
|-<br />
! USB<br />
| align="center" | 중간(~ E7 bit/s)<br />
| align="center" | 어려움<br />
<br />
|-<br />
! PCI 카드<br />
| align="center" | 매우 빠름 (> E9 bit/s)<br />
| align="center" | 매우 어려움<br />
<br />
|}<br />
<br />
==Parallel Communication==<br />
<br />
===Using inpout32.dll for Windows===<br />
Windows has different ways to access hardware devices on the 9x series and on the NT series. On the 9x series (95, 98, Me) programs can access the hardware directly, just like they did on DOS. The NT series (Windows NT and XP), however, don't allow this approach. On this architecture, all communication with hardware ports must be throught a device driver. This is a security mechanism, but developing a driver can cost too much in terms of time and money for small projects.<br />
<br />
Happily there is a library that solves this problem. If Windows NT is detected, it decompresses HWInterface.sys kernel device driver and installs it. If Windows 9x is detected, it simply uses assembler opcodes to access the hardware.<br />
<br />
But how do I use the library? Simple! It has only two functions, Inp32 and Out32, and their use is quite intuitive.<br />
<br />
We will load the library dynamically, so let's define both functions first:<br />
<br />
<delphi><br />
type<br />
TInp32 = function(Address: SmallInt): SmallInt; stdcall;<br />
TOut32 = procedure(Address: SmallInt; Data: SmallInt); stdcall;<br />
</delphi><br />
<br />
* Address represents the address of the port you desire to access<br />
* Out32 sends Data to the port you specify by Address<br />
* Inp32 returns a byte from the port you specify by Address<br />
<br />
Now we can load the library. This can be implemented in a place like the OnCreate method of your program's main form:<br />
<br />
<delphi><br />
type<br />
TMyForm = class(TForm)<br />
.........<br />
private<br />
{ private declarations }<br />
Inpout32: THandle;<br />
Inp32: TInp32;<br />
Out32: TOut32;<br />
.........<br />
implementation<br />
.........<br />
procedure TMyForm.FormCreate(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
Inpout32 := LoadLibrary('inpout32.dll');<br />
if (Inpout32 <> 0) then<br />
begin<br />
// needs overtyping, plain Delphi's @Inp32 = GetProc... leads to compile errors<br />
Inp32 := TInp32(GetProcAddress(Inpout32, 'Inp32'));<br />
if (@Inp32 = nil) then Caption := 'Error';<br />
Out32 := TOut32(GetProcAddress(Inpout32, 'Out32'));<br />
if (@Out32 = nil) then Caption := 'Error';<br />
end<br />
else Caption := 'Error';<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
If you load the library on OnCreate just don't forget to unload it in OnDestroy:<br />
<br />
<delphi><br />
procedure TMyForm.FormDestroy(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
FreeLibrary(Inpout32);<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
Here is a simple example of how to use Inp32 function:<br />
<br />
<delphi><br />
{$IFDEF WIN32}<br />
myLabel.Caption := IntToStr(Inp32($0220));<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Windows XP. Of course you will need to have Windows on your uses clause in order for this code to run. For deployment you only need to include "inpout32.dll" in the same directory of our application.<br />
<br />
This is the homepage for the library: [http://www.logix4u.net/inpout32.htm www.logix4u.net/inpout32.htm] *see discussion*<br />
<br />
===Using assembler on Windows 9x===<br />
<br />
On Windows 9x you can also use assembler code. Suppose you wish to write $CC to the $320 port. The following code will do it:<br />
<br />
<delphi><br />
{$ASMMODE ATT}<br />
...<br />
asm<br />
movl $0x320, %edx<br />
movb $0xCC, %al<br />
outb %al, %dx<br />
end ['EAX','EDX'];<br />
</delphi><br />
<br />
===Troubleshooting on Windows===<br />
<br />
One possible source of trouble using parallel hardware that does not support Plug And Play on Windows is that Windows may assign the port utilized by your hardware to another device. You can find instructions on the URL below about how to tell Windows not to assign the address of your device to Plug And Play devices:<br />
<br />
http://support.microsoft.com/kb/135168<br />
<br />
===Using ioperm to access ports on Linux===<br />
<br />
The best way to access the hardware on Linux is throught device drivers, but, due to the complexity of the task of creating a driver, sometimes a quick method is very useful.<br />
<br />
In order to use the "[[doc:rtl/ports|ports]]" unit under Linux your program must be run as root, and IOPerm must be called to set appropriate permissions on the port access. You can find documentation about the "[[doc:rtl/ports|ports]]" unit [http://www.freepascal.org/docs-html/rtl/ports/index.html here].<br />
<br />
The first thing to do is link to (g)libc and call IOPerm. A unit that links to the entire (g)libc exists on free pascal, but this unit gives problems when used directly by application and linking statically to the entire (g)libc library is not a very good idea because it changes often between version in an incompatible manner. Functions like ioperm, however, are unlikely to change.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external 'libc';<br />
{$ENDIF}<br />
</delphi><br />
<br />
* "from" represents the first port to be accessed.<br />
* "num" is the number of ports after the first to be accessed, so ioperm($220, 8, 1) will give access for the program for all ports between and including $220 and $227.<br />
<br />
After linking to IOPerm you can port[<Address>] to access the ports.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
i := ioperm($220, 8, 1);<br />
port[$220] := $00;<br />
myLabel.Caption := 'ioperm: ' + IntToStr(i);<br />
i := Integer(port[$220]);<br />
myOtherLabel.Caption := 'response: ' + IntToStr(i);<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Mandriva Linux 2005 and Damn Small Linux 1.5<br />
<br />
===General UNIX Hardware Access===<br />
<br />
<delphi><br />
{$IFDEF Unix}<br />
Uses Clib; // retrieve libc library name.<br />
{$ENDIF}<br />
<br />
{$IFDEF Unix}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external clib;<br />
{$ENDIF}<br />
</delphi><br />
<br />
<br />
'''Note''' that FPC provides an abstraction for ioperm called "fpioperm" in [[doc:rtl/x86/index.html|unit x86]], and also defines out and inport functions. These functions are currently implemented for Linux/x86 and FreeBSD/x86.<br />
<br />
It is not recommended to link to libc unless absolutely necessary due to possible deployment and portability functions.<br />
Also manual linking to libc (by declaring ad hoc libc imports for functions that are available elsewhere) like done above is not recommended (e.g. the above libc import line will unnecessarily fail if the standard C lib is not called libc, like e.g. libroot on BeOS, or on platforms with a non standard C symbol mangling).<br />
<br />
'''Note 2''' Using _unit_ libc is not recommended under any circumstances other than Kylix compability. This because the unit is relatively unportable (due to excessive exposure of structures and other private symbols) and must only be modified as little as possible out of Kylix compability issues.<br />
<br />
==Serial Communication==<br />
<br />
It is very easy to build a serial communication software using the [http://synapse.ararat.cz/doku.php Synaser library]. The example when used together with the [http://synapse.ararat.cz/doc/help/synaser.html Synaser documentation] should be trivial to understand. The most important part is TBlockSerial.Config to configure the speed (in bits per second), data bits, parity bits, stop bits and handshake protocol, if any. The following code was tested with a serial mouse connected to COM 1.<br />
<br />
<delphi><br />
program comm;<br />
<br />
{$apptype console}<br />
<br />
uses<br />
Classes, SysUtils, Synaser;<br />
<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('COM1');<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
while True do<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
finally<br />
ser.free;<br />
end;<br />
end.<br />
</delphi><br />
<br />
The following code-example is an alternative version of the example above. The example above seems to have a critically fault in its main concept, to be exactly, it is the part with "while true do...". On the Test - System (Asus A6T Laptop with Digitus USB to RS232 Adapter, Ubuntu 8.04.1), this part caused the following error: The application ran only one time successfully per session, when the application was started again, the application was unable to connect to the serial port. Thus, a reboot was necessary everytime the user tried to relaunch the application, which is/was a really annoying bug. <br />
<br />
The reason is not difficult to understand: The application is in the while true do - loop, which is, to be more precisely, an endless loop. There is no abort-condition, so the only way to close the application is to close the terminal or to press CTRL-C. But if you quit the application this way, the important part with "ser.free", which frees the serial port, will never be called. This problem is described in the following thread in the German Lazarus-Forum [http://www.lazarusforum.de/viewtopic.php?f=10&t=2082 http://www.lazarusforum.de/viewtopic.php?f=10&t=2082]<br />
<br />
There is a bit code around the main application to make every user clear, not to press CTRL-C. If anyone is worrying, why /dev/ttyUSB0 is used for com-port: this is due to the USB to Serial Adapter (from Digitus) on the test-system. If you have an built-in serial port, please use the 'Com0' - declaration like in the code - example above. <br />
<br />
<delphi><br />
<br />
program serialtest;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$IFDEF UNIX}{$IFDEF UseCThreads}<br />
cthreads,<br />
{$ENDIF}{$ENDIF}<br />
Classes,SysUtils,Synaser,Crt<br />
{ you can add units after this };<br />
<br />
var l:boolean;<br />
<br />
function check_affirmation():boolean;<br />
var k:string;<br />
begin<br />
Writeln('To quit the application please do NOT use CTRL-C! Instead, please press any key to quit the application! '+<br />
'Please confirm this notification before the application continues! '+<br />
'[0]=Quit, [1]=Confirm, please continue! ');<br />
Writeln('Your decision: ');<br />
Read(k);<br />
if StrtoInt(k) = 1 then<br />
begin<br />
check_affirmation:=true;<br />
Writeln('OK, application continues ...');<br />
end<br />
else<br />
begin<br />
check_affirmation:=false;<br />
Writeln('Abort');<br />
end<br />
end;<br />
<br />
procedure RS232_connect;<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('/dev/ttyUSB0'); //ComPort<br />
Sleep(1000);<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
Write('Device: ' + ser.Device + ' Status: ' + ser.LastErrorDesc +' '+<br />
Inttostr(ser.LastError));<br />
Sleep(1000);<br />
repeat<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
until keypressed; //Important!!!<br />
finally<br />
Writeln('Serial Port will be freed...');<br />
ser.free;<br />
Writeln('Serial Port was freed successfully!');<br />
end;<br />
end;<br />
<br />
begin<br />
l:=check_affirmation();<br />
if l=true then<br />
RS232_connect()<br />
else<br />
Writeln('Program quit! ');<br />
end.<br />
<br />
</delphi><br />
<br />
Also, the [[Hardware Access#External Links | External Links]] section has UNIX and Windows serial port tutorials.<br />
<br />
==USB==<br />
<br />
===libusb===<br />
<br />
A cross platform possibility for Linux, BSDs and Mac OS X is [http://libusb.sourceforge.net/ libusb].<br />
<br />
Headers are listed in http://www.freepascal.org/contrib/db.php3?category=Miscellaneous:<br />
<br />
{|cellpadding="4"<br />
|-<br />
! name !! author !! version !! date !! link !! remarks<br />
|-<br />
| libusb.pp || nowrap | Uwe Zimmermann || 0.1.12 || nowrap | 2006-06-29 || http://www.sciencetronics.com/download/fpc_libusb.tgz || <br />
|-<br />
| libusb.pas || Johann Glaser || || nowrap | 2005-01-14 || http://www.johann-glaser.at/projects/libusb.pas || <br />
|-<br />
| fpcusb || Joe Jared || 0.11-14 || nowrap | 2006-02-02 || http://relays.osirusoft.com/fpcusb.tgz || nowrap | download link broken<br />
|}<br />
<br />
===FTDI===<br />
<br />
If you use one of the chips from [http://www.ftdichip.com/ FTDI], you can use their pascal headers for their dll interface to the chips.<br />
<br />
==External Links==<br />
<br />
Communication Protocols speed comparison:<br />
<br />
# http://en.wikipedia.org/wiki/Serial_port#Speed<br />
# http://www.lvr.com/jansfaq.htm - Jan Axelson's Parallel Port FAQ<br />
# http://en.wikipedia.org/wiki/USB#Transfer_Speed<br />
# http://en.wikipedia.org/wiki/PCI#Conventional_PCI_bus_specifications<br />
<br />
Serial Communication Links:<br />
<br />
# On UNIX: [http://www.easysw.com/~mike/serial/serial.html]<br />
# On Windows: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp<br />
# Synaser component: http://synapse.ararat.cz/<br />
# Comport Delphi package: http://sourceforge.net/projects/comport/<br />
<br />
ISA Digital Oscilloscope - A example of hardware access with full source included:<br />
<br />
[http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/]<br />
<br />
----<br />
[[Networking]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Hardware_Access/ko&diff=32327Hardware Access/ko2008-11-27T02:04:49Z<p>Oranke: /* Overview */</p>
<hr />
<div>{{Hardware Access}}<br />
__TOC__<br />
==개관==<br />
이 페이지는 라자루스상에서 하드웨어 장치(디바이스)에 접근하기위한 뉴토리얼의 시작입니다. 이 장치들은 ISA, PCI, USB, parallel port, serial port 등을 포함하지만 이것들에 제한된것은 아닙니다.<br />
완전한 멀티 플랫폼상에서 하드웨어에 접근하는 것은 프리파스칼 라이브러리나 LCL에의해 구현되지는 않았으므로 이 튜토리얼은 다른 플랫폼상에서의 기초적인 하드웨어 접근 방법을 다룰 것 입니다. 조건적인 컴파일에 의해 다른 플랫폼에서 컴파일된 코드는 다음과 같을 것이다:<br />
<delphi><br />
uses<br />
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,<br />
{$IFDEF WIN32}<br />
Windows;<br />
{$ENDIF}<br />
{$IFDEF Unix}<br />
ports;<br />
{$ENDIF}<br />
</delphi><br />
<br />
이 시점에서 Mac OX/x86이 HW 접근을 허용하는지는 아직 확실치는 않다. 이 경우에서는 내가 가정하듯이 위의 방법이 허용되지 않을 수 있지만 곧 io.dll같은 드라이버가 나타날 것이다.<br />
<br />
==Parallel and Serial Comparison==<br />
ISA Cards, PCI Cards and the Parallel Port communicate with the computer using a '''parallel''' protocol. The Serial Port and USB devices work with a '''serial''' protocol. Because the processor and thus programming languages all work on a parallel approach to data, access to this kinds of protocols is easier to be implemented on the software side. When you access an Integer variable, for example, you can access it's value with a single command. With a serial protocol, however, you can only know one bit at a time, and you need to glue the pieces together to understand the data.<br />
<br />
Serial communication is difficult to be implemented directly, but it can be pretty easy if you use a pre-made component. It is also harder on the hardware side, so many devices use specialised Integrated Circuits or even Microcontrolers to implement it.<br />
<br />
Now a brief comparison of hardware access protocols will be given:<br />
<br />
{| border=2 width="100%"<br />
<br />
|-<br />
!<br />
! Speed<br />
! Hardware implementation difficulty<br />
<br />
|-<br />
! Serial Port<br />
| align="center" | Very slow (< E5 bit/s)<br />
| align="center" | Medium<br />
<br />
|-<br />
! Parallel Port<br />
| align="center" | Slow (~ E6 bit/s)<br />
| align="center" | Easy<br />
<br />
|-<br />
<br />
! ISA Card<br />
| align="center" | Medium (~ E7 bit/s)<br />
| align="center" | Medium<br />
<br />
|-<br />
! USB<br />
| align="center" | Medium (~ E7 bit/s)<br />
| align="center" | Hard<br />
<br />
|-<br />
! PCI Card<br />
| align="center" | Very Fast (> E9 bit/s)<br />
| align="center" | Very Hard<br />
<br />
|}<br />
<br />
==Parallel Communication==<br />
<br />
===Using inpout32.dll for Windows===<br />
Windows has different ways to access hardware devices on the 9x series and on the NT series. On the 9x series (95, 98, Me) programs can access the hardware directly, just like they did on DOS. The NT series (Windows NT and XP), however, don't allow this approach. On this architecture, all communication with hardware ports must be throught a device driver. This is a security mechanism, but developing a driver can cost too much in terms of time and money for small projects.<br />
<br />
Happily there is a library that solves this problem. If Windows NT is detected, it decompresses HWInterface.sys kernel device driver and installs it. If Windows 9x is detected, it simply uses assembler opcodes to access the hardware.<br />
<br />
But how do I use the library? Simple! It has only two functions, Inp32 and Out32, and their use is quite intuitive.<br />
<br />
We will load the library dynamically, so let's define both functions first:<br />
<br />
<delphi><br />
type<br />
TInp32 = function(Address: SmallInt): SmallInt; stdcall;<br />
TOut32 = procedure(Address: SmallInt; Data: SmallInt); stdcall;<br />
</delphi><br />
<br />
* Address represents the address of the port you desire to access<br />
* Out32 sends Data to the port you specify by Address<br />
* Inp32 returns a byte from the port you specify by Address<br />
<br />
Now we can load the library. This can be implemented in a place like the OnCreate method of your program's main form:<br />
<br />
<delphi><br />
type<br />
TMyForm = class(TForm)<br />
.........<br />
private<br />
{ private declarations }<br />
Inpout32: THandle;<br />
Inp32: TInp32;<br />
Out32: TOut32;<br />
.........<br />
implementation<br />
.........<br />
procedure TMyForm.FormCreate(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
Inpout32 := LoadLibrary('inpout32.dll');<br />
if (Inpout32 <> 0) then<br />
begin<br />
// needs overtyping, plain Delphi's @Inp32 = GetProc... leads to compile errors<br />
Inp32 := TInp32(GetProcAddress(Inpout32, 'Inp32'));<br />
if (@Inp32 = nil) then Caption := 'Error';<br />
Out32 := TOut32(GetProcAddress(Inpout32, 'Out32'));<br />
if (@Out32 = nil) then Caption := 'Error';<br />
end<br />
else Caption := 'Error';<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
If you load the library on OnCreate just don't forget to unload it in OnDestroy:<br />
<br />
<delphi><br />
procedure TMyForm.FormDestroy(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
FreeLibrary(Inpout32);<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
Here is a simple example of how to use Inp32 function:<br />
<br />
<delphi><br />
{$IFDEF WIN32}<br />
myLabel.Caption := IntToStr(Inp32($0220));<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Windows XP. Of course you will need to have Windows on your uses clause in order for this code to run. For deployment you only need to include "inpout32.dll" in the same directory of our application.<br />
<br />
This is the homepage for the library: [http://www.logix4u.net/inpout32.htm www.logix4u.net/inpout32.htm] *see discussion*<br />
<br />
===Using assembler on Windows 9x===<br />
<br />
On Windows 9x you can also use assembler code. Suppose you wish to write $CC to the $320 port. The following code will do it:<br />
<br />
<delphi><br />
{$ASMMODE ATT}<br />
...<br />
asm<br />
movl $0x320, %edx<br />
movb $0xCC, %al<br />
outb %al, %dx<br />
end ['EAX','EDX'];<br />
</delphi><br />
<br />
===Troubleshooting on Windows===<br />
<br />
One possible source of trouble using parallel hardware that does not support Plug And Play on Windows is that Windows may assign the port utilized by your hardware to another device. You can find instructions on the URL below about how to tell Windows not to assign the address of your device to Plug And Play devices:<br />
<br />
http://support.microsoft.com/kb/135168<br />
<br />
===Using ioperm to access ports on Linux===<br />
<br />
The best way to access the hardware on Linux is throught device drivers, but, due to the complexity of the task of creating a driver, sometimes a quick method is very useful.<br />
<br />
In order to use the "[[doc:rtl/ports|ports]]" unit under Linux your program must be run as root, and IOPerm must be called to set appropriate permissions on the port access. You can find documentation about the "[[doc:rtl/ports|ports]]" unit [http://www.freepascal.org/docs-html/rtl/ports/index.html here].<br />
<br />
The first thing to do is link to (g)libc and call IOPerm. A unit that links to the entire (g)libc exists on free pascal, but this unit gives problems when used directly by application and linking statically to the entire (g)libc library is not a very good idea because it changes often between version in an incompatible manner. Functions like ioperm, however, are unlikely to change.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external 'libc';<br />
{$ENDIF}<br />
</delphi><br />
<br />
* "from" represents the first port to be accessed.<br />
* "num" is the number of ports after the first to be accessed, so ioperm($220, 8, 1) will give access for the program for all ports between and including $220 and $227.<br />
<br />
After linking to IOPerm you can port[<Address>] to access the ports.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
i := ioperm($220, 8, 1);<br />
port[$220] := $00;<br />
myLabel.Caption := 'ioperm: ' + IntToStr(i);<br />
i := Integer(port[$220]);<br />
myOtherLabel.Caption := 'response: ' + IntToStr(i);<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Mandriva Linux 2005 and Damn Small Linux 1.5<br />
<br />
===General UNIX Hardware Access===<br />
<br />
<delphi><br />
{$IFDEF Unix}<br />
Uses Clib; // retrieve libc library name.<br />
{$ENDIF}<br />
<br />
{$IFDEF Unix}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external clib;<br />
{$ENDIF}<br />
</delphi><br />
<br />
<br />
'''Note''' that FPC provides an abstraction for ioperm called "fpioperm" in [[doc:rtl/x86/index.html|unit x86]], and also defines out and inport functions. These functions are currently implemented for Linux/x86 and FreeBSD/x86.<br />
<br />
It is not recommended to link to libc unless absolutely necessary due to possible deployment and portability functions.<br />
Also manual linking to libc (by declaring ad hoc libc imports for functions that are available elsewhere) like done above is not recommended (e.g. the above libc import line will unnecessarily fail if the standard C lib is not called libc, like e.g. libroot on BeOS, or on platforms with a non standard C symbol mangling).<br />
<br />
'''Note 2''' Using _unit_ libc is not recommended under any circumstances other than Kylix compability. This because the unit is relatively unportable (due to excessive exposure of structures and other private symbols) and must only be modified as little as possible out of Kylix compability issues.<br />
<br />
==Serial Communication==<br />
<br />
It is very easy to build a serial communication software using the [http://synapse.ararat.cz/doku.php Synaser library]. The example when used together with the [http://synapse.ararat.cz/doc/help/synaser.html Synaser documentation] should be trivial to understand. The most important part is TBlockSerial.Config to configure the speed (in bits per second), data bits, parity bits, stop bits and handshake protocol, if any. The following code was tested with a serial mouse connected to COM 1.<br />
<br />
<delphi><br />
program comm;<br />
<br />
{$apptype console}<br />
<br />
uses<br />
Classes, SysUtils, Synaser;<br />
<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('COM1');<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
while True do<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
finally<br />
ser.free;<br />
end;<br />
end.<br />
</delphi><br />
<br />
The following code-example is an alternative version of the example above. The example above seems to have a critically fault in its main concept, to be exactly, it is the part with "while true do...". On the Test - System (Asus A6T Laptop with Digitus USB to RS232 Adapter, Ubuntu 8.04.1), this part caused the following error: The application ran only one time successfully per session, when the application was started again, the application was unable to connect to the serial port. Thus, a reboot was necessary everytime the user tried to relaunch the application, which is/was a really annoying bug. <br />
<br />
The reason is not difficult to understand: The application is in the while true do - loop, which is, to be more precisely, an endless loop. There is no abort-condition, so the only way to close the application is to close the terminal or to press CTRL-C. But if you quit the application this way, the important part with "ser.free", which frees the serial port, will never be called. This problem is described in the following thread in the German Lazarus-Forum [http://www.lazarusforum.de/viewtopic.php?f=10&t=2082 http://www.lazarusforum.de/viewtopic.php?f=10&t=2082]<br />
<br />
There is a bit code around the main application to make every user clear, not to press CTRL-C. If anyone is worrying, why /dev/ttyUSB0 is used for com-port: this is due to the USB to Serial Adapter (from Digitus) on the test-system. If you have an built-in serial port, please use the 'Com0' - declaration like in the code - example above. <br />
<br />
<delphi><br />
<br />
program serialtest;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$IFDEF UNIX}{$IFDEF UseCThreads}<br />
cthreads,<br />
{$ENDIF}{$ENDIF}<br />
Classes,SysUtils,Synaser,Crt<br />
{ you can add units after this };<br />
<br />
var l:boolean;<br />
<br />
function check_affirmation():boolean;<br />
var k:string;<br />
begin<br />
Writeln('To quit the application please do NOT use CTRL-C! Instead, please press any key to quit the application! '+<br />
'Please confirm this notification before the application continues! '+<br />
'[0]=Quit, [1]=Confirm, please continue! ');<br />
Writeln('Your decision: ');<br />
Read(k);<br />
if StrtoInt(k) = 1 then<br />
begin<br />
check_affirmation:=true;<br />
Writeln('OK, application continues ...');<br />
end<br />
else<br />
begin<br />
check_affirmation:=false;<br />
Writeln('Abort');<br />
end<br />
end;<br />
<br />
procedure RS232_connect;<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('/dev/ttyUSB0'); //ComPort<br />
Sleep(1000);<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
Write('Device: ' + ser.Device + ' Status: ' + ser.LastErrorDesc +' '+<br />
Inttostr(ser.LastError));<br />
Sleep(1000);<br />
repeat<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
until keypressed; //Important!!!<br />
finally<br />
Writeln('Serial Port will be freed...');<br />
ser.free;<br />
Writeln('Serial Port was freed successfully!');<br />
end;<br />
end;<br />
<br />
begin<br />
l:=check_affirmation();<br />
if l=true then<br />
RS232_connect()<br />
else<br />
Writeln('Program quit! ');<br />
end.<br />
<br />
</delphi><br />
<br />
Also, the [[Hardware Access#External Links | External Links]] section has UNIX and Windows serial port tutorials.<br />
<br />
==USB==<br />
<br />
===libusb===<br />
<br />
A cross platform possibility for Linux, BSDs and Mac OS X is [http://libusb.sourceforge.net/ libusb].<br />
<br />
Headers are listed in http://www.freepascal.org/contrib/db.php3?category=Miscellaneous:<br />
<br />
{|cellpadding="4"<br />
|-<br />
! name !! author !! version !! date !! link !! remarks<br />
|-<br />
| libusb.pp || nowrap | Uwe Zimmermann || 0.1.12 || nowrap | 2006-06-29 || http://www.sciencetronics.com/download/fpc_libusb.tgz || <br />
|-<br />
| libusb.pas || Johann Glaser || || nowrap | 2005-01-14 || http://www.johann-glaser.at/projects/libusb.pas || <br />
|-<br />
| fpcusb || Joe Jared || 0.11-14 || nowrap | 2006-02-02 || http://relays.osirusoft.com/fpcusb.tgz || nowrap | download link broken<br />
|}<br />
<br />
===FTDI===<br />
<br />
If you use one of the chips from [http://www.ftdichip.com/ FTDI], you can use their pascal headers for their dll interface to the chips.<br />
<br />
==External Links==<br />
<br />
Communication Protocols speed comparison:<br />
<br />
# http://en.wikipedia.org/wiki/Serial_port#Speed<br />
# http://www.lvr.com/jansfaq.htm - Jan Axelson's Parallel Port FAQ<br />
# http://en.wikipedia.org/wiki/USB#Transfer_Speed<br />
# http://en.wikipedia.org/wiki/PCI#Conventional_PCI_bus_specifications<br />
<br />
Serial Communication Links:<br />
<br />
# On UNIX: [http://www.easysw.com/~mike/serial/serial.html]<br />
# On Windows: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp<br />
# Synaser component: http://synapse.ararat.cz/<br />
# Comport Delphi package: http://sourceforge.net/projects/comport/<br />
<br />
ISA Digital Oscilloscope - A example of hardware access with full source included:<br />
<br />
[http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/]<br />
<br />
----<br />
[[Networking]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Hardware_Access/ko&diff=32326Hardware Access/ko2008-11-27T02:03:29Z<p>Oranke: New page: {{Hardware Access}} __TOC__ ==Overview== This page is the start of a tutorial about accessing hardware devices on Lazarus. These devices include, but are not limited to: ISA, PCI, USB, par...</p>
<hr />
<div>{{Hardware Access}}<br />
__TOC__<br />
==Overview==<br />
This page is the start of a tutorial about accessing hardware devices on Lazarus. These devices include, but are not limited to: ISA, PCI, USB, parallel port, serial port.<br />
<br />
Access to hardware devices on a completely multi-platform way is not implemented by Free Pascal Runtime Library or by the LCL, so this tutorial will basically cover hardware access methods on different platforms. The code can be compiled on different environments using conditional compiles, like this:<br />
<br />
<delphi><br />
uses<br />
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,<br />
{$IFDEF WIN32}<br />
Windows;<br />
{$ENDIF}<br />
{$IFDEF Unix}<br />
ports;<br />
{$ENDIF}<br />
</delphi><br />
<br />
It is not known yet, at this time, if Mac OS X/x86 will allow HW access. It can disallow it, though I assume in that case, in time, drivers like io.dll will appear.<br />
<br />
==Parallel and Serial Comparison==<br />
ISA Cards, PCI Cards and the Parallel Port communicate with the computer using a '''parallel''' protocol. The Serial Port and USB devices work with a '''serial''' protocol. Because the processor and thus programming languages all work on a parallel approach to data, access to this kinds of protocols is easier to be implemented on the software side. When you access an Integer variable, for example, you can access it's value with a single command. With a serial protocol, however, you can only know one bit at a time, and you need to glue the pieces together to understand the data.<br />
<br />
Serial communication is difficult to be implemented directly, but it can be pretty easy if you use a pre-made component. It is also harder on the hardware side, so many devices use specialised Integrated Circuits or even Microcontrolers to implement it.<br />
<br />
Now a brief comparison of hardware access protocols will be given:<br />
<br />
{| border=2 width="100%"<br />
<br />
|-<br />
!<br />
! Speed<br />
! Hardware implementation difficulty<br />
<br />
|-<br />
! Serial Port<br />
| align="center" | Very slow (< E5 bit/s)<br />
| align="center" | Medium<br />
<br />
|-<br />
! Parallel Port<br />
| align="center" | Slow (~ E6 bit/s)<br />
| align="center" | Easy<br />
<br />
|-<br />
<br />
! ISA Card<br />
| align="center" | Medium (~ E7 bit/s)<br />
| align="center" | Medium<br />
<br />
|-<br />
! USB<br />
| align="center" | Medium (~ E7 bit/s)<br />
| align="center" | Hard<br />
<br />
|-<br />
! PCI Card<br />
| align="center" | Very Fast (> E9 bit/s)<br />
| align="center" | Very Hard<br />
<br />
|}<br />
<br />
==Parallel Communication==<br />
<br />
===Using inpout32.dll for Windows===<br />
Windows has different ways to access hardware devices on the 9x series and on the NT series. On the 9x series (95, 98, Me) programs can access the hardware directly, just like they did on DOS. The NT series (Windows NT and XP), however, don't allow this approach. On this architecture, all communication with hardware ports must be throught a device driver. This is a security mechanism, but developing a driver can cost too much in terms of time and money for small projects.<br />
<br />
Happily there is a library that solves this problem. If Windows NT is detected, it decompresses HWInterface.sys kernel device driver and installs it. If Windows 9x is detected, it simply uses assembler opcodes to access the hardware.<br />
<br />
But how do I use the library? Simple! It has only two functions, Inp32 and Out32, and their use is quite intuitive.<br />
<br />
We will load the library dynamically, so let's define both functions first:<br />
<br />
<delphi><br />
type<br />
TInp32 = function(Address: SmallInt): SmallInt; stdcall;<br />
TOut32 = procedure(Address: SmallInt; Data: SmallInt); stdcall;<br />
</delphi><br />
<br />
* Address represents the address of the port you desire to access<br />
* Out32 sends Data to the port you specify by Address<br />
* Inp32 returns a byte from the port you specify by Address<br />
<br />
Now we can load the library. This can be implemented in a place like the OnCreate method of your program's main form:<br />
<br />
<delphi><br />
type<br />
TMyForm = class(TForm)<br />
.........<br />
private<br />
{ private declarations }<br />
Inpout32: THandle;<br />
Inp32: TInp32;<br />
Out32: TOut32;<br />
.........<br />
implementation<br />
.........<br />
procedure TMyForm.FormCreate(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
Inpout32 := LoadLibrary('inpout32.dll');<br />
if (Inpout32 <> 0) then<br />
begin<br />
// needs overtyping, plain Delphi's @Inp32 = GetProc... leads to compile errors<br />
Inp32 := TInp32(GetProcAddress(Inpout32, 'Inp32'));<br />
if (@Inp32 = nil) then Caption := 'Error';<br />
Out32 := TOut32(GetProcAddress(Inpout32, 'Out32'));<br />
if (@Out32 = nil) then Caption := 'Error';<br />
end<br />
else Caption := 'Error';<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
If you load the library on OnCreate just don't forget to unload it in OnDestroy:<br />
<br />
<delphi><br />
procedure TMyForm.FormDestroy(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
FreeLibrary(Inpout32);<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
Here is a simple example of how to use Inp32 function:<br />
<br />
<delphi><br />
{$IFDEF WIN32}<br />
myLabel.Caption := IntToStr(Inp32($0220));<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Windows XP. Of course you will need to have Windows on your uses clause in order for this code to run. For deployment you only need to include "inpout32.dll" in the same directory of our application.<br />
<br />
This is the homepage for the library: [http://www.logix4u.net/inpout32.htm www.logix4u.net/inpout32.htm] *see discussion*<br />
<br />
===Using assembler on Windows 9x===<br />
<br />
On Windows 9x you can also use assembler code. Suppose you wish to write $CC to the $320 port. The following code will do it:<br />
<br />
<delphi><br />
{$ASMMODE ATT}<br />
...<br />
asm<br />
movl $0x320, %edx<br />
movb $0xCC, %al<br />
outb %al, %dx<br />
end ['EAX','EDX'];<br />
</delphi><br />
<br />
===Troubleshooting on Windows===<br />
<br />
One possible source of trouble using parallel hardware that does not support Plug And Play on Windows is that Windows may assign the port utilized by your hardware to another device. You can find instructions on the URL below about how to tell Windows not to assign the address of your device to Plug And Play devices:<br />
<br />
http://support.microsoft.com/kb/135168<br />
<br />
===Using ioperm to access ports on Linux===<br />
<br />
The best way to access the hardware on Linux is throught device drivers, but, due to the complexity of the task of creating a driver, sometimes a quick method is very useful.<br />
<br />
In order to use the "[[doc:rtl/ports|ports]]" unit under Linux your program must be run as root, and IOPerm must be called to set appropriate permissions on the port access. You can find documentation about the "[[doc:rtl/ports|ports]]" unit [http://www.freepascal.org/docs-html/rtl/ports/index.html here].<br />
<br />
The first thing to do is link to (g)libc and call IOPerm. A unit that links to the entire (g)libc exists on free pascal, but this unit gives problems when used directly by application and linking statically to the entire (g)libc library is not a very good idea because it changes often between version in an incompatible manner. Functions like ioperm, however, are unlikely to change.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external 'libc';<br />
{$ENDIF}<br />
</delphi><br />
<br />
* "from" represents the first port to be accessed.<br />
* "num" is the number of ports after the first to be accessed, so ioperm($220, 8, 1) will give access for the program for all ports between and including $220 and $227.<br />
<br />
After linking to IOPerm you can port[<Address>] to access the ports.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
i := ioperm($220, 8, 1);<br />
port[$220] := $00;<br />
myLabel.Caption := 'ioperm: ' + IntToStr(i);<br />
i := Integer(port[$220]);<br />
myOtherLabel.Caption := 'response: ' + IntToStr(i);<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Mandriva Linux 2005 and Damn Small Linux 1.5<br />
<br />
===General UNIX Hardware Access===<br />
<br />
<delphi><br />
{$IFDEF Unix}<br />
Uses Clib; // retrieve libc library name.<br />
{$ENDIF}<br />
<br />
{$IFDEF Unix}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external clib;<br />
{$ENDIF}<br />
</delphi><br />
<br />
<br />
'''Note''' that FPC provides an abstraction for ioperm called "fpioperm" in [[doc:rtl/x86/index.html|unit x86]], and also defines out and inport functions. These functions are currently implemented for Linux/x86 and FreeBSD/x86.<br />
<br />
It is not recommended to link to libc unless absolutely necessary due to possible deployment and portability functions.<br />
Also manual linking to libc (by declaring ad hoc libc imports for functions that are available elsewhere) like done above is not recommended (e.g. the above libc import line will unnecessarily fail if the standard C lib is not called libc, like e.g. libroot on BeOS, or on platforms with a non standard C symbol mangling).<br />
<br />
'''Note 2''' Using _unit_ libc is not recommended under any circumstances other than Kylix compability. This because the unit is relatively unportable (due to excessive exposure of structures and other private symbols) and must only be modified as little as possible out of Kylix compability issues.<br />
<br />
==Serial Communication==<br />
<br />
It is very easy to build a serial communication software using the [http://synapse.ararat.cz/doku.php Synaser library]. The example when used together with the [http://synapse.ararat.cz/doc/help/synaser.html Synaser documentation] should be trivial to understand. The most important part is TBlockSerial.Config to configure the speed (in bits per second), data bits, parity bits, stop bits and handshake protocol, if any. The following code was tested with a serial mouse connected to COM 1.<br />
<br />
<delphi><br />
program comm;<br />
<br />
{$apptype console}<br />
<br />
uses<br />
Classes, SysUtils, Synaser;<br />
<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('COM1');<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
while True do<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
finally<br />
ser.free;<br />
end;<br />
end.<br />
</delphi><br />
<br />
The following code-example is an alternative version of the example above. The example above seems to have a critically fault in its main concept, to be exactly, it is the part with "while true do...". On the Test - System (Asus A6T Laptop with Digitus USB to RS232 Adapter, Ubuntu 8.04.1), this part caused the following error: The application ran only one time successfully per session, when the application was started again, the application was unable to connect to the serial port. Thus, a reboot was necessary everytime the user tried to relaunch the application, which is/was a really annoying bug. <br />
<br />
The reason is not difficult to understand: The application is in the while true do - loop, which is, to be more precisely, an endless loop. There is no abort-condition, so the only way to close the application is to close the terminal or to press CTRL-C. But if you quit the application this way, the important part with "ser.free", which frees the serial port, will never be called. This problem is described in the following thread in the German Lazarus-Forum [http://www.lazarusforum.de/viewtopic.php?f=10&t=2082 http://www.lazarusforum.de/viewtopic.php?f=10&t=2082]<br />
<br />
There is a bit code around the main application to make every user clear, not to press CTRL-C. If anyone is worrying, why /dev/ttyUSB0 is used for com-port: this is due to the USB to Serial Adapter (from Digitus) on the test-system. If you have an built-in serial port, please use the 'Com0' - declaration like in the code - example above. <br />
<br />
<delphi><br />
<br />
program serialtest;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$IFDEF UNIX}{$IFDEF UseCThreads}<br />
cthreads,<br />
{$ENDIF}{$ENDIF}<br />
Classes,SysUtils,Synaser,Crt<br />
{ you can add units after this };<br />
<br />
var l:boolean;<br />
<br />
function check_affirmation():boolean;<br />
var k:string;<br />
begin<br />
Writeln('To quit the application please do NOT use CTRL-C! Instead, please press any key to quit the application! '+<br />
'Please confirm this notification before the application continues! '+<br />
'[0]=Quit, [1]=Confirm, please continue! ');<br />
Writeln('Your decision: ');<br />
Read(k);<br />
if StrtoInt(k) = 1 then<br />
begin<br />
check_affirmation:=true;<br />
Writeln('OK, application continues ...');<br />
end<br />
else<br />
begin<br />
check_affirmation:=false;<br />
Writeln('Abort');<br />
end<br />
end;<br />
<br />
procedure RS232_connect;<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('/dev/ttyUSB0'); //ComPort<br />
Sleep(1000);<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
Write('Device: ' + ser.Device + ' Status: ' + ser.LastErrorDesc +' '+<br />
Inttostr(ser.LastError));<br />
Sleep(1000);<br />
repeat<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
until keypressed; //Important!!!<br />
finally<br />
Writeln('Serial Port will be freed...');<br />
ser.free;<br />
Writeln('Serial Port was freed successfully!');<br />
end;<br />
end;<br />
<br />
begin<br />
l:=check_affirmation();<br />
if l=true then<br />
RS232_connect()<br />
else<br />
Writeln('Program quit! ');<br />
end.<br />
<br />
</delphi><br />
<br />
Also, the [[Hardware Access#External Links | External Links]] section has UNIX and Windows serial port tutorials.<br />
<br />
==USB==<br />
<br />
===libusb===<br />
<br />
A cross platform possibility for Linux, BSDs and Mac OS X is [http://libusb.sourceforge.net/ libusb].<br />
<br />
Headers are listed in http://www.freepascal.org/contrib/db.php3?category=Miscellaneous:<br />
<br />
{|cellpadding="4"<br />
|-<br />
! name !! author !! version !! date !! link !! remarks<br />
|-<br />
| libusb.pp || nowrap | Uwe Zimmermann || 0.1.12 || nowrap | 2006-06-29 || http://www.sciencetronics.com/download/fpc_libusb.tgz || <br />
|-<br />
| libusb.pas || Johann Glaser || || nowrap | 2005-01-14 || http://www.johann-glaser.at/projects/libusb.pas || <br />
|-<br />
| fpcusb || Joe Jared || 0.11-14 || nowrap | 2006-02-02 || http://relays.osirusoft.com/fpcusb.tgz || nowrap | download link broken<br />
|}<br />
<br />
===FTDI===<br />
<br />
If you use one of the chips from [http://www.ftdichip.com/ FTDI], you can use their pascal headers for their dll interface to the chips.<br />
<br />
==External Links==<br />
<br />
Communication Protocols speed comparison:<br />
<br />
# http://en.wikipedia.org/wiki/Serial_port#Speed<br />
# http://www.lvr.com/jansfaq.htm - Jan Axelson's Parallel Port FAQ<br />
# http://en.wikipedia.org/wiki/USB#Transfer_Speed<br />
# http://en.wikipedia.org/wiki/PCI#Conventional_PCI_bus_specifications<br />
<br />
Serial Communication Links:<br />
<br />
# On UNIX: [http://www.easysw.com/~mike/serial/serial.html]<br />
# On Windows: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp<br />
# Synaser component: http://synapse.ararat.cz/<br />
# Comport Delphi package: http://sourceforge.net/projects/comport/<br />
<br />
ISA Digital Oscilloscope - A example of hardware access with full source included:<br />
<br />
[http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/]<br />
<br />
----<br />
[[Networking]]</div>Orankehttps://wiki.freepascal.org/index.php?title=User_talk:Heennavi&diff=32325User talk:Heennavi2008-11-27T02:02:03Z<p>Oranke: New page: 지금 작업중이신 위치는 한국어 페이지가 아닙니다. 영문 페이지에 직접 수정을 하시면 안되요. 한국어 페이지를 만들고 그 곳에 번역을 하...</p>
<hr />
<div>지금 작업중이신 위치는 한국어 페이지가 아닙니다. 영문 페이지에 직접 수정을 하시면 안되요. <br />
한국어 페이지를 만들고 그 곳에 번역을 하는 내용을 델마당에 올렸으니 참고 해 주세요.</div>Orankehttps://wiki.freepascal.org/index.php?title=Hardware_Access&diff=32324Hardware Access2008-11-27T02:01:02Z<p>Oranke: </p>
<hr />
<div>{{Hardware Access}}<br />
__TOC__<br />
==Overview==<br />
This page is the start of a tutorial about accessing hardware devices on Lazarus. These devices include, but are not limited to: ISA, PCI, USB, parallel port, serial port.<br />
<br />
Access to hardware devices on a completely multi-platform way is not implemented by Free Pascal Runtime Library or by the LCL, so this tutorial will basically cover hardware access methods on different platforms. The code can be compiled on different environments using conditional compiles, like this:<br />
<br />
<delphi><br />
uses<br />
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,<br />
{$IFDEF WIN32}<br />
Windows;<br />
{$ENDIF}<br />
{$IFDEF Unix}<br />
ports;<br />
{$ENDIF}<br />
</delphi><br />
<br />
It is not known yet, at this time, if Mac OS X/x86 will allow HW access. It can disallow it, though I assume in that case, in time, drivers like io.dll will appear.<br />
<br />
==Parallel and Serial Comparison==<br />
ISA Cards, PCI Cards and the Parallel Port communicate with the computer using a '''parallel''' protocol. The Serial Port and USB devices work with a '''serial''' protocol. Because the processor and thus programming languages all work on a parallel approach to data, access to this kinds of protocols is easier to be implemented on the software side. When you access an Integer variable, for example, you can access it's value with a single command. With a serial protocol, however, you can only know one bit at a time, and you need to glue the pieces together to understand the data.<br />
<br />
Serial communication is difficult to be implemented directly, but it can be pretty easy if you use a pre-made component. It is also harder on the hardware side, so many devices use specialised Integrated Circuits or even Microcontrolers to implement it.<br />
<br />
Now a brief comparison of hardware access protocols will be given:<br />
<br />
{| border=2 width="100%"<br />
<br />
|-<br />
!<br />
! Speed<br />
! Hardware implementation difficulty<br />
<br />
|-<br />
! Serial Port<br />
| align="center" | Very slow (< E5 bit/s)<br />
| align="center" | Medium<br />
<br />
|-<br />
! Parallel Port<br />
| align="center" | Slow (~ E6 bit/s)<br />
| align="center" | Easy<br />
<br />
|-<br />
<br />
! ISA Card<br />
| align="center" | Medium (~ E7 bit/s)<br />
| align="center" | Medium<br />
<br />
|-<br />
! USB<br />
| align="center" | Medium (~ E7 bit/s)<br />
| align="center" | Hard<br />
<br />
|-<br />
! PCI Card<br />
| align="center" | Very Fast (> E9 bit/s)<br />
| align="center" | Very Hard<br />
<br />
|}<br />
<br />
==Parallel Communication==<br />
<br />
===Using inpout32.dll for Windows===<br />
Windows has different ways to access hardware devices on the 9x series and on the NT series. On the 9x series (95, 98, Me) programs can access the hardware directly, just like they did on DOS. The NT series (Windows NT and XP), however, don't allow this approach. On this architecture, all communication with hardware ports must be throught a device driver. This is a security mechanism, but developing a driver can cost too much in terms of time and money for small projects.<br />
<br />
Happily there is a library that solves this problem. If Windows NT is detected, it decompresses HWInterface.sys kernel device driver and installs it. If Windows 9x is detected, it simply uses assembler opcodes to access the hardware.<br />
<br />
But how do I use the library? Simple! It has only two functions, Inp32 and Out32, and their use is quite intuitive.<br />
<br />
We will load the library dynamically, so let's define both functions first:<br />
<br />
<delphi><br />
type<br />
TInp32 = function(Address: SmallInt): SmallInt; stdcall;<br />
TOut32 = procedure(Address: SmallInt; Data: SmallInt); stdcall;<br />
</delphi><br />
<br />
* Address represents the address of the port you desire to access<br />
* Out32 sends Data to the port you specify by Address<br />
* Inp32 returns a byte from the port you specify by Address<br />
<br />
Now we can load the library. This can be implemented in a place like the OnCreate method of your program's main form:<br />
<br />
<delphi><br />
type<br />
TMyForm = class(TForm)<br />
.........<br />
private<br />
{ private declarations }<br />
Inpout32: THandle;<br />
Inp32: TInp32;<br />
Out32: TOut32;<br />
.........<br />
implementation<br />
.........<br />
procedure TMyForm.FormCreate(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
Inpout32 := LoadLibrary('inpout32.dll');<br />
if (Inpout32 <> 0) then<br />
begin<br />
// needs overtyping, plain Delphi's @Inp32 = GetProc... leads to compile errors<br />
Inp32 := TInp32(GetProcAddress(Inpout32, 'Inp32'));<br />
if (@Inp32 = nil) then Caption := 'Error';<br />
Out32 := TOut32(GetProcAddress(Inpout32, 'Out32'));<br />
if (@Out32 = nil) then Caption := 'Error';<br />
end<br />
else Caption := 'Error';<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
If you load the library on OnCreate just don't forget to unload it in OnDestroy:<br />
<br />
<delphi><br />
procedure TMyForm.FormDestroy(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
FreeLibrary(Inpout32);<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
Here is a simple example of how to use Inp32 function:<br />
<br />
<delphi><br />
{$IFDEF WIN32}<br />
myLabel.Caption := IntToStr(Inp32($0220));<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Windows XP. Of course you will need to have Windows on your uses clause in order for this code to run. For deployment you only need to include "inpout32.dll" in the same directory of our application.<br />
<br />
This is the homepage for the library: [http://www.logix4u.net/inpout32.htm www.logix4u.net/inpout32.htm] *see discussion*<br />
<br />
===Using assembler on Windows 9x===<br />
<br />
On Windows 9x you can also use assembler code. Suppose you wish to write $CC to the $320 port. The following code will do it:<br />
<br />
<delphi><br />
{$ASMMODE ATT}<br />
...<br />
asm<br />
movl $0x320, %edx<br />
movb $0xCC, %al<br />
outb %al, %dx<br />
end ['EAX','EDX'];<br />
</delphi><br />
<br />
===Troubleshooting on Windows===<br />
<br />
One possible source of trouble using parallel hardware that does not support Plug And Play on Windows is that Windows may assign the port utilized by your hardware to another device. You can find instructions on the URL below about how to tell Windows not to assign the address of your device to Plug And Play devices:<br />
<br />
http://support.microsoft.com/kb/135168<br />
<br />
===Using ioperm to access ports on Linux===<br />
<br />
The best way to access the hardware on Linux is throught device drivers, but, due to the complexity of the task of creating a driver, sometimes a quick method is very useful.<br />
<br />
In order to use the "[[doc:rtl/ports|ports]]" unit under Linux your program must be run as root, and IOPerm must be called to set appropriate permissions on the port access. You can find documentation about the "[[doc:rtl/ports|ports]]" unit [http://www.freepascal.org/docs-html/rtl/ports/index.html here].<br />
<br />
The first thing to do is link to (g)libc and call IOPerm. A unit that links to the entire (g)libc exists on free pascal, but this unit gives problems when used directly by application and linking statically to the entire (g)libc library is not a very good idea because it changes often between version in an incompatible manner. Functions like ioperm, however, are unlikely to change.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external 'libc';<br />
{$ENDIF}<br />
</delphi><br />
<br />
* "from" represents the first port to be accessed.<br />
* "num" is the number of ports after the first to be accessed, so ioperm($220, 8, 1) will give access for the program for all ports between and including $220 and $227.<br />
<br />
After linking to IOPerm you can port[<Address>] to access the ports.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
i := ioperm($220, 8, 1);<br />
port[$220] := $00;<br />
myLabel.Caption := 'ioperm: ' + IntToStr(i);<br />
i := Integer(port[$220]);<br />
myOtherLabel.Caption := 'response: ' + IntToStr(i);<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Mandriva Linux 2005 and Damn Small Linux 1.5<br />
<br />
===General UNIX Hardware Access===<br />
<br />
<delphi><br />
{$IFDEF Unix}<br />
Uses Clib; // retrieve libc library name.<br />
{$ENDIF}<br />
<br />
{$IFDEF Unix}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external clib;<br />
{$ENDIF}<br />
</delphi><br />
<br />
<br />
'''Note''' that FPC provides an abstraction for ioperm called "fpioperm" in [[doc:rtl/x86/index.html|unit x86]], and also defines out and inport functions. These functions are currently implemented for Linux/x86 and FreeBSD/x86.<br />
<br />
It is not recommended to link to libc unless absolutely necessary due to possible deployment and portability functions.<br />
Also manual linking to libc (by declaring ad hoc libc imports for functions that are available elsewhere) like done above is not recommended (e.g. the above libc import line will unnecessarily fail if the standard C lib is not called libc, like e.g. libroot on BeOS, or on platforms with a non standard C symbol mangling).<br />
<br />
'''Note 2''' Using _unit_ libc is not recommended under any circumstances other than Kylix compability. This because the unit is relatively unportable (due to excessive exposure of structures and other private symbols) and must only be modified as little as possible out of Kylix compability issues.<br />
<br />
==Serial Communication==<br />
<br />
It is very easy to build a serial communication software using the [http://synapse.ararat.cz/doku.php Synaser library]. The example when used together with the [http://synapse.ararat.cz/doc/help/synaser.html Synaser documentation] should be trivial to understand. The most important part is TBlockSerial.Config to configure the speed (in bits per second), data bits, parity bits, stop bits and handshake protocol, if any. The following code was tested with a serial mouse connected to COM 1.<br />
<br />
<delphi><br />
program comm;<br />
<br />
{$apptype console}<br />
<br />
uses<br />
Classes, SysUtils, Synaser;<br />
<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('COM1');<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
while True do<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
finally<br />
ser.free;<br />
end;<br />
end.<br />
</delphi><br />
<br />
The following code-example is an alternative version of the example above. The example above seems to have a critically fault in its main concept, to be exactly, it is the part with "while true do...". On the Test - System (Asus A6T Laptop with Digitus USB to RS232 Adapter, Ubuntu 8.04.1), this part caused the following error: The application ran only one time successfully per session, when the application was started again, the application was unable to connect to the serial port. Thus, a reboot was necessary everytime the user tried to relaunch the application, which is/was a really annoying bug. <br />
<br />
The reason is not difficult to understand: The application is in the while true do - loop, which is, to be more precisely, an endless loop. There is no abort-condition, so the only way to close the application is to close the terminal or to press CTRL-C. But if you quit the application this way, the important part with "ser.free", which frees the serial port, will never be called. This problem is described in the following thread in the German Lazarus-Forum [http://www.lazarusforum.de/viewtopic.php?f=10&t=2082 http://www.lazarusforum.de/viewtopic.php?f=10&t=2082]<br />
<br />
There is a bit code around the main application to make every user clear, not to press CTRL-C. If anyone is worrying, why /dev/ttyUSB0 is used for com-port: this is due to the USB to Serial Adapter (from Digitus) on the test-system. If you have an built-in serial port, please use the 'Com0' - declaration like in the code - example above. <br />
<br />
<delphi><br />
<br />
program serialtest;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$IFDEF UNIX}{$IFDEF UseCThreads}<br />
cthreads,<br />
{$ENDIF}{$ENDIF}<br />
Classes,SysUtils,Synaser,Crt<br />
{ you can add units after this };<br />
<br />
var l:boolean;<br />
<br />
function check_affirmation():boolean;<br />
var k:string;<br />
begin<br />
Writeln('To quit the application please do NOT use CTRL-C! Instead, please press any key to quit the application! '+<br />
'Please confirm this notification before the application continues! '+<br />
'[0]=Quit, [1]=Confirm, please continue! ');<br />
Writeln('Your decision: ');<br />
Read(k);<br />
if StrtoInt(k) = 1 then<br />
begin<br />
check_affirmation:=true;<br />
Writeln('OK, application continues ...');<br />
end<br />
else<br />
begin<br />
check_affirmation:=false;<br />
Writeln('Abort');<br />
end<br />
end;<br />
<br />
procedure RS232_connect;<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('/dev/ttyUSB0'); //ComPort<br />
Sleep(1000);<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
Write('Device: ' + ser.Device + ' Status: ' + ser.LastErrorDesc +' '+<br />
Inttostr(ser.LastError));<br />
Sleep(1000);<br />
repeat<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
until keypressed; //Important!!!<br />
finally<br />
Writeln('Serial Port will be freed...');<br />
ser.free;<br />
Writeln('Serial Port was freed successfully!');<br />
end;<br />
end;<br />
<br />
begin<br />
l:=check_affirmation();<br />
if l=true then<br />
RS232_connect()<br />
else<br />
Writeln('Program quit! ');<br />
end.<br />
<br />
</delphi><br />
<br />
Also, the [[Hardware Access#External Links | External Links]] section has UNIX and Windows serial port tutorials.<br />
<br />
==USB==<br />
<br />
===libusb===<br />
<br />
A cross platform possibility for Linux, BSDs and Mac OS X is [http://libusb.sourceforge.net/ libusb].<br />
<br />
Headers are listed in http://www.freepascal.org/contrib/db.php3?category=Miscellaneous:<br />
<br />
{|cellpadding="4"<br />
|-<br />
! name !! author !! version !! date !! link !! remarks<br />
|-<br />
| libusb.pp || nowrap | Uwe Zimmermann || 0.1.12 || nowrap | 2006-06-29 || http://www.sciencetronics.com/download/fpc_libusb.tgz || <br />
|-<br />
| libusb.pas || Johann Glaser || || nowrap | 2005-01-14 || http://www.johann-glaser.at/projects/libusb.pas || <br />
|-<br />
| fpcusb || Joe Jared || 0.11-14 || nowrap | 2006-02-02 || http://relays.osirusoft.com/fpcusb.tgz || nowrap | download link broken<br />
|}<br />
<br />
===FTDI===<br />
<br />
If you use one of the chips from [http://www.ftdichip.com/ FTDI], you can use their pascal headers for their dll interface to the chips.<br />
<br />
==External Links==<br />
<br />
Communication Protocols speed comparison:<br />
<br />
# http://en.wikipedia.org/wiki/Serial_port#Speed<br />
# http://www.lvr.com/jansfaq.htm - Jan Axelson's Parallel Port FAQ<br />
# http://en.wikipedia.org/wiki/USB#Transfer_Speed<br />
# http://en.wikipedia.org/wiki/PCI#Conventional_PCI_bus_specifications<br />
<br />
Serial Communication Links:<br />
<br />
# On UNIX: [http://www.easysw.com/~mike/serial/serial.html]<br />
# On Windows: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp<br />
# Synaser component: http://synapse.ararat.cz/<br />
# Comport Delphi package: http://sourceforge.net/projects/comport/<br />
<br />
ISA Digital Oscilloscope - A example of hardware access with full source included:<br />
<br />
[http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/]<br />
<br />
----<br />
[[Networking]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Template:Hardware_Access&diff=32322Template:Hardware Access2008-11-27T01:55:50Z<p>Oranke: </p>
<hr />
<div><small><br />
[[Hardware Access/de|'''Deutsch (de)''']]<br />
[[Hardware Access|'''English (en)''']]<br />
[[Hardware Access/es|'''Español (es)''']]<br />
[[Hardware Access/fr|'''Français (fr)''']]<br />
[[Hardware Access/ja|'''Japanese (jp)''']]<br />
[[Hardware Access/ko|'''한국어 (ko)''']]<br />
[[Hardware Access/pt|'''Português (pt)''']]<br />
[[Hardware Access/ru|'''Русский (ru)''']]<br />
</small></div>Orankehttps://wiki.freepascal.org/index.php?title=Hardware_Access&diff=32321Hardware Access2008-11-27T01:42:57Z<p>Oranke: </p>
<hr />
<div>{{Hardware Access}}<br />
__TOC__<br />
==Overview==<br />
This page is the start of a tutorial about accessing hardware devices on Lazarus. These devices include, but are not limited to: ISA, PCI, USB, parallel port, serial port.<br />
<br />
Access to hardware devices on a completely multi-platform way is not implemented by Free Pascal Runtime Library or by the LCL, so this tutorial will basically cover hardware access methods on different platforms. The code can be compiled on different environments using conditional compiles, like this:<br />
<br />
<delphi><br />
uses<br />
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,<br />
{$IFDEF WIN32}<br />
Windows;<br />
{$ENDIF}<br />
{$IFDEF Unix}<br />
ports;<br />
{$ENDIF}<br />
</delphi><br />
<br />
It is not known yet, at this time, if Mac OS X/x86 will allow HW access. It can disallow it, though I assume in that case, in time, drivers like io.dll will appear.<br />
<br />
==Parallel and Serial Comparison==<br />
ISA Cards, PCI Cards and the Parallel Port communicate with the computer using a '''parallel''' protocol. The Serial Port and USB devices work with a '''serial''' protocol. Because the processor and thus programming languages all work on a parallel approach to data, access to this kinds of protocols is easier to be implemented on the software side. When you access an Integer variable, for example, you can access it's value with a single command. With a serial protocol, however, you can only know one bit at a time, and you need to glue the pieces together to understand the data.<br />
<br />
Serial communication is difficult to be implemented directly, but it can be pretty easy if you use a pre-made component. It is also harder on the hardware side, so many devices use specialised Integrated Circuits or even Microcontrolers to implement it.<br />
<br />
Now a brief comparison of hardware access protocols will be given:<br />
<br />
{| border=2 width="100%"<br />
<br />
|-<br />
!<br />
! Speed<br />
! Hardware implementation difficulty<br />
<br />
|-<br />
! Serial Port<br />
| align="center" | Very slow (< E5 bit/s)<br />
| align="center" | Medium<br />
<br />
|-<br />
! Parallel Port<br />
| align="center" | Slow (~ E6 bit/s)<br />
| align="center" | Easy<br />
<br />
|-<br />
<br />
! ISA Card<br />
| align="center" | Medium (~ E7 bit/s)<br />
| align="center" | Medium<br />
<br />
|-<br />
! USB<br />
| align="center" | Medium (~ E7 bit/s)<br />
| align="center" | Hard<br />
<br />
|-<br />
! PCI Card<br />
| align="center" | Very Fast (> E9 bit/s)<br />
| align="center" | Very Hard<br />
<br />
|}<br />
<br />
==Parallel Communication==<br />
<br />
===Using inpout32.dll for Windows===<br />
Windows has different ways to access hardware devices on the 9x series and on the NT series. On the 9x series (95, 98, Me) programs can access the hardware directly, just like they did on DOS. The NT series (Windows NT and XP), however, don't allow this approach. On this architecture, all communication with hardware ports must be throught a device driver. This is a security mechanism, but developing a driver can cost too much in terms of time and money for small projects.<br />
<br />
Happily there is a library that solves this problem. If Windows NT is detected, it decompresses HWInterface.sys kernel device driver and installs it. If Windows 9x is detected, it simply uses assembler opcodes to access the hardware.<br />
<br />
But how do I use the library? Simple! It has only two functions, Inp32 and Out32, and their use is quite intuitive.<br />
<br />
We will load the library dynamically, so let's define both functions first:<br />
<br />
<delphi><br />
type<br />
TInp32 = function(Address: SmallInt): SmallInt; stdcall;<br />
TOut32 = procedure(Address: SmallInt; Data: SmallInt); stdcall;<br />
</delphi><br />
<br />
* Address represents the address of the port you desire to access<br />
* Out32 sends Data to the port you specify by Address<br />
* Inp32 returns a byte from the port you specify by Address<br />
<br />
Now we can load the library. This can be implemented in a place like the OnCreate method of your program's main form:<br />
<br />
<delphi><br />
type<br />
TMyForm = class(TForm)<br />
.........<br />
private<br />
{ private declarations }<br />
Inpout32: THandle;<br />
Inp32: TInp32;<br />
Out32: TOut32;<br />
.........<br />
implementation<br />
.........<br />
procedure TMyForm.FormCreate(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
Inpout32 := LoadLibrary('inpout32.dll');<br />
if (Inpout32 <> 0) then<br />
begin<br />
// needs overtyping, plain Delphi's @Inp32 = GetProc... leads to compile errors<br />
Inp32 := TInp32(GetProcAddress(Inpout32, 'Inp32'));<br />
if (@Inp32 = nil) then Caption := 'Error';<br />
Out32 := TOut32(GetProcAddress(Inpout32, 'Out32'));<br />
if (@Out32 = nil) then Caption := 'Error';<br />
end<br />
else Caption := 'Error';<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
If you load the library on OnCreate just don't forget to unload it in OnDestroy:<br />
<br />
<delphi><br />
procedure TMyForm.FormDestroy(Sender: TObject);<br />
begin<br />
{$IFDEF WIN32}<br />
FreeLibrary(Inpout32);<br />
{$ENDIF}<br />
end;<br />
</delphi><br />
<br />
Here is a simple example of how to use Inp32 function:<br />
<br />
<delphi><br />
{$IFDEF WIN32}<br />
myLabel.Caption := IntToStr(Inp32($0220));<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Windows XP. Of course you will need to have Windows on your uses clause in order for this code to run. For deployment you only need to include "inpout32.dll" in the same directory of our application.<br />
<br />
This is the homepage for the library: [http://www.logix4u.net/inpout32.htm www.logix4u.net/inpout32.htm] *see discussion*<br />
<br />
===Using assembler on Windows 9x===<br />
<br />
On Windows 9x you can also use assembler code. Suppose you wish to write $CC to the $320 port. The following code will do it:<br />
<br />
<delphi><br />
{$ASMMODE ATT}<br />
...<br />
asm<br />
movl $0x320, %edx<br />
movb $0xCC, %al<br />
outb %al, %dx<br />
end ['EAX','EDX'];<br />
</delphi><br />
<br />
===Troubleshooting on Windows===<br />
<br />
One possible source of trouble using parallel hardware that does not support Plug And Play on Windows is that Windows may assign the port utilized by your hardware to another device. You can find instructions on the URL below about how to tell Windows not to assign the address of your device to Plug And Play devices:<br />
<br />
http://support.microsoft.com/kb/135168<br />
<br />
===Using ioperm to access ports on Linux===<br />
<br />
The best way to access the hardware on Linux is throught device drivers, but, due to the complexity of the task of creating a driver, sometimes a quick method is very useful.<br />
<br />
In order to use the "[[doc:rtl/ports|ports]]" unit under Linux your program must be run as root, and IOPerm must be called to set appropriate permissions on the port access. You can find documentation about the "[[doc:rtl/ports|ports]]" unit [http://www.freepascal.org/docs-html/rtl/ports/index.html here].<br />
<br />
The first thing to do is link to (g)libc and call IOPerm. A unit that links to the entire (g)libc exists on free pascal, but this unit gives problems when used directly by application and linking statically to the entire (g)libc library is not a very good idea because it changes often between version in an incompatible manner. Functions like ioperm, however, are unlikely to change.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external 'libc';<br />
{$ENDIF}<br />
</delphi><br />
<br />
* "from" represents the first port to be accessed.<br />
* "num" is the number of ports after the first to be accessed, so ioperm($220, 8, 1) will give access for the program for all ports between and including $220 and $227.<br />
<br />
After linking to IOPerm you can port[<Address>] to access the ports.<br />
<br />
<delphi><br />
{$IFDEF Linux}<br />
i := ioperm($220, 8, 1);<br />
port[$220] := $00;<br />
myLabel.Caption := 'ioperm: ' + IntToStr(i);<br />
i := Integer(port[$220]);<br />
myOtherLabel.Caption := 'response: ' + IntToStr(i);<br />
{$ENDIF}<br />
</delphi><br />
<br />
This code was tested with a custom ISA card on port $0220, using Lazarus 0.9.10 on Mandriva Linux 2005 and Damn Small Linux 1.5<br />
<br />
===General UNIX Hardware Access===<br />
<br />
<delphi><br />
{$IFDEF Unix}<br />
Uses Clib; // retrieve libc library name.<br />
{$ENDIF}<br />
<br />
{$IFDEF Unix}<br />
function ioperm(from: Cardinal; num: Cardinal; turn_on: Integer): Integer; cdecl; external clib;<br />
{$ENDIF}<br />
</delphi><br />
<br />
<br />
'''Note''' that FPC provides an abstraction for ioperm called "fpioperm" in [[doc:rtl/x86/index.html|unit x86]], and also defines out and inport functions. These functions are currently implemented for Linux/x86 and FreeBSD/x86.<br />
<br />
It is not recommended to link to libc unless absolutely necessary due to possible deployment and portability functions.<br />
Also manual linking to libc (by declaring ad hoc libc imports for functions that are available elsewhere) like done above is not recommended (e.g. the above libc import line will unnecessarily fail if the standard C lib is not called libc, like e.g. libroot on BeOS, or on platforms with a non standard C symbol mangling).<br />
<br />
'''Note 2''' Using _unit_ libc is not recommended under any circumstances other than Kylix compability. This because the unit is relatively unportable (due to excessive exposure of structures and other private symbols) and must only be modified as little as possible out of Kylix compability issues.<br />
<br />
==Serial Communication==<br />
<br />
It is very easy to build a serial communication software using the [http://synapse.ararat.cz/doku.php Synaser library]. The example when used together with the [http://synapse.ararat.cz/doc/help/synaser.html Synaser documentation] should be trivial to understand. The most important part is TBlockSerial.Config to configure the speed (in bits per second), data bits, parity bits, stop bits and handshake protocol, if any. The following code was tested with a serial mouse connected to COM 1.<br />
<br />
<delphi><br />
program comm;<br />
<br />
{$apptype console}<br />
<br />
uses<br />
Classes, SysUtils, Synaser;<br />
<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('COM1');<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
while True do<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
finally<br />
ser.free;<br />
end;<br />
end.<br />
</delphi><br />
<br />
The following code-example is an alternative version of the example above. The example above seems to have a critically fault in its main concept, to be exactly, it is the part with "while true do...". On the Test - System (Asus A6T Laptop with Digitus USB to RS232 Adapter, Ubuntu 8.04.1), this part caused the following error: The application ran only one time successfully per session, when the application was started again, the application was unable to connect to the serial port. Thus, a reboot was necessary everytime the user tried to relaunch the application, which is/was a really annoying bug. <br />
<br />
The reason is not difficult to understand: The application is in the while true do - loop, which is, to be more precisely, an endless loop. There is no abort-condition, so the only way to close the application is to close the terminal or to press CTRL-C. But if you quit the application this way, the important part with "ser.free", which frees the serial port, will never be called. This problem is described in the following thread in the German Lazarus-Forum [http://www.lazarusforum.de/viewtopic.php?f=10&t=2082 http://www.lazarusforum.de/viewtopic.php?f=10&t=2082]<br />
<br />
There is a bit code around the main application to make every user clear, not to press CTRL-C. If anyone is worrying, why /dev/ttyUSB0 is used for com-port: this is due to the USB to Serial Adapter (from Digitus) on the test-system. If you have an built-in serial port, please use the 'Com0' - declaration like in the code - example above. <br />
<br />
<delphi><br />
<br />
program serialtest;<br />
<br />
{$mode objfpc}{$H+}<br />
<br />
uses<br />
{$IFDEF UNIX}{$IFDEF UseCThreads}<br />
cthreads,<br />
{$ENDIF}{$ENDIF}<br />
Classes,SysUtils,Synaser,Crt<br />
{ you can add units after this };<br />
<br />
var l:boolean;<br />
<br />
function check_affirmation():boolean;<br />
var k:string;<br />
begin<br />
Writeln('To quit the application please do NOT use CTRL-C! Instead, please press any key to quit the application! '+<br />
'Please confirm this notification before the application continues! '+<br />
'[0]=Quit, [1]=Confirm, please continue! ');<br />
Writeln('Your decision: ');<br />
Read(k);<br />
if StrtoInt(k) = 1 then<br />
begin<br />
check_affirmation:=true;<br />
Writeln('OK, application continues ...');<br />
end<br />
else<br />
begin<br />
check_affirmation:=false;<br />
Writeln('Abort');<br />
end<br />
end;<br />
<br />
procedure RS232_connect;<br />
var<br />
ser: TBlockSerial;<br />
begin<br />
ser:=TBlockSerial.Create;<br />
try<br />
ser.Connect('/dev/ttyUSB0'); //ComPort<br />
Sleep(1000);<br />
ser.config(1200, 7, 'N', SB1, False, False);<br />
Write('Device: ' + ser.Device + ' Status: ' + ser.LastErrorDesc +' '+<br />
Inttostr(ser.LastError));<br />
Sleep(1000);<br />
repeat<br />
Write(IntToHex(ser.RecvByte(10000), 2), ' ');<br />
until keypressed; //Important!!!<br />
finally<br />
Writeln('Serial Port will be freed...');<br />
ser.free;<br />
Writeln('Serial Port was freed successfully!');<br />
end;<br />
end;<br />
<br />
begin<br />
l:=check_affirmation();<br />
if l=true then<br />
RS232_connect()<br />
else<br />
Writeln('Program quit! ');<br />
end.<br />
<br />
</delphi><br />
<br />
Also, the [[Hardware Access#External Links | External Links]] section has UNIX and Windows serial port tutorials.<br />
<br />
==USB==<br />
<br />
===libusb===<br />
<br />
A cross platform possibility for Linux, BSDs and Mac OS X is [http://libusb.sourceforge.net/ libusb].<br />
<br />
Headers are listed in http://www.freepascal.org/contrib/db.php3?category=Miscellaneous:<br />
<br />
{|cellpadding="4"<br />
|-<br />
! name !! author !! version !! date !! link !! remarks<br />
|-<br />
| libusb.pp || nowrap | Uwe Zimmermann || 0.1.12 || nowrap | 2006-06-29 || http://www.sciencetronics.com/download/fpc_libusb.tgz || <br />
|-<br />
| libusb.pas || Johann Glaser || || nowrap | 2005-01-14 || http://www.johann-glaser.at/projects/libusb.pas || <br />
|-<br />
| fpcusb || Joe Jared || 0.11-14 || nowrap | 2006-02-02 || http://relays.osirusoft.com/fpcusb.tgz || nowrap | download link broken<br />
|}<br />
<br />
===FTDI===<br />
<br />
If you use one of the chips from [http://www.ftdichip.com/ FTDI], you can use their pascal headers for their dll interface to the chips.<br />
<br />
==External Links==<br />
<br />
Communication Protocols speed comparison:<br />
<br />
# http://en.wikipedia.org/wiki/Serial_port#Speed<br />
# http://www.lvr.com/jansfaq.htm - Jan Axelson's Parallel Port FAQ<br />
# http://en.wikipedia.org/wiki/USB#Transfer_Speed<br />
# http://en.wikipedia.org/wiki/PCI#Conventional_PCI_bus_specifications<br />
<br />
Serial Communication Links:<br />
<br />
# On UNIX: [http://www.easysw.com/~mike/serial/serial.html]<br />
# On Windows: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp<br />
# Synaser component: http://synapse.ararat.cz/<br />
# Comport Delphi package: http://sourceforge.net/projects/comport/<br />
<br />
ISA Digital Oscilloscope - A example of hardware access with full source included:<br />
<br />
[http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/]<br />
<br />
----<br />
[[Networking]]</div>Orankehttps://wiki.freepascal.org/index.php?title=Main_Page/ko&diff=32318Main Page/ko2008-11-26T23:51:21Z<p>Oranke: /* 라자루스 문서 */</p>
<hr />
<div>__NOTOC__<br />
{{Main Page}}<br />
<br />
=라자루스와 프리파스칼 위키에 오신 것을 환영합니다=<br />
<br />
<br />
==개요==<br />
<br />
이 위키는, FPC, Lazarus, 그리고 [[Related projects|관련된 프로젝트]]의 정보를 모으는 것을 목적으로 하고 있습니다.<br />
<br />
FPC는 이미 몇가지 포멧으로 잘 문서화 되어 있습니다만, [[FPC development|FPC의 개발이나 조직에 관한 정보]] 그리고 [[FPC_documentation|아직 정리되지 않은 문서]]들은 이 위키에 모아두고 있습니다.<br />
<br />
또한 라자루스는 필연적으로 유저들에게 배포된 문서와는 약간의 차이가 있을 수 밖에 없으므로, 누구나 참여해 편집할 수 있는 이 "open document", 또는 "wiki"가 만들어지게 되었습니다. <br />
<br />
이 위키는 브라우저를 통해 쉽게 내용을 변경하거나 추가할 수 있습니다. 사용법을 익히시려면 [http://www.chat11.com/30_Second_Quick_Wiki_Tutorial 30분 속성 위키 설명서] 또는 [http://en.wikipedia.org/wiki/Wikipedia:Tutorial 위키페디아 설명서]를 참고하세요. 연습을 위해 [[Sand Box|모래상자]]가 제공됩니다. 위키 사용에 문제가 있다면 [http://sourceforge.net/users/vlx/ 관리자]에게 알려주시거나 [http://sourceforge.net/projects/lazarus-ccr Lazarus-CCR] 에 버그를 올려주세요. 그 외에 남기고 싶은 제안은 [[Site Feedback|사이트 피드백]] 페이지를 이용하세요.<br />
<br />
라자루스의 <b>개발 이력</b>은 [[History|이 곳]]을 참고하세요.<br />
<br />
==프리 파스칼 문서==<br />
;[[FPC documentation|FPC 개발자 문서]]<br />
:개발자 및 기타 메시지 등을 다른 언어로 번역 해 주실 프리파스칼 컴파일러에 대한 공헌자들을 위한 문서 입니다.<br />
<br />
==라자루스 문서==<br />
;[[Lazarus Documentation/ko|라자루스 문서]]<br />
:모든 라자루스 IDE (프리파스칼 컴파일러 메뉴얼 포함) 에 대한 문서와 [[Lazarus_Documentation/ko#Lazarus_and_Pascal_Tutorials|튜토리얼]]은 [[Lazarus Documentation/ko|라자루스 문서]] 페이지에 있습니다. 많은 페이지가 "작업중"인 상태로 당신의 참여를 간절히 바라고 있습니다. 물론 새로운 페이지를 만들어 멋진 내용을 추가 해 주셔도 좋습니다.<br />
<br />
==다운로드==<br />
사용 가능한 컴포넌트와 패키지들은 [http://sourceforge.net/project/showfiles.php?group_id=92177 Lazarus-CCR 소스포지 파일 영역]에서 찾으실 수 있습니다. 프리파스칼 컴파일러와 라자루스의 현재 테스트버전은 [http://sourceforge.net/project/showfiles.php?group_id=89339 라자루스 소스포지 사이트]에서 찾으실 수 있습니다. 이 패키지에 대한 추가적인 문서는 [[Components and Code examples|컴포넌트와 코드 예제]] 페이지에 있습니다. 컴파일러와 많은 사람들에 의해 보내진 수 많은 코드들은 [http://www.freepascal.org/download.var 프리 파스클 컴파일러 다운로드 미러]와 [http://lazarus.freepascal.org 라자루스 IDE 웹사이트]에서 찾으실 수 있습니다. 라자루스 스냅샷은 [[Lazarus Snapshots Downloads | 이 곳]]에서 다운받으실 수 있습니다.<br />
<br />
==메일링 리스트==<br />
초보, 숙련자 누구나 Lazarus-ccr [http://lists.sourceforge.net/lists/listinfo/lazarus-ccr-announce 공지], 그리고 [http://lists.sourceforge.net/lists/listinfo/lazarus-ccr-general 일반] 메일링 리스트에 가입하세요.<br />
<br />
또한, [http://www.lazarus.freepascal.org/modules.php?op=modload&name=StaticPage&file=index&sURL=maill 라자루스] IDE 메일링 리스트와 [http://www.freepascal.org/maillist.html 프리파스칼] 개발자 또는 공지사항 메일링 리스트도 많은 도움이 될 것 입니다.<br />
<br />
==누가 무슨 작업을 하고 있나?==<br />
만약 당신이 현재 어떤 컴포넌트, 또는 라이브러리를 컨버팅 중이거나 그럴 필요를 느낀다면, 그 내용을 [[Current conversion projects|현재 변환중인 프로젝트]] 페이지에 올려주세요. 그렇게 함으로써 동일한 프로젝트를 두 사람 이상이 중복해 작업하는 일을 막을 수 있을 것입니다.<br />
<br />
==레퍼런스, 링크 그리고 리소스==<br />
<br />
===라자루스 IDE===<br />
라자루스 IDE에 대한 새 소식이나 정보는 [http://lazarus.freepascal.org 라자루스 IDE 웹사이트]에서 찾을 수 있습니다. 아이디어, 수정사항, 그리고 이후 개발계획은 [[Lazarus Development Process|라자루스 개발 프로세스]] 페이지를 참고하세요. 라자루스 IDE와 프리파스칼 컴파일러에 대한 다운로드도 그 곳에서 할 수 있습니다. 또한 [http://sourceforge.net/project/showfiles.php?group_id=89339 라자루스 파일 영역]에서 다운로드 가능한 컴파일러와 IDE의 최종 패키지를 얻을 수 있습니다..<br />
<br />
====라자루스 프로젝트의 활성화====<br />
<br />
[[Projects using Lazarus|라자루스 적용 프로젝트]] 페이지는 라자루스와 연관된 많은 자료에 대한 웹사이트와 다운로드 링크를 제공합니다. <br />
<br />
[[Lazarus Application Gallery|라자루스 어플리케이션 갤러리]]에서는 라자루스로 만들어진 어플리케이션의 스크린샷을 구경할 수 있습니다.<br />
<br />
====유용한 링크====<br />
[[Page Of Code Sites|코드 사이트 모음]] 페이지에서 델파이/카일릭스와 관련된 사이트들의 정보를 얻을 수 있습니다. 혹시라도 이 페이지에 없는 멋진 사이트를 알고 계시다면, 언제든지 추가 해 주세요.<br />
<br />
====특화된 검색엔진====<br />
새로운 기술과 문제 해결을 위해 온라인을 기반으로한 유용한 검색과 지식엔진이 있습니다. <br />
Tamarack 연합은 볼랜드 유즈넷의 문서들의 검색을 위해 특별히 빠른 [http://www.tamaracka.com/search.htm 검색엔진]을 운영합니다.<br />
Mer Systems Inc.는 유사한 [http://www.mers.com/searchsite.html 검색엔진]을 제공하고 있습니다.<br />
사이트 검색 능력을 진행하는 또 다른 정보소스는 Earl F. Glynnd의 컴퓨터랩과 레퍼런스 [http://www.efg2.com/ 라이브러리]입니다.<br />
<br />
====마케팅 사례 연구====<br />
[[Marketing_Case_Studies|라자루스 사용자들을 위한 기회]]로 라자루스가 왜 선택받은 IDE인지를 설명합니다.<br />
<br />
<br />
<br />
====FPC/라자루스 컨테스트와 전시회 출품====<br />
FPC/Lazarus는 독일 뮌헨의 [[Systems 2005]], [[Systems 2006]]과 [[Systems 2007]]에 부스를 만들어 출품 되었습니다. 이러한 전시회의 경험을 바탕으로한 [[Preparing a booth on a trade show|정보]]수집은 앞으로 전시회의 부스 준비를 돕기위해 만들어졌습니다.<br />
라자루스와 관련 프로젝트들은 그밖의 여러 컨테스트에 참여하고 있고 [[Contests|위키 페이지]]는 앞으로의 컨테스트 자료를위해 준비되고 있습니다.<br />
<br />
=Translations=<br />
<br />
* [[Main Page/ar | عربي (Arabic)]]<br />
* [[Main Page/es | Español (Spanish)]]<br />
* [[Main Page/de | Deutsch (German)]]<br />
* [[Main Page/fr | Français (French)]]<br />
* [[Main Page/id | Bahasa Indonesia (Indonesian)]]<br />
* [[Main Page/it | Italiano (Italian)]]<br />
* [[Main Page/ja | Japanese (Japanese)]]<br />
* [[Main Page/ko | Korean (한국어)]]<br />
* [[Main Page/nl | Nederlands (Dutch)]]<br />
* [[Main Page/pl | Polski (Polish)]]<br />
* [[Main Page/pt | Português (Portuguese)]]<br />
* [[Main Page/ru | Русский (Russian)]]<br />
* [[Main Page/sk | Slovensky (Slovak)]]<br />
* [[Main Page/fi | Suomi (Finnish)]]<br />
* [[Main Page/uk | Українська (Ukrainian)]]<br />
* [[Main Page/zh_CN | Chinese 中文(简体)]]<br />
* [[Main Page/zh_TW | Chinese 中文(正體)]]<br />
* [[Main Page/vn | Vietnamese (Việt Nam)]]<br />
<br />
=예전의 위키=<br />
이 페이지들은 예전의 위키포맷에서 변환되어져 왔습니다. 전의 위키페이지는 [http://lazarus-ccr.sourceforge.net/index.php?wiki=FrontPage 여기]에서 찾을 수 있습니다.<br />
<br />
원본 제공 [[User:VlxAdmin]].</div>Orankehttps://wiki.freepascal.org/index.php?title=Main_Page/ko&diff=32317Main Page/ko2008-11-26T23:50:51Z<p>Oranke: /* 라자루스 문서 */</p>
<hr />
<div>__NOTOC__<br />
{{Main Page}}<br />
<br />
=라자루스와 프리파스칼 위키에 오신 것을 환영합니다=<br />
<br />
<br />
==개요==<br />
<br />
이 위키는, FPC, Lazarus, 그리고 [[Related projects|관련된 프로젝트]]의 정보를 모으는 것을 목적으로 하고 있습니다.<br />
<br />
FPC는 이미 몇가지 포멧으로 잘 문서화 되어 있습니다만, [[FPC development|FPC의 개발이나 조직에 관한 정보]] 그리고 [[FPC_documentation|아직 정리되지 않은 문서]]들은 이 위키에 모아두고 있습니다.<br />
<br />
또한 라자루스는 필연적으로 유저들에게 배포된 문서와는 약간의 차이가 있을 수 밖에 없으므로, 누구나 참여해 편집할 수 있는 이 "open document", 또는 "wiki"가 만들어지게 되었습니다. <br />
<br />
이 위키는 브라우저를 통해 쉽게 내용을 변경하거나 추가할 수 있습니다. 사용법을 익히시려면 [http://www.chat11.com/30_Second_Quick_Wiki_Tutorial 30분 속성 위키 설명서] 또는 [http://en.wikipedia.org/wiki/Wikipedia:Tutorial 위키페디아 설명서]를 참고하세요. 연습을 위해 [[Sand Box|모래상자]]가 제공됩니다. 위키 사용에 문제가 있다면 [http://sourceforge.net/users/vlx/ 관리자]에게 알려주시거나 [http://sourceforge.net/projects/lazarus-ccr Lazarus-CCR] 에 버그를 올려주세요. 그 외에 남기고 싶은 제안은 [[Site Feedback|사이트 피드백]] 페이지를 이용하세요.<br />
<br />
라자루스의 <b>개발 이력</b>은 [[History|이 곳]]을 참고하세요.<br />
<br />
==프리 파스칼 문서==<br />
;[[FPC documentation|FPC 개발자 문서]]<br />
:개발자 및 기타 메시지 등을 다른 언어로 번역 해 주실 프리파스칼 컴파일러에 대한 공헌자들을 위한 문서 입니다.<br />
<br />
==라자루스 문서==<br />
;[[Lazarus Documentation/ko|라자루스 문서]]<br />
:모든 라자루스 IDE (프리파스칼 컴파일러 메뉴얼 포함) 에 대한 문서와 [[Lazarus_Documentation#Lazarus_and_Pascal_Tutorials/ko|튜토리얼]]은 [[Lazarus Documentation/ko|라자루스 문서]] 페이지에 있습니다. 많은 페이지가 "작업중"인 상태로 당신의 참여를 간절히 바라고 있습니다. 물론 새로운 페이지를 만들어 멋진 내용을 추가 해 주셔도 좋습니다.<br />
<br />
==다운로드==<br />
사용 가능한 컴포넌트와 패키지들은 [http://sourceforge.net/project/showfiles.php?group_id=92177 Lazarus-CCR 소스포지 파일 영역]에서 찾으실 수 있습니다. 프리파스칼 컴파일러와 라자루스의 현재 테스트버전은 [http://sourceforge.net/project/showfiles.php?group_id=89339 라자루스 소스포지 사이트]에서 찾으실 수 있습니다. 이 패키지에 대한 추가적인 문서는 [[Components and Code examples|컴포넌트와 코드 예제]] 페이지에 있습니다. 컴파일러와 많은 사람들에 의해 보내진 수 많은 코드들은 [http://www.freepascal.org/download.var 프리 파스클 컴파일러 다운로드 미러]와 [http://lazarus.freepascal.org 라자루스 IDE 웹사이트]에서 찾으실 수 있습니다. 라자루스 스냅샷은 [[Lazarus Snapshots Downloads | 이 곳]]에서 다운받으실 수 있습니다.<br />
<br />
==메일링 리스트==<br />
초보, 숙련자 누구나 Lazarus-ccr [http://lists.sourceforge.net/lists/listinfo/lazarus-ccr-announce 공지], 그리고 [http://lists.sourceforge.net/lists/listinfo/lazarus-ccr-general 일반] 메일링 리스트에 가입하세요.<br />
<br />
또한, [http://www.lazarus.freepascal.org/modules.php?op=modload&name=StaticPage&file=index&sURL=maill 라자루스] IDE 메일링 리스트와 [http://www.freepascal.org/maillist.html 프리파스칼] 개발자 또는 공지사항 메일링 리스트도 많은 도움이 될 것 입니다.<br />
<br />
==누가 무슨 작업을 하고 있나?==<br />
만약 당신이 현재 어떤 컴포넌트, 또는 라이브러리를 컨버팅 중이거나 그럴 필요를 느낀다면, 그 내용을 [[Current conversion projects|현재 변환중인 프로젝트]] 페이지에 올려주세요. 그렇게 함으로써 동일한 프로젝트를 두 사람 이상이 중복해 작업하는 일을 막을 수 있을 것입니다.<br />
<br />
==레퍼런스, 링크 그리고 리소스==<br />
<br />
===라자루스 IDE===<br />
라자루스 IDE에 대한 새 소식이나 정보는 [http://lazarus.freepascal.org 라자루스 IDE 웹사이트]에서 찾을 수 있습니다. 아이디어, 수정사항, 그리고 이후 개발계획은 [[Lazarus Development Process|라자루스 개발 프로세스]] 페이지를 참고하세요. 라자루스 IDE와 프리파스칼 컴파일러에 대한 다운로드도 그 곳에서 할 수 있습니다. 또한 [http://sourceforge.net/project/showfiles.php?group_id=89339 라자루스 파일 영역]에서 다운로드 가능한 컴파일러와 IDE의 최종 패키지를 얻을 수 있습니다..<br />
<br />
====라자루스 프로젝트의 활성화====<br />
<br />
[[Projects using Lazarus|라자루스 적용 프로젝트]] 페이지는 라자루스와 연관된 많은 자료에 대한 웹사이트와 다운로드 링크를 제공합니다. <br />
<br />
[[Lazarus Application Gallery|라자루스 어플리케이션 갤러리]]에서는 라자루스로 만들어진 어플리케이션의 스크린샷을 구경할 수 있습니다.<br />
<br />
====유용한 링크====<br />
[[Page Of Code Sites|코드 사이트 모음]] 페이지에서 델파이/카일릭스와 관련된 사이트들의 정보를 얻을 수 있습니다. 혹시라도 이 페이지에 없는 멋진 사이트를 알고 계시다면, 언제든지 추가 해 주세요.<br />
<br />
====특화된 검색엔진====<br />
새로운 기술과 문제 해결을 위해 온라인을 기반으로한 유용한 검색과 지식엔진이 있습니다. <br />
Tamarack 연합은 볼랜드 유즈넷의 문서들의 검색을 위해 특별히 빠른 [http://www.tamaracka.com/search.htm 검색엔진]을 운영합니다.<br />
Mer Systems Inc.는 유사한 [http://www.mers.com/searchsite.html 검색엔진]을 제공하고 있습니다.<br />
사이트 검색 능력을 진행하는 또 다른 정보소스는 Earl F. Glynnd의 컴퓨터랩과 레퍼런스 [http://www.efg2.com/ 라이브러리]입니다.<br />
<br />
====마케팅 사례 연구====<br />
[[Marketing_Case_Studies|라자루스 사용자들을 위한 기회]]로 라자루스가 왜 선택받은 IDE인지를 설명합니다.<br />
<br />
<br />
<br />
====FPC/라자루스 컨테스트와 전시회 출품====<br />
FPC/Lazarus는 독일 뮌헨의 [[Systems 2005]], [[Systems 2006]]과 [[Systems 2007]]에 부스를 만들어 출품 되었습니다. 이러한 전시회의 경험을 바탕으로한 [[Preparing a booth on a trade show|정보]]수집은 앞으로 전시회의 부스 준비를 돕기위해 만들어졌습니다.<br />
라자루스와 관련 프로젝트들은 그밖의 여러 컨테스트에 참여하고 있고 [[Contests|위키 페이지]]는 앞으로의 컨테스트 자료를위해 준비되고 있습니다.<br />
<br />
=Translations=<br />
<br />
* [[Main Page/ar | عربي (Arabic)]]<br />
* [[Main Page/es | Español (Spanish)]]<br />
* [[Main Page/de | Deutsch (German)]]<br />
* [[Main Page/fr | Français (French)]]<br />
* [[Main Page/id | Bahasa Indonesia (Indonesian)]]<br />
* [[Main Page/it | Italiano (Italian)]]<br />
* [[Main Page/ja | Japanese (Japanese)]]<br />
* [[Main Page/ko | Korean (한국어)]]<br />
* [[Main Page/nl | Nederlands (Dutch)]]<br />
* [[Main Page/pl | Polski (Polish)]]<br />
* [[Main Page/pt | Português (Portuguese)]]<br />
* [[Main Page/ru | Русский (Russian)]]<br />
* [[Main Page/sk | Slovensky (Slovak)]]<br />
* [[Main Page/fi | Suomi (Finnish)]]<br />
* [[Main Page/uk | Українська (Ukrainian)]]<br />
* [[Main Page/zh_CN | Chinese 中文(简体)]]<br />
* [[Main Page/zh_TW | Chinese 中文(正體)]]<br />
* [[Main Page/vn | Vietnamese (Việt Nam)]]<br />
<br />
=예전의 위키=<br />
이 페이지들은 예전의 위키포맷에서 변환되어져 왔습니다. 전의 위키페이지는 [http://lazarus-ccr.sourceforge.net/index.php?wiki=FrontPage 여기]에서 찾을 수 있습니다.<br />
<br />
원본 제공 [[User:VlxAdmin]].</div>Orankehttps://wiki.freepascal.org/index.php?title=Talk:Lazarus_Tutorial/ko&diff=32309Talk:Lazarus Tutorial/ko2008-11-26T16:41:38Z<p>Oranke: New page: 원 영어 페이지에 한글로 번역되어있기에 이 페이지로 옮겼습니다. 미처 한글 페이지를 준비 해 놓지 않은 것... 실수였구먼유~~</p>
<hr />
<div>원 영어 페이지에 한글로 번역되어있기에 이 페이지로 옮겼습니다. <br />
미처 한글 페이지를 준비 해 놓지 않은 것... 실수였구먼유~~</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Documentation/ko&diff=32308Lazarus Documentation/ko2008-11-26T16:25:22Z<p>Oranke: /* 라자루스와 파스칼 튜토리얼 */</p>
<hr />
<div>{{Lazarus Documentation}}<br />
<br />
==라자루스와 파스칼 튜토리얼==<br />
*[[Overview of Free Pascal and Lazarus/ko|프리파스칼과 라자루스 살펴보기]] - 간략한 소개글 입니다.<br />
*[[Lazarus Tutorial/ko|라자루스 튜토리얼]] - 라자루스 IDE에 대해 자세히 다루고 있는 초보자를 위한 설명서 입니다.<br />
*[[Lazarus IDE Tools|라자루스 IDE 툴]] - 코드 자동완성을 비롯한 기타 IDE의 내용들을 다루는 중급자용 설명서 입니다.<br />
*[[Lazarus Database Tutorial|라자루스 데이터베이스 튜토리얼]] - 데이터베이스 개발에 라자루스를 사용하기 위한 소개서 입니다.<br />
*[[Developing with Graphics|그래픽 개발]] - 그래픽 프로그래밍을 위한 기본적인 예제들 입니다.<br />
*[[Pascal Tutorial]] - [http://www.taoyue.com/ Tao Yue's] [http://www.taoyue.com/tutorials/pascal/ Pascal Tutorial] (reposted with permission).<br />
*[[Object Oriented Programming with FreePascal and Lazarus|프리파스칼과 라자루스를 사용한 객체 지향 프로그래밍]] - 파스칼 이상의 파스칼<br />
*[[Console Mode Pascal|콘솔 모드 파스칼]] - 라자루스 IDE를 사용해 텍스트 모드에서 구동되는 프로그램 만들기 입니다.<br />
*[[Executing External Programs|외부 프로그램 실행]] - 외부 프로그램을 실행시키는 방법에 대한 간단한 설명서 입니다.<br />
*[[TXMLPropStorage]] - Using TXMLPropStorage to save user preferences.<br />
*[[Hardware Access|하드웨어 제어]] - ISA, PCI카드, 패러랠, 시리얼, USB 디바이스 등의 하드웨어 접근법 입니다.<br />
*[[Networking|네트워킹]] - Tutorials about TCP/IP protocol, creating secure network programs, WebServices, etc.<br />
*[[XML Tutorial|XML 튜토리얼]] - XML 파일 읽고 쓰기에 대한 내용 입니다.<br />
*[[Multithreaded Application Tutorial|멀티쓰레드 어플리케이션 튜토리얼]] - 프리파스칼과 라자루스를 사용한 멀티쓰레드 어플리케이션 제작법 입니다.<br />
*[[Streaming components|스트리밍 컴포넌트]] - 스트림에 컴포넌트를 저장하고, 다시 읽어들여 생성하는 방법 입니다.<br />
*[[OpenGL Tutorial|OpenGL 튜토리얼]] - GLUT 라이브러리를 라자루스에서 사용하는 방법 입니다.<br />
*[[Creating bindings for C libraries|C 라이브러리와 연결]] - C 헤더파일을 (.h) 파스칼 유니트로 변환하는 방법에 대해 설명합니다.<br />
*[[Lazarus/FPC Libraries]] - How to create dynamic libraries (.so, .dll, .dylib) and how to use them<br />
*[[Translations / i18n / localizations for programs]] - How to provide localized versions of your programs and packages<br />
*[[Daemons and Services]] - 윈도의 서비스, 또는 리눅스의 데몬을 만드는 법에 대해 이야기 합니다.<br />
*[[Office Automation]] - How to interact with office software and create spreadsheets, text documents, presentations, etc.<br />
*[[Lazarus Inline Assembler]] - a getting started guide.<br />
*[[VirtualTreeview Example for Lazarus]] - Using VirtualTreeview on Lazarus.<br />
*[http://es.wikibooks.org/wiki/Programaci%C3%B3n_en_Pascal Programando en Pascal] - Spanish tutorial focused on FPC/Lazarus, hosted in Wikibooks.<br />
<br />
==라자루스 사용자 가이드==<br />
*[[Lazarus Faq/ko|라자루스 FAQ]] - 리눅스 및 윈도 유저를 위한 일반적인 정보들 입니다..<br />
*[[Lazarus DB Faq|라자루스 DB FAQ]] - 라자루스에서 DB를 다룰 때 만나는 문제들에 대한 FAQ 입니다.<br />
*[[Databases in Lazarus|라자루스와 데이터베이스]] - 라자루스에서 데이터베이스를 사용하는 것에 대한 간략한 안내 입니다.<br />
*[[Code Examples|예제 모음]] - 라자루스 예제 모음 입니다.<br />
*[[Feature_Ideas|Wishlist/Wanted Features]] - Features that you would like to see in Lazarus<br />
*[[How do I create a bug report]] - You think you found a bug in Lazarus, how can you report it?<br />
<br />
===설치하기=== <br />
*[[Installing Lazarus|라자루스 설치]] - 설치 방법에 대한 안내 입니다.<br />
*[[Getting Lazarus|라자루스 구하기]] - 라자루스의 릴리즈버전, 또는 SVN을 통한 개발버전을 얻는 방법에 대한 안내 입니다. <br />
*[[Multiple Lazarus|여러 버전의 라자루스]] - 한 대의 컴퓨터에 여러 버전의 라자루스를 설치하는 방법에 대한 안내 입니다. <br />
<br />
===IDE===<br />
*[[IDE tricks]] - Tips, tricks and hidden features<br />
*[[Lazarus IDE]] - The IDE windows<br />
*[[Lazarus IDE Shortcuts]] - The key mapping and shortcuts.<br />
*[[Lazarus Packages]] - A guide for creating a package under Lazarus<br />
*[[Install Packages]] - A small guide to install packages<br />
*[[Extending the IDE]] - How to add functionality to the Lazarus IDE<br />
*[[Adding Kylix Help]] - How to use the Borland Help files within the IDE editor.<br />
*[[Using Lazarus for other computer languages]] - How to use the IDE for C, Java, etc.<br />
*[[IDE Development]] - Various pages about current development of the IDE.<br />
<br />
===LCL===<br />
*[[doc:lcl/|LCL documentation]] - On line help for LCL (work in progress).<br />
*[[The LCL in various platforms]] - A brief discussion about LCL features which behave differently in different platforms.<br />
*[[Autosize / Layout]] - How to design forms that work on all platforms.<br />
*[[Main Loop Hooks]] - How to handle multiple event sources<br />
*[[Asynchronous Calls]] - How to queue methods for later execution<br />
*[[File size and smartlinking]] - How to smartlink applications and create smaller executables.<br />
*[[Accessing the Interfaces directly]] - Example how to access the LCL widgetsets<br />
*[[Add Help to Your Application]] - How to create a Online Help for your application<br />
*[[Anchor Sides]] - Description of Anchor Sides Feature<br />
*[[LCL Tips]] - Tips and tricks<br />
*[[LCL Defines]] - Choosing the right options to recompile LCL<br />
<br />
===Developing===<br />
*[[The Power of Proper Planning and Practices]] - common-sense programming best practices for the Free Pascal and Lazarus developer<br />
*[[Multiplatform Programming Guide]] - How to develop cross-platform applications and how to port from one platform to another<br />
*[[Using Pascal Libraries with .NET and Mono]] - yes, you can use your Free Pascal code with .NET and Mono<br />
*[[Deploying Your Application]] - How to create an installer for your application<br />
*[[Cross compiling]] - Creating executables of one platform, on another.<br />
*[[Remote Debugging]] - How to debug your Lazarus application from another machine.<br />
*[[Application Icon]] - Setting the application icon<br />
<br />
===플랫폼 별 유용한 팁===<br />
*[[OS X Programming Tips]] - Lazarus installation, useful tools, Unix commands, and more...<br />
*[[WinCE Programming Tips]] - Using the telephone API, sending SMSes, and more...<br />
<br />
===함께 하면 유용한 도구들===<br />
*[[Lazarus Documentation Editor]] - Using "lazde" to create documentation<br />
*[[LazDoc]] - An integrated editor for documentation files<br />
*[[FPDoc Updater]] - A GUI tool for updating FPDoc files<br />
*[[lazbuild]] - Compiling projects and packages without the IDE<br />
*[[LazSVNPkg]] - Lazarus SVN IDE Plugin<br />
<br />
===델파이 사용자를 위한 안내===<br />
*[[Lazarus Components|라자루스 컴포넌트]] - 라자루스와 터보델파이 컴포넌트들의 차이점에 대한 정보 입니다. <br />
*[[Lazarus For Delphi Users|델파이 사용자와 라자루스]] - 라자루스를 시작하려는 델파이 사용자를 위한 정보들 입니다.<br />
*[[Code Conversion Guide|코드 변환 가이드]] - 델파이와 카일릭스용 코드 및 컴포넌트를 라자루스에서 사용하는 방법에 대해 다룹니다.<br />
<br />
==라자루스 개발자 가이드==<br />
*[[Lazarus Development Process|라자루스 개발 프로세스]] - 로드맵, 아이디어, 그리고 현재.<br />
*[[How To Help Developing Lazarus|라자루스 개발을 돕는 법]] - 라자루스의 성능 개선을 위해 도움을 주려는 새로운 개발자가 참고할만한 내용들<br />
*[[Version Numbering|버전 번호 붙이기]] - 라자루스의 버전 번호의 차이점에 대한 설명 <br />
*[[Creating A Patch| 패치 만들기]] - 개선된 기능을 라자루스에 적용하기 위해 패치를 만드는 방법<br />
*[[Creating a Backtrace with GDB|GBD용 백트레이스 생성]] - 디버깅을 위해 백트레이스를 만드는 방법<br />
*[[Nomenclature/ko|이름 붙이기]] - 메소드나 프로퍼티에 이름 붙이는 방법에 대한 설명<br />
*[[DesignGuidelines/ko|디자인 가이드 라인]] - 라자루스 소스 코드 변경시 준수해야 할 규칙<br />
*[[GUI design]] - Notes on guidelines when designing the lazarus GUI<br />
*[[Roadmap]] - An idea of the current status of the various parts of Lazarus<br />
*[[Road To 1.0]] - What needs to be done for Lazarus 1.0 and To Do lists<br />
*[[Moderating the bug tracker]] - Guidelines for lazarus developers and moderators for using the [http://www.freepascal.org/mantis/ bug tracker].<br />
*[[Codetools]] - How the codetools are integrated into the IDE<br />
*[[Creating IDE Help]] - How to extend the IDE documentation<br />
*[[Unit not found - How to find units]] - How to setup the IDE and source files<br />
*[[Bounties]] - Need a particular new feature soon? Set a price here. <br />
<br />
===LCL - 라자루스 컴포넌트 라이브러리===<br />
*[[LCL Messages]] - Guide related to LCL Messages<br />
*[[LCL Internals]] - Some info about the inner workings of the LCL<br />
*[[LCL Key Handling]] - Help! A key press, what now?<br />
*[[LCL Internals - Resizing, Moving]] - How the LCL communicates with the LCL interface to resize, move controls<br />
*[[LCL Unicode Support]] - Road to Unicode enabled Lazarus<br />
*[[LCL Documentation Roadmap]] - Which units have to be documented<br />
*[[LCL Bindings]] - Bindings to use LCL on other languages<br />
<br />
===Interfaces===<br />
*[[Lazarus known issues (things that will never be fixed)]] - A list of interface compatibility issues<br />
*[[Win32/64 Interface]] - The winapi interface for Windows 95/98/Me/2K/XP/Vista, but not CE<br />
*[[GTK1 Interface]] - The gtk1.2 for Unixes, Mac OS X, Windows<br />
*[[GTK2 Interface]] - The gtk2 for Unixes, Mac OS X, Windows<br />
*[[Carbon Interface]] - The Carbon Interface for Mac OS X<br />
*[[Qt Interface]] - The Qt 4 Interface for Unixes, Mac OS X and linux-based PDAs<br />
*[[Windows CE Interface]] - For Pocket PC and Smartphones<br />
*[[fpGUI Interface]] - A widgetset completely written in Object Pascal<br />
*[[Cocoa Interface]] - The Cocoa Interface for Mac OS X<br />
<br />
===Translations===<br />
* [[Getting translation strings right]] A few notes for programmers on how to create and use translateable strings in your application. Quickly discusses general things about creating strings, offers a few hints on implementation issues and points out some things to consider when using English as base language in particular.<br />
* '''Localization Notes:'''<br />
:* [[German localization notes|German]] - Notes and guidelines for translating the Lazarus IDE to German, including a small dictionary to look up often used translations.<br />
:* [[Portuguese-Brazilian Localization Notes|Portuguese-Brazilian]] - Small dictionary containing common translations of terms used in the Lazarus IDE for the Portuguese-Brazilian translation.<br />
:* [[Russian localization notes|Russian]] - Notes and guidelines for translating the Lazarus IDE to Russian.<br />
<!-- *[[TO-DO]] Remaining Tasks --><br />
* [[Help:Add language bar | Add language bar]] explains how you can add a list of translations to the top of a wiki page.<br />
<br />
==Additional Components Documentation==<br />
*[[Pascal Script]] and [[Pascal Script Examples]] - How to use the pascal script components in Lazarus<br />
*[[OpenGL]] - How to use OpenGL in Lazarus<br />
*[[KOL-CE]] - Free Pascal/Lazarus port of KOL&MCK library. How to create very compact applications for Win32/WinCE in Lazarus.<br />
<br />
==Free Pascal Compiler Documentation==<br />
In addition to [http://lazarus-ccr.sourceforge.net/fpcdoc/ this site], the latest version of the documentation can also be found online and in a variety of downloadable formats on the main [http://www.freepascal.org/docs.html Free Pascal Compiler site].<br />
There is now also a WiKi site for FreePascal [http://www.freepascal.org/wiki/index.php/Main_Page] very similar in style to this one, to allow developers to submit documentation in addition to the official FPC documents below.<br />
<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/user/user.html User's guide]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/prog/prog.html Programmer's guide]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/ref/ref.html Reference guide for the system unit, and supported Pascal constructs]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/rtl/index.html Run-Time Library reference manual]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/fcl/index.html Free Component Library reference manual]<br />
*[http://lazarus-ccr.sourceforge.net/fpcdoc/fpdoc/fpdoc.html Free Pascal documentation tool manual]<br />
*[[Build messages]]<br />
<br />
==Lazarus related blogs and websites==<br />
'''Blogs'''<br />
*[[Adventures of a Newbie]] - A blog of a newbie getting started with some tutorial information in a running log.<br />
*[http://lazarusroad.blogspot.com/ On the road with Lazarus/Freepascal] - A blog dedicated to register my experiences while programming with Lazarus and Freepascal (by Luiz Américo)<br />
*[http://port2laz.blogspot.com/ Porting to Lazarus] - This blog describes the porting of a medium-sized application (~100 kloc) from D7 with CLX to Lazarus (by Alexsander da Rosa)<br />
*[http://living-lazarus.blogspot.com/ Living Lazarus] - One mans exploration into the possibilities of an open source RAD (by [[User:Wibblytim|Wibblytim]]).<br />
*[http://beeography.wordpress.com/tag/object-pascal/ Bee.ography] just (another) Bee’s buzz!<br />
*[http://donaldshimoda.blogspot.com/ Parallel Pascal Worlds] Donald Shimoda.<br />
<br />
'''Websites'''<br />
*[[swainbrain pascal wiki]] - unique free pascal tutorials and info [http://mercury.it.swin.edu.au/swinbrain/index.php/Pascal#Pascal_Development_Tools swainbrain]</div>Orankehttps://wiki.freepascal.org/index.php?title=Lazarus_Tutorial&diff=32305Lazarus Tutorial2008-11-26T16:20:55Z<p>Oranke: /* This page is default english page but korean string setted. */</p>
<hr />
<div>{{Lazarus Tutorial}}<br />
<br />
''This is the start of a Lazarus Tutorial. Please feel free to add your experiences to it.''<br />
== Overview ==<br />
Lazarus is a free and open source development tool for the FreePascal Compiler (object pascal), which is also free and open source. The Lazarus IDE ([http://lazarus-ccr.sourceforge.net/kbdata/lazide.jpg screenshot]) is a stable and feature rich programming environment for creating self-standing graphical and console applications. It currently runs on Linux, FreeBSD and Win32 and provides a customizable source editor and visual form creation environment along with a package manager, debugger and complete GUI integration with the FreePascal Compiler.<br />
<br />
== Getting Started - Your first Lazarus Program! ==<br />
<br />
(Thanks to [[User:Kirkpatc]])<br />
<br />
Get, install ([[Installing Lazarus]]) and launch Lazarus which will also make available the FreePascal Compiler.<br />
<br />
Several windows will appear on the desktop: the main menu at the top, the Object Inspector on the left, the Lazarus Source Editor occupying most of the desktop, and a ready-made Form1 window overlying the Source Editor.<br />
<br />
On the top Menu window, underneath the menu line, is a row of tabs. If the 'Standard' tab is not already selected, select it by clicking with the mouse. Then find the Button icon (a rectangle with 'OK' on it) and click on that with the mouse. Then click on the Form1 window, somewhere to the left of the middle. A shadowed rectangle labelled 'Button1' will appear. Click again on the Button icon in the Standard tab, and click on the Form1 somewhere to the right of centre: a rectangle labelled 'Button2' will appear.<br />
<br />
Now click on Button1 to select it. The Object Inspector will display the properties of the object Button1. Near the top is a property named 'Caption', with the displayed value 'Button1'. Click on that box, and change 'Button1' to 'Press'. If you hit ENTER or click in another box, you will see the label of the first button on Form1 change to 'Press'. Now click on the Events tab on the Object Inspector, to see the various events that can be associated with the button. These include OnClick, OnEnter, OnExit etc. Select the box to the right of OnClick: a smaller box with three dots (... ellipsis) appears. When you click on this, you are taken automatically into the Source Editor and your cursor will be placed in a piece of code starting:<br />
<br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin<br />
{now type:} Button1.caption := 'Press again';<br />
{the editor has already completed the procedure with}<br />
end;<br />
<br />
Press F12 to select the Form1 window instead of the Source Editor.<br />
<br />
Now edit the properties of Button2: click on Button2 to display its properties in the Object Inspector. Change its Caption property to 'Exit' instead of 'Button2'. Now select the Events tab, and click on the box for OnClick. Click on the ... ellipsis, and you will be taken into the Source Editor, in the middle of another procedure:<br />
<br />
procedure TForm1.Button2Click(Sender: TObject);<br />
begin<br />
{now type:} Close;<br />
{the editor has already completed the procedure with} <br />
end;<br />
<br />
Now Press F12 to see the Form1 window again. You are now ready to try to compile. The simplest way to do this is to select 'Run' from the main menu at the top, and then the 'Run' option on the sub-menu. Alternatively you could simply type F9. This will first compile and then (if all is well) link and execute your program.<br />
<br />
Several text windows will appear and all sorts of compiler messages will be typed, but eventually your Form1 window will re-appear, but without the grid of dots; this is the actual main window of your application, and it is waiting for you to push buttons or otherwise interact with it.<br />
<br />
Try clicking on the button labelled 'Press'. You will notice that it changes to 'Press again'. If you press it again, it will still say 'Press again'!!<br />
<br />
Now click on the button marked 'Exit'. The window will close and the program will exit. The original Form1 window with the grid of dots will reappear, ready to accept more editing activity.<br />
<br />
You should save your work now (and frequently!!) by selecting Project > Save Project As > your_selected_file_name.pas<br />
<br />
=== Second session. ===<br />
Re-open your saved Project.<br />
On the Form1 window click on the 'Press' button (Button1) to select it.<br />
Select the 'Events' tab on the Object Inspector, click on the right side box next to OnClick, click on the ... ellipsis, to go back to the appropriate point in the Source Editor.<br />
<br />
Edit your code to read as follows:<br />
<br />
procedure TForm1.Button1Click(Sender: TObject);<br />
{Makes use of the Tag property, setting it to either 0 or 1}<br />
begin<br />
if Button1.tag =0 then<br />
begin<br />
Button1.caption := 'Press again';<br />
Button1.tag := 1<br />
end else<br />
begin<br />
Button1.caption := 'Press';<br />
Button1.tag := 0<br />
end<br />
end;<br />
<br />
Save your work, re-compile and run. The left button will now toggle between two alternative messages.<br />
<br />
The rest is up to you!<br />
<br />
If you prefer to write Console- or text-based Pascal programs (for example if you are following a basic Pascal programming course, or you need to write programs to use in batch mode or for system programming), you can still use Lazarus to edit, compile and run your programs. It makes an ideal environment for Pascal development. See [[Console Mode Pascal]].<br />
<br />
== The Editor ==<br />
When you launch Lazarus for the first time, a series of separate disconnected or 'floating' windows will appear on your desk-top.<br />
<br />
The first, running right along the top of the desk-top, is titled '''Lazarus Editor vXXXXXX - project1''' (which will subsequently be modified to reflect the name of your currently-open project). This is the main controlling window for your project, and contains the Main Menu and the Component Palette.<br />
<br />
<center>[[Image:LazMain_GTK2.png]]</center><br />
<br />
On the line below the title bar is the ''Main Menu'' with the usual entries for File, Edit, Search, View functions and so on, with a few selections that are specific to Lazarus.<br />
Below this on the left is a set of BitButtons (which take you rapidly to particular Main Menu options) and on the right is the Component Palette.<br />
<br />
Under the Lazarus Editor window will appear the '''[http://lazarus-ccr.sourceforge.net/kbdata/objinsp.jpg Object Inspector]''' window on the left, and the '''[http://lazarus-ccr.sourceforge.net/kbdata/editor.jpg Lazarus Source Editor]''' on the right. There may be another smaller window, labelled '''[http://lazarus-ccr.sourceforge.net/kbdata/blankform.jpg Form1]''', overlying the Lazarus Source Editor window. If this is not visible immediately, it can be made to appear by pressing the '''F12''' key, which toggles between the Source Editor view and the Form view. The Form window is the one on which you will construct the graphical interface for your application, while the Source Editor is the window which displays the Pascal code associated with the application which you are developing. The operation of the Object Inspector is discussed in more detail below while the Component Palette is described.<br />
<br />
When you start a new project (or when you first launch Lazarus) a default Form will be constructed, which consists of a box in which there is a grid of dots to help you to position the various components of the form, and a bar along the top which contains the usual '''Minimise''', '''Maximise''' and '''Close buttons'''. If you click with your mouse cursor anywhere in this box, you will see the properties of this form displayed in the Object Inspector on the left side of the desk-top.<br />
<br />
Other windows that may become visible during your work: the '''[http://lazarus-ccr.sourceforge.net/kbdata/projinsp.jpg Project Inspector]''', which contains details of the files included in your project, and allows you to add files to or delete files from your project; the '''Messages''' window, which displays compiler messages, errors or progress reports on your project; if Lazarus was launched from a terminal window, the original terminal remains visible and detailed compiler messages are also printed there.<br />
<br />
<br />
=== The Main Menu ===<br />
<br />
The main menu line contains the following entries:<br />
<u>F</u>ile <u>E</u>dit <u>S</u>earch <u>V</u>iew <u>P</u>roject <u>R</u>un <u>C</u>omponents <u>T</u>ools E<u>n</u>vironment <u>W</u>indows <u>H</u>elp<br />
<br />
As usual, the options can be selected either by placing the mouse cursor over the menu option and clicking the left mouse button, or by typing Alt-F on the keyboard (provided the main menu window has focus: if it has not, hit TAB repeatedly to cycle focus through the various windows until the desired window has its title bar highlighted in colour).<br />
<br />
==== The File sub-menu ====<br />
<div class="floatright"> [[Image:FileMenu.png]] </div><br />
* '''New Unit''': Creates a new Unit file (Pascal Source).<br />
* '''New Form''': Creates a new Form: both the visual on-screen window and the associated Pascal source file.<br />
* '''New ...''': Offers a pop-up menu box ([http://lazarus-ccr.sourceforge.net/kbdata/menu-new.jpg screenshot]) with a variety of new document types to create.<br />
* '''Open''': Offers a pop-up Dialog Box to enable you to navigate the filesystem and choose an existing file to open.<br />
* '''Revert''': Abandon editing changes and restore the file to its original state. <br />
* '''Open Recent''': Offers a list of recently edited files, and an opportunity to select one.<br />
* '''Save''': Save the current file, using its original filename. If there is no name, the system will prompt for one (just like Save As).<br />
* '''Save As''': Allows you to choose a directory and filename for saving the current file.<br />
* '''Save All''': Saves all the files attached to the editor, not just the current one selected.<br />
* '''Close''': Closes the current file, prompting whether to save all editor changes.<br />
* '''Close all editor files''': Close all files currently open in the editor. Prompt for saving changes.<br />
* '''Clean directory''': Offers a dialog with a series of editable filters for removing files from the current directory. Useful for removing .bak files and remnants of former Delphi projects.<br />
* '''Print''': Uses the system printer to print the selected file. This menu item does not appear by default; you need to install $Lazdir/components/printers/design/printers4lazide.pas and re-compile the IDE<br />
* '''Restart''': Re-start Lazarus - useful if files have got hopelessly scrambled!<br />
* '''Quit''': Exit Lazarus, after prompting for saving all edited files.<br />
<div style="clear:both;"></div><br />
<br />
==== The Edit sub-menu ====<br />
<div class="floatright"> [[Image:EditMenu.png]] </div><br />
* '''Undo''': Undo the last edit action, leaving the Editor in the state just before the last action.<br />
* '''Redo''': Re-instates the last action that was reversed by Undo.<br />
* '''Cut''': Remove the selected text or other item and place it on the Clipboard.<br />
* '''Copy''': Make a copy of the selected text, leaving the original in place, and placing the copy on the Clipboard.<br />
* '''Paste''': Places the contents of the Clipboard at the cursor position. If text has been selected at the cursor position, the contents of the Clipboard will replace the selected text.<br />
* '''Indent selection''': Move the selected text to the right by the amount specified in Environment -> Editor options -> General -> Block indent. This feature is useful for formatting your Pascal source code to show the underlying Block structure.<br />
* '''Unindent selection''': Removes one level of indenting, moving the text to the left by the amount specified in Block indent.<br />
* '''Enclose selection''': Provides a pop-up menu with a number of options for logically enclosing the selected text (begin ... end; try ... except; try ... finally; repeat ... until; { ... } etc).<br />
* '''Uppercase selection''': Convert selected text to uppercase.<br />
* '''Lowercase selection''': Convert selected text to lowercase.<br />
* '''Tabs to spaces in selection''': Converts any tabs in the selected text to the number of spaces specified by Environment -> Editor options -> General -> Tab widths. The number of spaces is not a fixed quantity, but is the number needed to fill the remaining width of the tab.<br />
* '''Break lines in selection''': If any lines in the selected text are longer than 80 characters or the number specified in Environment -> Editor options -> Display -> Right Margin, then the line is broken at a word boundary and continued on the next line.<br />
* '''Comment selection''': Makes the selected text into [[Comments|comments]] by inserting // on each line.<br />
* '''Uncomment selection''': Removes comment marks.<br />
* '''Sort selection''': Sort lines (or words or paragraphs) alphabetically; options for ascending or descending order, case sensitive or insensitive. In the middle of program source code, of course, it makes no sense, but if you have a list you need to have sorted this will do the trick.<br />
* '''Select''': Allows selection of blocks of text. Options include select all, select to brace, select paragraph or line etc.<br />
* '''Insert from character map''': Allows insertion of non-keyboard symbols such as accented characters, picked from a pop-up character map.<br />
* '''Insert text''': Displays pop-up menu to allow insertion of standard text such as CVS keywords (Author, Date, Header etc) or GPL notice, username or Current date and time.<br />
* '''Complete code''': Completes the code at the cursor. It is context sensitive and saves you a lot of time. For example: it completes classes, by adding private variables, Get and Set property access methods and adding method bodies. On variable assignments (e.g. i:=3;) it adds the variable declarations. On forward defined procedures it adds the procedure bodies. On event assignments (OnClick:=) it adds the method definition and the method body. See [[Lazarus IDE Tools]].<br />
* '''Extract procedure''': Uses the selected text (a statement or series of statements) to build a new procedure.<br />
<div style="clear:both;"></div><br />
<br />
==== The Search sub-menu ====<br />
<div class="floatright"> [[Image:SearchMenu.png]] </div><br />
* '''Find''': Similar to the facility in almost all graphic text editors: a pop-up dialog box appears allowing entry of a search text string, with options such as case sensitivity, whole words, origin, scope and direction of search.<br />
* '''Find Next, Find previous''': Search again for the previously entered text string, in the specified direction.<br />
* '''Find in files''': Search for text string in files: pop-up dialog with options all open files, all files in project, or all directories; masks available for selecting file types.<br />
* '''Replace''': Similar to '''Find'''; shows pop-up dialog with place to enter search text string and replacement text, and options for case sensitivity, direction etc.<br />
* '''Incremental find''': Search for the string while you are entering the search string. Example: after you choose "Incremental Find" if you press "l" the first "l" will be highlighted. If then you press "a", the editor will find the next "la" and so on.<br />
* '''Goto line''': Move editing cursor to specified line in file.<br />
* '''Jump back''': Jump to previous position. Everytime jumping to an error or find declaration the IDE saves the current source position. With this function you can jump back in the history.<br />
* '''Jump forward''': Jump to next position. Undoes a Jump back.<br />
* '''Add jump point to history''': Add the current source position to the jump hsitory.<br />
* '''View Jump-History''': Look at list of jump points: '''Not implemented yet'''.<br />
* '''Jump to next error''', '''Jump to previous error''': Jump to the positions in the source file of the next or previous reported error.<br />
* '''Set a free bookmark''': mark the current line where the cursor is located with the next available (free) numbered bookmark, and add this to the list of bookmarks. Note that a pop-up menu (obtained by right-clicking with the mouse on the appropriate line of the source file) gives a larger range of Bookmark options, allowing the number of a bookmark to be specified, or allowing the user to jump to a numbered bookmark, not just the next or previous ones.<br />
* '''Jump to next bookmark''', '''Jump to previous bookmark''': Jump to next or previous bookmark in the numerical sequence.<br />
* '''Find other end of code block''': If positioned on a '''begin''', finds the corresponding '''end''' or vice versa.<br />
* '''Find code block start''': Moves to the '''begin''' of the procedure or function in which the cursor is placed.<br />
* '''Find Declaration at cursor''': Finds the place at which the selected identifier is declared. This may be in the same file or another file already open in the Editor; if the file is not open, it will be opened (so if a procedure or function is declared, for example, in <u>classesh.inc </u>, this will be opened in the Editor).<br />
* '''Open filename at cursor''': Opens the file whose name is selected at the cursor. Useful for looking at <u>Include </u> files or the files containing other <u>Units </u> used in the project.<br />
* '''Goto include directive''': If the cursor is positioned in a file which is <u>Included</u> in another file, goes to the place in the other file that called the <u>Include</u> file.<br />
'''<div style="clear:both;"></div><br />
* '''Find Identifier References''': Produces a list of all the lines in the current file, or the current project or all attached files, in which an identifier is mentioned.<br />
* '''Rename Identifier''': Allows developer to rename an identifier. A pop-up menu asks the developer to specify whether renaming is to occur in the current file only, or throughout the project, or in all open or attached files etc. You can even rename the identifier if it occurs in comments. You would use this feature, for example, if the compiler told you that an identifier already existed, so you need a new name for your own identifier.<br />
* '''Procedure List''': Produces a list of all Procedures and Functions in the current file, with the line numbers where they are defined.<br />
<br />
==== The View sub-menu ====<br />
<div class="floatright"> [[Image:ViewMenu.png]] </div><br />
Controls the display of various windows and panels on the screen.<br />
* '''Object Inspector''': The window that usually occupies the left side of the Desktop, and displays the features of the Form which is on the desktop. Clicking with the mouse on any component of the form will cause the details of that component to be displayed in the Object Inspector. There is a panel at the top which shows the tree-structure of the current project, and the components of the form may optionally be selected in this panel: this will also cause the corresponding details to be displayed in the Object Inspector. The main lower panel has two tabs which allow selection of either '''Properties''' or '''Events''' to be displayed. Selection of '''Properties''' causes features such as name, color, caption, font, size etc to be displayed: there are two columns, the left showing the property, and the right showing the value associated with that property. Selection of '''Events''' displays two columns: the left lists the possible events such as MouseClick or KeyDown associated with that component, and the right shows the action that results from that event. If there is no action defined, then clicking in the appropriate box or on the <div class="box">...</div> button causes the Source Editor to be displayed, with the cursor already positioned in a dummy Procedure declaration, waiting for event-defining code to be typed in.<br />
* '''Source Editor''': The main window in which source code is edited. Its behaviour is very like that of most other graphical text editors, so that the mouse can move the cursor over the displayed text, and clicking with the left mouse button while dragging the mouse will select and highlight text. Right clicking with the mouse displays a pop-up menu, it includes the usual Edit Cut, Copy or Paste functions, ''Find Declaration'' and ''Open File at Cursor''. The top of the Source Editor window has a number of tabs, corresponding to the files that are open for the current project; clicking on any tab makes that file visible, and you can move easily from file to file, copying and pasting between files and performing most of the normal editing functions. The Source Editor performs color syntax highlighting on the code, with different colors for punctuation marks, comments, string constants etc. It will also maintain the level of indentation from line to line as you type in code, until you change the indentation. The function and appearance of the Source Editor are very configurable from the Main Menu by selecting Environment -> Editor options and then selecting one of several tabs in the pop-up dialog box.<br />
* '''Code Explorer''': A window usually placed on the right of the Desktop which displays, in tree form, the structure of the code in the current unit or program. It usually opens with just the Unit name and branches for Interface and Implementation sections, but clicking on the <div class="box">+</div> box to the left of any branch will open up its sub-branches or twigs, in more and more detail until individual constants, types and variables are displayed as well as procedure and function declarations. If you change the file displayed in the main Source Editor window, you need to click on the Refresh button of the Code Explorer to display the structure of the new file.<br />
* '''Units...''': Opens a pop-up dialog window with a list of the unit files in the current project.Clicking with the mouse on a filename selects that file; click on Open to display that file in the Source Editor. Checking the Multi box allows several files to be selected simultaneously, and they will all be opened in the Source Editor (but only one at a time will be displayed). This Menu Option is rather like the Project -> Project Inspector option, but only displays the list of Unit files and allows them to be opened.<br />
* '''Forms...''': Opens a pop-up dialog window with a list of the Forms in the current project, and allows the selection of one or more of them for display.<br />
* '''View Unit Dependencies''': Opens a pop-up dialog window that shows, in a tree-like manner, the structure of dependencies of the currently open unit file. Most of the files listed as dependencies will have their own <div class="box">+</div> boxes, which allow the dependencies of the individual files to be explored, often in a highly recursive manner.<br />
* '''Toggle form / unit view F12''': Toggles whether the Source Editor or the current Form is placed on the top layer of the Desktop, and given focus. If the Source Editor has focus, then you can edit the source code; if the Form is given focus, you can manipulate the components on the desktop and edit the appearance of the Form. The easiest way to toggle the display between Editor and Form is to use the F12 key on the keyboard, but the same effect is achieved by selecting this option on the Main Menu.<br />
* '''Messages''': A window that displays compiler messages, showing the progress of a successful compilation or listing the errors found.<br />
* '''Search Results''': A window that displays the results of find in files.<br />
* '''Debug windows''': Opens a pop-up menu with several options for operating and configuring the Debugger. See below where the [[#The_Debugger|debugger]] is described.<br />
<div style="clear:both;"></div><br />
<br />
==== The Project sub-menu ====<br />
<div class="floatright"> [[Image:ProjectMenu.png]] </div><br />
* '''New Project''': Create a new project. A pop-up dialog window appears offering a choice of types of project to create.<br />
* '''New Project from file''': A Navigation dialog window appears, alowing selection of a file from which to create a new project.<br />
* '''Open Project''' Open a project which has already been created and saved. A navigation dialog appears with a list of Lazarus Project Information (.lpi) files from which a project may be chosen.<br />
* '''Open Recent Project''': Displays a pop-up list of recent projects on which you have been working, and allows selection of one of these.<br />
* '''Save Project''': Similar to File -> Save: all the files of the current project are saved; if they have not previously been saved, there is a prompt for filename(s)- similar to Save Project As...<br />
* '''Save Project As...''': Prompts for filename to save project. A default filename of Project1.lpi is offered, but you should choose your own filename. Lazarus will not permit you to use the same name for the Project file and the Unit File (see [[Lazarus Tutorial#The_Lazarus_files| below]]).<br />
* '''Publish Project''': Creates a copy of the whole project. If you want to send someone just the sources and compiler settings of your code, this function is your friend. A normal project directory contains a lot of information. Most of it is not needed to be published: the .lpi file contains session information (like caret position and bookmarks of closed units) and the project directory contains a lot of .ppu, .o files and the executable. To create a lpi file with only the base information and only the sources, along with all sub directories use "Publish Project". In the dialog you can setup the exclude and include filter, and with the command after you can compress the output into one archive. See [[Lazarus IDE Tools]]<br />
* '''Project Inspector''': Opens a pop-up dialog with a tree-like display of the files in the current project. Allows you to add, remove or open selected files, or change options of the project.<br />
* '''Project Options...''': Opens a pop-up dialog window with tabs for setting options for Application (Title, Output Target file name), Forms (allowing you to select among the available forms, make them Auto-create at start of application) and Info (specifying whether editor information should be saved for closed files, or only for project files).<br />
* '''Compiler options ...''': (Recently moved here from the Run Menu). Opens a multi-page tabbed window which allows configuration of the compiler. Tabs include '''Paths''' which allows definition of search paths for units, include files, libraries etc, as well as allowing choice of widget type for the forms (gtk, gnome, win32); '''Parsing''' which allows choice of rules for parsing source programs, '''Code''' which allows choice of optimisation for faster or smaller programs, choice of target processor, types of checks, heap size etc; '''Linking''' allowing choice of whether or how to use debugging, static or dynamic libraries, and whether to pass options through to the linker; '''Messages''' to define what type of messages should be generated during error conditions; '''Other''' which allows decision to use default configuration file (fpc.cfg) or some other file; '''Inherited''' which shows a tree structure diagram to indicate how options have been inherited from units already incorporated; '''Compilation''' which allows definition of commands to be executed before or after the compiler is launched and can allow use of Make files. <br />
* '''Add editor file to Project''': Add the file currently being edited to the Project<br />
* '''Remove from Project''': Gives a pop-up menu of files available for removal from project.<br />
* '''View Source''': No matter which file you are editing, takes you back to the main program file (.lpr)or the main .pas file if there is no .lpr.<br />
* '''View ToDo List''':Opens a dialog box with a list of ToDo items associated with this project. This will list any ToDo comments in your project (lines commencing //TODO), and any others in the Lazarus units you have used. You need to Refresh the ToDo items in the dialog (using arrow symbol button of toolbar) before new 'ToDos' appear. The first column of the ToDo list contains numbers you have allocated to your ToDo comments; a simple //TODO comment will appear as a zero, but a comment of //TODO999 (for example) will place the number 999 in the first column. Remember there should be no spaces on the line before //TODO and ToDo comments added after the last save will not be shown!<br />
<br />
==== The Run sub-menu ====<br />
<div class="floatright"> [[Image:RunMenu.png]] </div><br />
* '''Build''': Causes Lazarus to build (ie compile) any files in the project that have been changed since the last build.<br />
* '''Build all''': Builds all files in the project, whether or not there have been any changes.<br />
* '''Abort build''': Stop the build process once it is running - either you have remembered that you did something silly and want to stop the build, or the system seems to be taking far too long and something is obviously wrong.<br />
<br />
* '''Run''': This is the usual way to launch the compiler and, if compilation is successful, to start execution of the application. What actually happens is that Lazarus saves a copy of your files, then starts the compiler and linker, then begins execution of the final linked binary program.<br />
* '''Pause''': Suspend execution of the currently running program. This may allow you to inspect any output that has been generated; execution may be resumed by selecting '''Run''' again.<br />
* '''Step into''': Used in conjunction with the debugger, causes execution of the program one step at a time up to a bookmarked point in the source.<br />
* '''Step over''': Causes stepwise execution up to the statement marked, then skips the marked statement, and continues execution at normal speed. Useful in trying to isolate a statement that introduces a logical error.<br />
* '''Run to cursor''': Causes execution at normal speed (ie NOT one statement at a time) until the statement is reached where the cursor is located; then stops. Resume execution at normal speed by selecting '''Run'''.<br />
* '''Stop''': Cease execution of the running program. Cannot be resumed by selecting '''Run'''; this will start the program again from the beginning (re-compiling if necessary).<br />
<br />
* '''Run Parameters''': Opens a multi-page pop-up window which allows command-line options and parameters to be passed to the program to be executed; allows selection of display to run program (eg a remote X terminal may be used in Linux); some system Environment variables may be overridden.<br />
: One very important use of this sub-menu is to activate a terminal window in which conventional Pascal console input/output is displayed. If you are developing a console-mode Pascal program (ie one that doesn't use the Graphical User Interface with its forms, buttons and boxes) then you should check the box for "Use launching application". The first time you do this and try the Compile/Run sequence, you will probably get a rude message to say <br />
"xterm: Can't execvp /usr/share/lazarus//tools/runwait.sh: Permission denied". <br />
: If this happens, you need to change the permissions on the appropriate file (for example using chmod +x ''filename'', or using the Windows utility for changing permissions); you might have to do this as root. After this, each time you launch you program, a console box will appear and all your text i/o (readln, writeln etc) will appear in it.<br />
: After your program has finished execution, a message "Press enter" appears on the screen. Thus any output your program generated will remain on the screen until you have had a chance to read it; after you press 'enter' the console window closes.<br />
: '''Note:''' as for the current version, there is no prepared console command for Windows users. Until the Lazarus team adressess that, the following line should work (on WinXP -- someone please update for other Windowses)<br />
C:\Windows\system32\cmd.exe /C ${TargetCmdLine}<br />
: See the separate tutorial on [[Console Mode Pascal]] programming.<br />
* '''Reset debugger''': Restores the debugger to its original state, so that breakpoints and values of variables etc are forgotten.<br />
<br />
* '''Build file''': Compile (build) just the file that is currently open in the Editor.<br />
* '''Run file''': Compile, link and execute just the currently open file.<br />
* '''Configure Build + Run File''': Opens a multi-page tabbed window with options to allow for build of just this file when '''Build Project''' is selected, allows selection of the working directory, the use of various Macros, etc. Then Builds and Runs the file.<br />
:These last three options enable you to open (and maintain) a test project. Use File -> Open to open an .lpr file, pressing cancel on the next dialog to open this file as "normal source" file. <br />
<br />
<div style="clear:both;"></div><br />
<br />
==== The Package sub-menu ====<br />
* '''Open Package''': Displays a [http://lazarus-ccr.sourceforge.net/kbdata/OpenPackageSnapshot.png list of installed packages], with an invitation to [http://lazarus-ccr.sourceforge.net/kbdata/PackageContentsSnapshot.png open one or more of them], or to select various general or compiler options.<br />
* '''Open Package File''': Open one of the files in the selected package.<br />
* '''Open Recent Package''': Open a package that was opened recently.<br />
* '''Add Active Unit to Package''': Place the unit file (currently in the editor) into a package.<br />
* '''Package Graph''': Displays a [http://lazarus-ccr.sourceforge.net/kbdata/PackageGraphSnapshot.png graph] showing the relationships of the packages currently being used (if you aren't using any other packages, the Lazarus package and the FCL and LCL will be displayed).<br />
* '''Configure custom components''': If you have created some components, allows you to configure them.<br />
<br />
==== The Tools sub-menu ====<br />
<div class="floatright"> [[Image:ToolsMenu.png]] </div><br />
* '''Configure custom tools''': Allows the user to add various external tools (usually macros) to the toolkit<br />
* '''Quick syntax check''': Perform a quick check of the syntax in your source file without actually compiling anything. Essential step in developing long or complicated programs, where you don't want to waste time compiling if the code is wrong.<br />
* '''Guess unclosed block''': useful utility if you have a complex nested block structure and you have left out an 'end' somewhere<br />
* '''guess misplaced IFDEF/ENDIF''': useful if there is a complex or nested macro structure and you think you have left out an ENDIF directive<br />
* '''Make resource string''': Makes the selected string a resource string by placing it in the resourcestrings section. An advantage of resource strongs is you can change them without the need to recompile your project! <br />
* '''Diff''': Allows comparison between two files (or, usually, two versions of the same file) to find differences. Options to ignore white space at beginning or end of lines or differences in line termination: CR+LF versus LF). Useful for checking if there have been changes since last CVS update etc.<br />
* '''Check LFM file in editor''': Allows inspection of the LFM file which contains the settings that describe the current form<br />
* '''Convert Delphi unit to Lazarus unit''': Helps in porting Delphi applications to Lazarus; makes the necessary changes to the source file. See [[Lazarus For Delphi Users]] and [[Code Conversion Guide]].<br />
* '''Convert DFM file to LFM''': For porting from Delphi to Lazarus: converts the Form Description files from Delphi to Lazarus. See [[Lazarus For Delphi Users]] and [[Code Conversion Guide]].<br />
* '''Build Lazarus''': Launches a re-build of Lazarus from the most recently downloaded or updated SVN files. Hit the button and sit back to watch it happen! (track the process on your '''Messages''' window).<br />
* '''Configure "Build Lazarus"''': Allows the user to determine which parts of Lazarus should be re-built, and how. For example, you could select to have just the LCL re-built, or to have everything except the examples built; you can select which LCL interface to use (ie which set of widgets), and you can select the target operating system and specify a different target directory.<br />
<div style="clear:both;"></div><br />
<br />
==== The Environment sub-menu ====<br />
<div class="floatright"> [[Image:EnvironmentMenu.png]] </div><br />
* '''Environment options''': Displays a multi-page window with tabs for<br />
** '''Files''' - allowing the user to specify path to default directory, compiler, source directory and temporary directory for compilation; <br />
** '''Desktop''' - options for Language, Auto save behaviour, saving desktop properties, hints for component palette and speed buttons; <br />
** '''Windows''', to allow specification of size and behaviour of the various windows; <br />
** '''Form Editor''' - choose colours for editing forms; <br />
** '''Object Inspector''' - choose colour and height of items; <br />
** '''Backup''' - specify how to backup files when editing; <br />
** '''Naming''' - specify what extension to use in naming pascal files ('.pp' or '.pas'), whether to save files with names in lowercase, whether to perform auto-delete or auto-rename.<br />
* '''Editor options''': Multi-page window, with tabs for <br />
** '''General''' - determines behaviour like auto-indent, bracket highlighting, drag-drop editing, scrolling, syntax highlighting, showing hints, size of block indent and tabs, limit of Undo; <br />
** '''Display''' - options for showing line numbers, presence of gutters, size and type of font for editor, and contains a preview panel showing the colours of the various syntax features such as comments, directives, punctuation, errors and breakpoints; <br />
** '''Key Mappings''' - options to select Lazarus or Turbo Pascal scheme; <br />
** '''Color''' - allows choice of colour scheme for text features, for a number of language types such as Object Pascal, C++, Perl, HTML, XML and shell scripts. It shows preview panel again (for whichever language is selected); <br />
** '''Code Tools''' - allows selection of features like Identifier Completion, tooltips, specification of template file names, specific templates for code completion.<br />
* '''Debugger Options''': Multi-page window with tabs for <br />
** '''General''' - choose debugger: none, GNU debugger (gdb) or gdb through SSH, specify search paths for debuggers,and specific options for chosen debugger; <br />
** '''Event log''' - specify whether to clear log on run, and which messages to display; <br />
** '''Language Exceptions''' - select which exceptions can be ignored; <br />
** '''OS Exceptions''' - allows user to add certain signals which apply to current operating system (not implemented).<br />
* '''Code Tool Options''': Multi-page window, tabs for <br />
** '''General''' - Allows entry of additional source search paths, specify Jumping Method; <br />
** '''Code Creation''' - determines whether created code is added before or after certain features; <br />
** '''Words''' - determines whether Pascal keywords are to be entered in upper or lower case, or as Capitalised Words; <br />
** '''Line Splitting''' - establish rules about where lines are allowed to be split (before or after punctuation, after keywords etc); <br />
** '''Space''' - decide whether a space is to be added automatically before or after certain syntactic features such as keywords or punctuation marks. <br />
* '''Code Tools Defines Editor''': Here you can see all IDE internal definitions to parse sources. You will see all the defines, unit, source, include paths for all source directories. Beginning with the settings of the current FPC, the defines for the Lazarus Source directory, all package directories and project directories.<br />
Most of these settings are auto generated and read only.<br />
<br />
<br />
* '''Re-scan FPC Source directory''' Looks through the directory again. Lazarus uses the fpc sources to generate correct event handlers and while looking for declarations. If somebody changes the directory in the environment options, then this directory is rescanned, to make sure lazarus uses the version stored in that location. But if this directory has changed without lazarus noticing, then you may get some errors when designing forms or doing "Find declaration". If you get such an error, you can do two things:<br />
*# Check the fpc source directory setting in the environment option.<br />
*# Re-scan FPC source directory.<br />
<br />
==== The Windows sub-menu ====<br />
<div class="floatright"> [[Image:WindowsMenu.png]] </div><br />
Contains a list of the currently opened files and the available windows such as '''Source Editor''', '''Object Inspector''' and '''Project Inspector'''. Clicking on the name of one of the windows brings it to the foreground and gives it focus.<br />
<div style="clear:both;"></div><br />
<br />
==== The Help sub-menu ====<br />
<br />
At present this has three selections:<br />
* '''Online Help''' which at present opens a browser window that contains a picture of the running cheetah and a few links to the Lazarus, FreePascal and WiKi websites<br />
* '''Reporting a bug''' opens the [[How_do_I_create_a_bug_report|wiki page]], which describe the bug reporting procedure<br />
* '''Configure Help''' which opens a pop-up menu with options to select viewers and databases from which to read Help information. This option allows the user to specify either the on-line documents section of the Lazarus-CCR website, some other website containing the documents, or a local store for the documentation (this would eventually become the default, when the Help system is fully developed).<br />
At present by default, if you place your Editor cursor over any keyword from the FreePascal Components Library FCL, the RunTime Library RTL or the Lazarus Components Library LCL, and then press <<F1>> you will be taken by your default browser to the appropriate definition on the website. Be aware that your browser may be located on another desktop on your machine (eg in Linux), and you may not see the information immediately; of course if you are not connected to the internet you cannot get this information. THIS SECTION STILL REPRESENTS WORK IN PROGRESS<br />
<br />
* '''About Lazarus''' Displays a pop-up box with some information about Lazarus.<br />
<br />
Eventually there will be a full on-line Help service, with information about Pascal syntax, the use of the IDE, how to use, modify or create Components, and hints on how to perform certain tasks. This part of the Documentation section (the thing you are currently reading) represents the beginning of the process. '''We need contributions from anyone who feels able to provide them: the WiKi is very easy to edit.'''<br />
<br />
=== The Button bar ===<br />
A small toolbar area on the left of the main editor window, just below the Main Menu and to the left of the Component Palette, contains a set of buttons which replicate frequently-used Main Menu selections:<br />
: '''New unit''', '''Open''' (with a down-arrow to display a drop-down list of recently used files), '''Save''', '''Save all''', '''New Form''', '''Toggle Form/Unit''' (ie show either form or source code of Unit), '''View Units''', '''View Forms''', '''Run''' (ie compile and Run), '''Pause''', '''Step Into''', '''Step over''' (the last two are Debugger functions).<br />
<br />
== The Component Palette ==<br />
A Tabbed toolbar which displays a large number of icons representing commonly used components for building Forms.<br />
<br />
Each tab causes the display of a different set of icons, representing a functional group of components. The left-most icon in each tabbed group is an obliquely leftward-facing arrow, called the Selection Tool.<br />
<br />
If you allow the mouse cursor to hover over any of the icons on the Component Palette, without clicking on the icon, the title of that component will pop-up. Note that each title begins with a 'T' - this signifies 'Type' or more accurately 'Class' of the component. When you select a component for inclusion in a form, the [[Class]] is added to the '''[[Type|type]]''' section of the '''[[Interface|interface]]''' part of the [[Unit]] (usually as part of the overall TForm1), and an '''instance''' of that class is added to the '''[[Var|var]]''' section (usually as the variable Form1). Any '''Methods''' that you design to be used by the Form or its Components (ie [[Procedure]]s or [[Function]]s) will be placed in the '''[[Implementation|implementation]]''' part of the Unit<br />
<br />
In the following list of the Components, you will find links to files that contain descriptions of the Units in which they are found. If you want to find out about the properties of a particular component, it is often worth looking at the Inheritance of that component and then inspecting the properties of the base type from which it is derived. For example, to understand TMaskEdit it is also useful to examine TCustomMaskEdit.<br />
<br />
'''TABS''' (the names are largely self-explanatory):<br />
* '''[http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/index-4.html Standard]''' (See [[Standard tab]] for components description)<br />
<center>[[Image:Component_Palette_Standart.png]]</center><br />
:''Frequently used components:'' [http://lazarus-ccr.sourceforge.net/docs/lcl/menus/tmainmenu.html TMainMenu], [http://lazarus-ccr.sourceforge.net/docs/lcl/menus/tpopupmenu.html TPopupMenu], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tbutton.html TButton], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tlabel.html TLabel], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tedit.html TEdit], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tmemo.html TMemo], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/ttogglebox.html TToggleBox], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tcheckbox.html TCheckBox], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tradiobutton.html TRadioButton], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tlistbox.html TListBox], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tcombobox.html TComboBox], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tscrollbar.html TScrollBar], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tgroupbox.html TGroupBox], [http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tstatictext.html TStaticText], [http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tradiogroup.html TRadioGroup], [http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tcheckgroup.html TCheckGroup], [http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tpanel.html TPanel], [http://lazarus-ccr.sourceforge.net/docs/lcl/actnlist/tactionlist.html TActionList]<br />
* '''[http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/index-4.html Additional]''' (See [[Additional tab]] for components description)<br />
<center>[[Image:Component_Palette_Additional.png]]</center><br />
:''More, often-used components:'' [http://lazarus-ccr.sourceforge.net/docs/lcl/buttons/tbitbtn.html TBitBtn], [http://lazarus-ccr.sourceforge.net/docs/lcl/buttons/tspeedbutton.html TSpeedButton], [http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/timage.html TImage], [http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tshape.html TShape], [http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tbevel.html TBevel], [http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tpaintbox.html TPaintBox], [http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tnotebook.html TNotebook], [http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tlabelededit.html TLabeledEdit], [http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tsplitter.html TSplitter], [http://lazarus-ccr.sourceforge.net/docs/lcl/maskedit/tmaskedit.html TMaskEdit], [http://lazarus-ccr.sourceforge.net/docs/lcl/checklst/tchecklistbox.html TCheckListBox], [http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tscrollbox.html TScrollBox], [http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tapplicationproperties.html TApplicationProperties], [http://lazarus-ccr.sourceforge.net/docs/lcl/grids/tstringgrid.html TStringGrid], [http://lazarus-ccr.sourceforge.net/docs/lcl/grids/tdrawgrid.html TDrawGrid], [http://lazarus-ccr.sourceforge.net/docs/lcl/pairsplitter/tpairsplitter.html TPairSplitter]<br />
* '''[http://lazarus-ccr.sourceforge.net/docs/lcl/comctrls/index-4.html Common Controls]''' (See [[Common Controls tab]] for components description)<br />
<center>[[Image:Component_Palette_Common_Controls.png]]</center><br />
: TTrackBar, TProgressBar, TTreeView, TListView, TStatusBar, TToolBar, TUpDown, TPageControl, TImageList<br />
* '''[http://lazarus-ccr.sourceforge.net/docs/lcl/dialogs Dialogs]''' (See [[Dialogs tab]] for components description)<br />
<center>[[Image:Component_Palette_Dialogs.png]]</center><br />
: TOpenDialog, TSaveDialog, TSelectDirectoryDialog, TColorDialog, TFontDialog, TOpenPictureDialog, TSavePictureDialog, TCalendarDialog, TCalculatorDialog<br />
<br />
Several useful '''[http://lazarus-ccr.sourceforge.net/index.php?wiki=DialogExamples Dialog]''' procedures or functions don't appear on the Palette, but are easily used as direct calls from your source program.<br />
<br />
For several good examples of the use of Components see the $LazarusPath/lazarus/examples subdirectory of your source installation. Many of the programs show how to use dialogs and other components directly without using the IDE and component palette or having a separate form definition file: all the components are fully and explicitly defined in the main Pascal program. Other example programs make full use of the IDE.<br />
<br />
Some examples don't work straight away: you may need to play about with paths and permissions of files or directories. If you want to compile any of the examples, make sure that you have read/write/execute permissions for the files and directories, or copy the files to a directory where you do have the appropriate permissions.<br />
<br />
Try running the 'testall' program to see a menu of the available components together with small example test forms for most of them; then inspect the code to find out how they work!<br />
* '''Misc'''<br />
<center>[[Image:Component_Palette_Misc.png]]</center><br />
: [http://lazarus-ccr.sourceforge.net/index.php?wiki=DialogsTxt TColorButton], TSpinEdit, TArrow, TCalendar, TEditButton, TFileNameEdit, TDirectoryEdit, TDateEdit, TCalcEdit, TFileListBox <br />
* '''Data Controls'''<br />
<center>[[Image:Component_Palette_DataControls.png]]</center><br />
: ''Data-aware components, which largely replicate the Standard and Additional groups but are applicable to Databases:'' TDBNavigation, TDBText, TDBEdit, TDBMemo, TDBImage, TDBListBox,TDBComboBox, TDBCheckBox, TDBRadioGroup, TDBCalendar, TDBGroupBox, TdbGrid<br />
* '''Data Access'''<br />
<center>[[Image:Component_Palette_DataAccess.png]]</center><br />
: TDatasource<br />
* '''[[System]]'''<br />
<center>[[Image:Component_Palette_System.png]]</center><br />
: [http://lazarus-ccr.sourceforge.net/index.php?wiki=ExtCtrls#TTimer TTimer], TIdleTimer, [[doc:fcl/process/tprocess.html|TProcess]]<br />
* '''SynEdit'''<br />
<center>[[Image:Component_Palette_SynEdit.png]]</center><br />
: ''A group of components to help interfacing with other languages and software tools. SynEdit is an advanced multi-line edit control, for Borland Delphi, Kylix and C++Builder. It supports Syntax Highlighting and code completion, and includes exporters for html, tex and rtf. It is a full-VCL/CLX control, meaning it is not a wrapper for Microsoft Windows controls, and no run-time library is required; this make SynEdit a crossplatform component. Compatibility with FreePascal is also planned, and SynEdit is the edit component in Lazarus IDE.'' see [http://synedit.sourceforge.net synedit at sourceforge]. TSynEdit, TSynAutoComplete, TSynExporterHTML, TSynMacroRecorder, TSynMemo, TSynPasSyn, TSynCppSyn, TSynJavaSyn, TSynPerlSyn, TSynHTMLSyn, TSynXMLSyn, TSynLFMSyn, TSynUNIXShellScriptSyn, TSynCssSyn, TSynPHPSyn, TSynTeXSyn, TSynSQLSyn, TSynMultiSyn<br />
<br />
=== How To Use the Palette ===<br />
<br />
To use the Palette, there must be an open form on view in the editor (if there isn't one, select File -> New Form). Click on the icon in the appropriate tab of the Palette for the component you want to use, then click on the Form, near where you want the component to appear. When the desired component appears, you can select it by clicking with the mouse, then move it to the exact place on the Form where you want it and adjust its size. Adjustments can be made to the appearance either by altering the picture itself on the Form using the mouse, or by changing the relevant Property in the Object Editor for that component.<br />
<br />
If you install additional components, either those you have written yourself, or some coming as a package from some other source, then extra tabs with the relevant icons will appear in your Component Palette. These new components can be selected and used on your forms in the same way as those supplied by default.<br />
<br />
== How to use Standard Controls, Common Controls and Extended Controls ==<br />
<p>The Units <i>StdCtrls</i>, <i>ComCtrls</i> and <i>ExtCtrls</i> contain definitions and descriptions of many of the most commonly used controls for constructing Forms and other Objects in Lazarus Applications.</p><br />
<p>Many of the final target controls that the application developer wants to use, such as <i>TButton</i>, <i>TMemo</i>, <i>TScrollBar</i> etc, have a corresponding ancestor class such as <i>TCustomButton</i>, <i>TCustomMemo</i> or <i>TCustomScrollBar</i>. Several of the properties and methods relevant to the final target control are defined (and explained) more fully in the <i>TCustomXXX</i> class, and are <b>inherited</b> by the final target control.</p><br />
<p>If you drop a component on the form editor you don't need to add code explicitly to create it. The component is automatically created by the IDE together with the form, and destroyed when the form is destroyed.</p><br />
<p>However, if you create the component yourself by code don't forget to free it when it is no longer needed.</p><br />
<p>If you place a component on the Form Designer and look at the Object Inspector, you can observe the properties change as you move the component around.</p><br />
<p>For example, if you place a button (TButton) on the form, click on it to select it, then move it around the form with the mouse, you can watch the values of Top and Left change in the Object Inspector to reflect the new position. If you use the object's re-sizing bars to adjust its size, you can watch the Height and Width properties change as well.</p><br />
<p>On the other hand, by using the Object Inspector, you can select the value associated with a property such as height, and type in a new value; you can watch the size of the object on the form change to reflect the new value.</p><br />
<p>You can also explicitly change the properties of the object in code by typing (in the appropriate Implementation section of the Source editor), for example</p><br />
<code>Form1.Button1.Height := 48;</code><br />
<p>If you type this new value into the Source Editor and then look back at the Form Designer, you will see that the button on the Form has taken the new size. The new value will also be shown in the Object Inspector.</p><br />
<p>In summary, there are usually about three different ways to determine each property of an object:</p><br />
<ul><br />
<li>by using the mouse,</li><br />
<li>by setting the values in the Object Inspector,</li><br />
<li>or explicitly by writing code.</li><br />
</ul><br />
<p>The components defined in these Units have several properties that are common to most of them, and other properties that are specific to the individual components. We shall describe the most common ones here. Unusual or control-specific properties will be described for the individual controls. </p><br />
<p>Additional Help can always be obtained by selecting a property or keyword, in either the Object Inspector or the Source Editor, and pressing <b>F1</b>. You will be taken by your Help browser to the appropriate page in the documentation. </p><br />
<p>If the description of a property on that page is insufficient, you can navigate to the corresponding description in the ancestor classes, by selecting the links in the Inheritance listing or by selecting the ancestor Type in the declaration of the object.</p><br />
<p><br />
<i>Constructors</i><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
such as <i>Create</i> allocate memory and system resources needed by the object. They also call the constructor of any sub-objects present in the class.</p><br />
<p><br />
<i>Destructors:</i><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
remove the object and de-allocate memory and other resources. If you call <i>Destroy</i> for an object which hasn't being initialized yet it will generate an error. Always use the <i>Free</i> method to deallocate objects, because it checks whether an object's value is <b>nil</b> before invoking <i>Destroy</i>.</p><br />
<p>Take the following precautions when creating your own <i>Destroy</i> method:</p><br />
<ul><br />
<li>Declare <i>Destroy</i> with the <b>override</b> directive, because it is a <b>virtual</b> method.</li><br />
<li>Always call '<i>inherited Destroy;</i>' as the last thing on the destructor code.</li><br />
<li>Be aware that an <i>exception</i> may be raised on the <i>constructor</i> in case there is not enought memory to create an object, or something else goes wrong. If the <i>exception</i> is not handled inside the constructor, the object will be only partially built. In this case <i>Destroy</i> will be called when you weren't expecting it, so your destructor must check if the resources were really allocated before disposing of them.</li><br />
<li>Remember to call <i>Free</i> for all objects created on the constructor.</li><br />
</ul><br />
<br/><br />
<table><br />
<caption><b>Some commonly listed properties</b></caption><br />
<tr><td><b>Property</b></td><td><b>Meaning</b></td></tr><br />
<tr><br />
<td>Action</td><br />
<td>The main action or event associated with the object. For example selecting an 'Exit' Button might cause the 'Close' action</td><br />
</tr><br />
<tr><br />
<td>Align</td><br />
<td>Defines the way in which an object is to be lined up with the parent object. Possible values are alTop (placed at the top and using the full available width), alBottom, alLeft (placed at the left and using the full available height), alRight. alNone (place anywhere on parent control) or alClient (takes all available space next to controls aligned to top, bottom, left or right)</td><br />
</tr><br />
<tr><br />
<td>Anchor</td><br />
<td>Used to keep a control a certain distance from the defined edges of a parent control, when the parent is resized. For example <b>[akBottom, akRight]</b> will keep the control a fixed distance from the bottom right corner.</td><br />
</tr><br />
<tr><br />
<td>AutoSelect</td><br />
<td>When True, an editing control will select all its text when it receives focus or when the Enter key is pressed.</td><br />
</tr><br />
<tr><br />
<td>AutoSelected</td><br />
<td>True indicate that the edit or combobox control has just performed an AutoSelect operation so that subsequent mouse-clicks and keystrokes proceed normally without selecting the text.</td><br />
</tr><br />
<tr><br />
<td>BorderSpacing</td><br />
<td>The space around the edge between an <i>Anchored</i> control and its parent.</td><br />
</tr><br />
<tr><br />
<td>Caption</td><br />
<td>The text that is displayed on or near the control; it should preferably give some clue as to the function of the control, or an instruction such as 'Close' or 'Execute'. By default Caption is set to be the same as the 'Name' property, and the application programmer should substitute meaningful text instead of the default values.</td><br />
</tr><br />
<tr><br />
<td>CharCase</td><br />
<td>Indicates how text is displayed in a text editing control: Normal (retaining the case of the letters typed by the user), converted to uppercase, or converted to lowercase</td><br />
</tr><br />
<tr><br />
<td>Constraints</td><br />
<td>Sets the minimum and maximum sizes for a control. If a control is resized the new dimensions are always within the ranges given here. You should take care when setting these options that they do not conflict with the Anchors and Align settings.</td><br />
</tr><br />
<tr><br />
<td>Color</td><br />
<td>The Colour to be used to draw the control or to write the text it contains.</td><br />
</tr><br />
<tr><br />
<td>Enabled</td><br />
<td>A Boolean property to determine whether or not a control is capable of being selected and performing an action. If it is not <i>Enabled</i>, it is often <b>Grayed</b> out on the Form.</td><br />
</tr><br />
<tr><br />
<td>Font</td><br />
<td>The Font to be used for writing the text associated with the control - either the caption or label, or the text-strings contained within the control. The entry on the Object Inspector usually has a (+) box on the left, and selecting this box reveals further options such as character set, colour and size.</td><br />
</tr><br />
<tr><br />
<td>Hint</td><br />
<td>A short piece of informative pop-up text that appears if the mouse-cursor hovers over the control.</td><br />
</tr><br />
<tr><br />
<td>Items</td><br />
<td>The list of 'Things' that the object contains, such as a group of images, a series of lines of text, a number of actions in an actionlist, etc</td><br />
</tr><br />
<tr><br />
<td>Lines</td><br />
<td>An array of strings, containing the textual data in controls with more than a single line of data, such as an Edit-Box or a Combo-Box. The array is zero-indexed, ie the lines are numbered [0..numLines-1]</td><br />
</tr><br />
<tr><br />
<td>Name</td><br />
<td>The identifier by which the control is known in the program. The IDE gives it a default name based on the underlying type, for example successive instances of TBitButton would be named Form1.BitBitton1 and Form1.BitButton2; it is up to the application programmer to give them more meaningful names such as ExitButton or OKButton. By default the Name of the control is applied to the Caption for the control, but the text of the Caption may be changed separately.</td><br />
</tr><br />
<tr><br />
<td>PopUpMenu</td><br />
<td>A window containing context-sensitive menu information that pops up when the right mouse button is clicked on the object.</td><br />
</tr><br />
<tr><br />
<td>Position (or Top, Left)</td><br />
<td>Determines where the control is located on the parent form or window</td><br />
</tr><br />
<tr><br />
<td>ReadOnly</td><br />
<td>Boolean property which, if True, signifies that the contents of the control can be read by the user or the calling routine, but cannot be written or changed.</td><br />
</tr><br />
<tr><br />
<td>ShowHint</td><br />
<td>Allows a small window containing a context-sensitive Help or other description to be displayed when the mouse cursor 'hovers' over the control.</td><br />
</tr><br />
<tr><br />
<td>Size (or Height and Width)</td><br />
<td>The dimensions of the control</td><br />
</tr><br />
<tr><br />
<td>Style</td><br />
<td>The options available for Style depend upon the sort of Control being considered: for instance the Style may be defined by TFormStyle, TBorderStyle, TButtonStyle etc.</td><br />
</tr><br />
<tr><br />
<td>TabOrder</td><br />
<td>Integer defining where in the sequence of tabs on the Form this control is to lie</td><br />
</tr><br />
<tr><br />
<td>TabStop</td><br />
<td>Boolean property which if True places this control in the sequence of objects that the user can reach by successively pressing the Tab key</td><br />
</tr><br />
<tr><br />
<td>Text</td><br />
<td>The String of Text that represents the actual data that this control contains. Applies particularly to Text, Memo and StringList types of object. Most of the editing operations (such as <i>Select</i>, <i>Clear</i>, <i>Cut</i>, <i>Copy</i>) are performed in this part of the object, which holds the actual string being edited. If the control contains more than a single line of text, for example <i>TMemo</i> or <i>TComboBox</i>, then the textual elements are arranged as an array of strings (zero-indexed, ie numbered from [0..numLines-1]) in <i>Lines</i>.</td><br />
</tr><br />
<tr><br />
<td>Visible</td><br />
<td>If true, the object can be seen on the Form; if False, object is hidden</td><br />
</tr><br />
<tr><br />
<td>WordWrap</td><br />
<td>Logical flag to show whether or not word-wrap is enabled, ie if a word comes close to the end of a line and is going to be too long for the line, it is wrapped down to the next line.</td><br />
</tr><br />
</table><br />
<p>Many actions are commonly listed in the 'Events' tab of the Object Inspector. If you select an entry in the list, a ComboBox appears with a DropDown list showing any actions that have aleady been defined, and allowing you to choose one to be associated with this event. Alternatively you can select the ellipsis (three dots ...) and you will be taken to an area of the Source Editor where you can begin typing your own action instructions for the selected event.</p><br />
<p>While a large number of events is available for any given control, in practice it is only necessary to populate a few of them. For most controls, it is sufficient to provide coding for 'OnClick'; for more complex controls it may be necessary also to provide for 'OnEntry' (when the mouse cursor enters the Control and gives it focus) and 'OnExit' (when the mouse cursor leaves the Control; or you may need to write an event handler for 'OnChange' or 'OnScroll', depending on the nature of the particular control with which you are dealing.</p><br />
<p>The pop-up menu that appears when you right-click an object in the Form Designer has, as its first item: 'Create default event' and selecting this option will have the same effect as selecting the ellipsis in the Object Inspector for the default event, usually OnClick: you are taken to the Implementation area of the Source Editor where you can type the code for the event handler.</p><br />
<p>A common strategy in Object-Oriented programming is to provide an <i>ActionList</i> with the facility for entering, removing or editing a number of pre-defined actions from which the most appropriate can be selected to use in any particular instance.</p><br />
<br/><br />
<table><br />
<caption><b>Some commonly listed Actions</b></caption><br />
<tr><br />
<td><b>Action</b></td><br />
<td><b>Meaning</b></td><br />
<tr><br />
<td>OnChange</td><br />
<td>Action to be taken if any change is detected (eg mouse move, mouse click, key press, edit text, alter picture, etc)</td><br />
</tr><br />
<tr><br />
<td>OnClick</td><br />
<td>Action to be taken when the (left) mouse button is clicked. This is usually the main or default action of the control; for example clicking on a button or checkbox initiates the action associated with the checkbox. It may alternatively initate a process of selection, for instance in a TextBox or Memo, or signal the beginning of painting with a Pen or Brush.</td><br />
</tr><br />
<tr><br />
<td>Click</td><br />
<td>A method to emulate in code the effect of clicking on a control. This method is most often found in Button-type controls (TButton, TBitBtn, TSpeedButton etc). A procedure can be written that calls the same code as the OnClick action. This facility can be particularly useful if the activation of one control by clicking causes a cascade of other controls to be activated, and the Click method can be used to initiate the action rather than having the user explicitly click on a lot of controls.</td><br />
</tr><br />
<tr><br />
<td>OnDragDrop</td><br />
<td>Action to be taken during Drag-Drop manoeuvres, ie when the mouse is used to 'capture' an item or some text etc and move it around the screen to a new location.</td><br />
</tr><br />
<tr><br />
<td>OnEntry</td><br />
<td>Action to be taken when the mouse cursor enters the area occupied by the object, usually transfering focus to that object. This might include changes in the appearance of the object such as highlighting or raising the border.</td><br />
</tr><br />
<tr><br />
<td>OnExit</td><br />
<td>Action to be taken when the mouse moves out of the area of the object, usually transferring focus out of the object.</td><br />
</tr><br />
<tr><br />
<td>OnKeyPress</td><br />
<td>Action to be taken for any key-press. Subtly different from OnKeyDown, which simply responds to a key being down, whether or not it was already down when focus was given to this control. OnKeyPress requires that a key becomes pressed while focus is in this control.</td><br />
</tr><br />
<tr><br />
<td>OnKeyDown</td><br />
<td>Action to be taken if a key is down while focus is in this control. Subtly different from OnKeyPress - for example the key might already have been down when focus entered this control, whereas OnKeyPress requires the key to become pressed while focus is in the control.</td><br />
</tr><br />
<tr><br />
<td>On Key Up</td><br />
<td>Action to be taken if a key is up (ie not pressed) while focus is in this control.</td><br />
</tr><br />
<tr><br />
<td>OnMouseMove</td><br />
<td>On Mouse Down - Action to be taken if the mouse cursor moves while focus is in this control.</td><br />
</tr><br />
<tr><br />
<td>OnMouseDown</td><br />
<td>Action to be taken if the mouse button is down while focus is in this control.</td><br />
</tr><br />
<tr><br />
<td>OnMouseUp</td><br />
<td>Action to be taken if the mouse button is up while the cursor is over this control. Implies that the mouse button was previously down and has been released. The case where the cursor enters the control but the mouse button has not yet been pressed is covered by OnEntry or OnMouseEnter.</td><br />
</tr><br />
<tr><br />
<td>OnResize</td><br />
<td>Action to be taken when the control is resized. Might include re-alignment of text or selection of a different font size etc.</td><br />
</tr><br />
</table><br />
<br />
== How to use Menus ==<br />
Hints for creating Menus for your Forms<br />
<br />
''TMainMenu'' is the Main Menu that appears at the top of most forms; form designers can customise by choosing various menu items. ''TPopupMenu'' is a menu window that pops up with pertinent, usually context-sensitive, details and choices when the right mouse button is clicked near a control<br />
<br />
Main Menu is a non-visible component : that is, if the icon is selected from the Component Palette and placed on the Form, it will not appear at Run-time. Instead, a Menu bar with a structure defined by the Menu Editor will appear. Popup menus, placed on the form by selecting the icon from the Component Palette, do not appear at all unless the right mouse button is clicked on a control that owns such a menu.<br />
<br />
To see the Menu Editor, right-click on the Main Menu or Popup Menu icon on your Form. A pop-up box appears, that invites you to enter items into the Menu bar.<br />
<br />
An Edit box is displayed, containing a Button labelled New Item1. If you right-click on that box, a pop-up menu is displayed that allows you to add a new item before or after (along the same level) or create a sub-menu with the opportunity to add further items below (or above) the new item in a downward column.<br />
<br />
Any or all of the ''MenuItems'' that you add can be configured using the Object Inspector.<br />
<br />
At the least you should give each item a ''Caption'' which will appear on the Menu Bar (you may also wish to give it a more meaningful ''Name''). The caption should indicate the activity to be selected, such as "File Open" or "Close", "Run" or "Quit"<br />
<br />
If you want a particular letter in the Caption to be associated with a shortcut key, that letter should be preceded by an ampersand. The Menu item at run-time will appear with the shortcut letter underlined, and hitting that letter key will have the same effect as selecting the menu item. Alternatively you can choose a shortcut key sequence (such as Ctrl-C for Copy or Ctrl-V for Paste - the standard Keyboard shortcuts) with the ''ShortCut'' property of the MenuItem.<br />
<br />
It is often helpful to use the Menu controls in conjuction with an ''ActionList'' which contains a series of standard or customised ''Actions''. Menu Items can be linked in the Object Inspector to Actions on the list, and the same actions can be linked to ''Buttons'', ''ToolBar Buttons'', ''SpeedButtons'' etc. It is obviously economic of effort to re-use the same code to respond to the various events, rather than writing separate ''OnClick'' event handlers for each individual control.<br />
<br />
By default a number of standard actions is pre-loaded from ''StdActns'' or, if DataAware controls are being used, from ''DBActns'', and these can be chosen using the ActionList editor which appears when you right-click on the ActionList icon on the Form Designer.<br />
<br />
== The Debugger ==<br />
: ''Still to be written''.<br />
<br />
see also [[:category: IDE Window - Debug]]<br />
<br />
== The Lazarus files ==<br />
(Thanks to Kevin Whitefoot.)<br />
(Additions by Giuseppe Ridinò, [[User:Kirkpatc]] and Tom Lisjac)<br />
When you save you will actually be saving two files: <br />
<br />
xxx.pas and yyy.lpr <br />
(You save more than that but those are the ones you get to name). The project file (lpr) and the unit file (pas) must not have the same name because Lazarus will helpfully rename the unit (inside the source code) to the same as the unit file name and the program to the name of the project file (it needs to do this or the compiler will probably not be able to find the unit later when referred to in the project file). Of course to be consistent it changes all the occurrences of unit1 to xxx.<br />
<br />
So if you are saving a project called '''again''', trying to save again.pas and again.lpr fails because unit names and program names are in the same name space resulting in a duplicate name error.<br />
<br />
So here is what I ended up with:<br />
<br />
e:/lazarus/kj/lazhello:<br />
total 4740 free 76500<br />
-rwxrwxrwx 1 kjwh root 4618697 Mar 24 11:19 again.exe<br />
-rw-rw-rw- 1 kjwh root 3002 Mar 24 11:21 again.lpi<br />
-rw-rw-rw- 1 kjwh root 190 Mar 24 11:18 again.lpr<br />
-rw-rw-rw- 1 kjwh root 506 Mar 24 11:08 againu.lfm<br />
-rw-rw-rw- 1 kjwh root 679 Mar 24 11:08 againu.lrs<br />
-rw-rw-rw- 1 kjwh root 677 Mar 24 11:08 againu.pas<br />
-rw-rw-rw- 1 kjwh root 2124 Mar 24 11:08 againu.ppu<br />
-rwxrwxrwx 1 kjwh root 335 Mar 24 11:07 ppas.bat<br />
<br />
Note that there are many more files than the two that I thought I was saving.<br />
<br />
Here is a brief note about each file:<br />
<br />
'''again.exe:'''<br />
The main program binary executable. Win32 adds an "exe" extension. Linux has none (just the name of the program). This file will be huge in Linux due to the inclusion of debugging symbols. Run the "strip" utility to remove them and substantially shrink the executable size.<br />
<br />
'''again.lpi:'''<br />
(Lazarus Project Information). This is the main information file of a Lazarus project; the equivalent Delphi main file of an application will be the .dpr file. It is stored in an XML format and contains instructions about all the libraries and units required to build the executable file.<br />
<br />
'''again.lpr:'''<br />
The main program source file or master file. Despite its lazarus specific extension it is in fact a perfectly normal Pascal source file. It has a uses clause that lets the compiler find all the units it needs. Note that the program statement does not have to name the program the same as the file name. This file is usually fairly small, with just a few statements to initialise, build the forms, run and close the application. Most of the work is done in the unit source files, with suffix '.pas'<br />
<br />
'''againu.lfm:'''<br />
This is where Lazarus stores the layout of the form unit, in human readable form. It reflects the properties of the various components, as set in the Object Inspector. Each object description starts with a line: <br />
object xxxx <br />
then there follows a list of properties <br />
(including embedded or nested objects) then an <br />
end <br />
line. Lazarus uses this file to generate a resource file (.lrs) that is included in the initialisation section of the againu.pas unit. Delphi dfm files can be converted to lfm format in the Lazarus IDE using the Tools->Convert DFM file to LFM utility.<br />
<br />
'''againu.lrs:'''<br />
This is the generated resource file which contains the instructions to the program for building the form (if you look in the main Unit file, you will see in the initialization section the line <br />
{$i againu.lrs} <br />
which instructs the program to load the resource file). Note that it is not a Windows resource file.<br />
<br />
'''againu.pas:'''<br />
The unit that contains the code for the form; this is usually the only file that the application programmer needs to edit or inspect, and contains any code specifically supplied by the programmer (especially event handlers).<br />
<br />
'''againu.ppu:'''<br />
This is the compiled unit which gets linked into the executable file together with any other units named in the Uses section.<br />
<br />
'''ppas.bat:'''<br />
This is a simple script that links the program to produce the executable. If compilation is successfull, it is deleted by the compiler.<br />
<br />
== Original contributors and changes ==<br />
This page has been imported from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusTutorial version].<br />
* Created initial page and template. T. Lisjac - 11/04/2003 [[User:Tom | VlxAdmin]]<br />
* Inserted a note containing instructions for writing your first Lazarus Program. Suggest an administrator places it in the appropriate place on the Tutorial menu. 3/09/2004 [[User:Kirkpatc]]<br />
* Per above, moved Chris's writeup to the main body of the tutorial [[User:Tom | VlxAdmin]]<br />
* Began to insert text describing the Lazarus Editor - more to follow! 24 Mar 2004 [[User:Kirkpatc]]<br />
* Added some more to Lazarus Editor section of Tutorial. 25 Mar 2004 [[User:Kirkpatc]]<br />
* Added screenshots and revised some of the page formatting [[User:Tom | VlxAdmin]] 3/25/2004<br />
* Moved some of kwhitefoot's comments into Tutorial section. Formatting not quite right, but have to go to bed now! 26 Mar 2004 [[User:Kirkpatc]]<br />
* Formatted, added credits and comments. Removed original notes. [[User:Tom | VlxAdmin]] 3/26/2004<br />
* More material added to Editor section of tutorial. 26 Mar 2004 [[User:Kirkpatc]]<br />
* More material added describing the Main Menu. Renamed 'Hello World' to 'Getting Started' and moved it to nearer the top. 31 March 2004 [[User:Kirkpatc]]<br />
* Inserted section on Run sub-menu. Some general editing (eg ended each entry with a period to ensure consistency). 9 Apr 2004 [[User:Kirkpatc]]<br />
* Inserted a new section on How to get started with MySQL in FPC/Lazarus. 13 Apr 2004 [[User:Kirkpatc]]<br />
* Deleted the section on MySQL from here: it has been copied to Lazarus Database section of tutorial. 14 Apr 2004 [[User:Kirkpatc]]<br />
* Added some more to the description of the Editor Main Menu. 18 Apr 2004 [[User:Kirkpatc]]<br />
* Added section on Environment sub-menu. 19 Apr 2004 [[User:Kirkpatc]]<br />
* Added section on Components sub-menu. 4 May 2004 [[User:Kirkpatc]]<br />
* Adding Tools sub-menu description (incomplete). 7 May 2004 [[User:Kirkpatc]]<br />
* Added some screenshots to Menu descriptions. 9 May 2004 [[User:Kirkpatc]]<br />
* Fixed a bit in Environment Options - thanks VincentSnijders. 14 May 2004 [[User:Kirkpatc]]<br />
* More additions to Tools sub-menu. 19 May 2004 [[User:Kirkpatc]]<br />
* Added a section on the Button Bar and started work on The Component Palette. 20 May 2004 [[User:Kirkpatc]]<br />
* Posted a description file for the StdCtrls unit of the LCL, in the hope that people will add comments. 26 May 2004 [[User:Kirkpatc]]<br />
* Edited the StdCtrls file, removing a lot of repetitive material and doing some formatting. It is still far too long. 28 May 2004 [[User:Kirkpatc]]<br />
* Expanding on the Components Palette. 5 June 2004 [[User:Kirkpatc]]<br />
* Added a lot to the DialogExamples page. 10 June 2004 [[User:Kirkpatc]]<br />
* Considerable revision of the StdCtrls page, hopefully making it clearer and encouraging people to contribute - particularly in the 'Description' sections. 14 June 2004 [[User:Kirkpatc]]<br />
* Added pages for Menus and Dialogs units (linked to Component Palette description) - please feel free to add to these pages. 14 June 2004 [[User:Kirkpatc]]<br />
* Added page for Common Controls (linked to Component Palette). 16 June 2004 [[User:Kirkpatc]]<br />
* Added MaskEdit page (linked to Component Palette). 17 June 2004 [[User:Kirkpatc]]<br />
* Added Buttons, ExtCtrls pages (linked to Component Palette). 17 June 2004 [[User:Kirkpatc]]<br />
* Edited MainMenu component description page. 23 June 2004 [[User:Kirkpatc]]<br />
* Some additions to Common Controls. 28 June 2004 [[User:Kirkpatc]]<br />
* A new tutorial on Text-mode Pascal programming has been added. 5 July 2004 [[User:Kirkpatc]]<br />
* Minor changes to ComCtrls, ExtCtrls, Environment Menu. 10 July [[User:Kirkpatc]]<br />
* Added FormsTxt, component description page for Component Palette. 20 July 2004 [[User:Kirkpatc]]<br />
* Some corrections to ConsoleModePascal. 21 July 2004 [[User:Kirkpatc]]<br />
* Some small changes to ComponentPalette. 22 July 2004 [[User:Kirkpatc]]<br />
* Returned after a long absence! Changed link for component descriptions in StdCntls group of ComponentPalette to point directly at the Lazarus on-line help html pages. 25 Sept 2007 [[User: Kirkpatc]]<br />
* Uploaded some more up-to-date screenshots and fixed links in descriptions of the Menus. 2 October 2007 [[User: Kirkpatc]]<br />
* Fixed links for component descriptions in Extra Controls section of Component Palette. 2 October 2007 [[User: Kirkpatc]]<br />
* Added sections on How to use Standard Controls etc and How to use Menus (based on topics in the LCL Documentation). Fixed some links in Component Palette. 4th June 2008 [[User: Kirkpatc]]<br />
* Some edits and additions to the Lazarus Files section. 12th July 2008 [[User: Kirkpatc]]<br />
<br />
----<br />
[[Lazarus IDE Tools]]</div>Orankehttps://wiki.freepascal.org/index.php?title=User_talk:Oranke&diff=32303User talk:Oranke2008-11-26T16:08:24Z<p>Oranke: /* 번역완료... */</p>
<hr />
<div>라자루스 위키 번역작업중.<br />
<br />
=== 번역중... ===<br />
<br />
* [[Lazarus_Documentation/ko]]<br />
* [[Nomenclature/ko]]<br />
* [[DesignGuidelines/ko]]<br />
* [[Overview_of_Free_Pascal_and_Lazarus/ko]]<br />
<br />
=== 번역완료... ===<br />
<br />
* [[Main_Page/ko]] - Arilang님, Azrael님 고생하셨습니다.</div>Orankehttps://wiki.freepascal.org/index.php?title=Overview_of_Free_Pascal_and_Lazarus/ko&diff=32302Overview of Free Pascal and Lazarus/ko2008-11-26T16:07:11Z<p>Oranke: /* 동적 링크 라이브러리 */</p>
<hr />
<div>{{Overview of Free Pascal and Lazarus}}<br />
<br />
프리 파스칼(FPC)은 두 개의 큰 특징을 가진 오픈 소스 파스칼 컴파일러 입니다. 첫번째는 [[Delphi|델파이]]와의 호환성입니다. 또 하나는 다중 플랫폼에 대한 지원으로서 현재 윈도우즈, 맥 OS X, 리눅스에서 사용할 수 있습니다. 프리 파스칼은 델파이에서 확장된 오브젝트 파스칼 프로그래밍 언어를 지원하는 것 뿐만 아니라, 델파이에서 사용되는 강력한 기능의 라이브러리나 클래스들도 함께 이용할 수 있습니다. 델파이 사용자에게 잘 알려져 있는 System, SysUtils, StrUtils, DateUtils, Classes, Variants, Math, IniFiles 그리고 Registry 등의 유니트들도 있으며, 이것들은 프리 파스칼이 동작하는 모든 플랫폼 상에서 동작 합니다. 그 외에도 프리 파스칼에는 Windows, ShellAPI, BaseUnix, Unix, 그리고 DynLibs 처럼 특정 운영체제를 위한 유니트들도 준비되어 있습니다. '''프리 파스칼 런타임 라이브러리'''(RTL)는 이 유니트들을 모아놓은 커다란 라이브러리 입니다. <br />
<br />
라자루스는 프리 파스칼용 통합 개발 환경(IDE)을 제공하는 오픈 소스 프로젝트 입니다. 프리 파스칼로 개발 되었으며, 문법 강조가 가능한 코드 에디터와 직관적인 폼 디자이너를 가지고 있습니다. 라자루스가 사용하는 '''라자루스 컴포넌트 라이브러리'''(LCL) 은 델파이의 '''비주얼 컴포넌트 라이브러리'''(VLC) 과 높은 호환성을 가지고 있으며 VCL 컨트롤과 마찬가지로 폼이나 버튼, 텍스트박스 등을 제공 합니다. 이 컨트롤들을 적절하게 배치하여 '''그래픽 사용자 인터페이스'''(GUI)를 가지는 어플리케이션을 작성할 수 있습니다.<br />
<br />
프리 파스칼과 라자루스는 파스칼 코드로 작성 되어 있습니다. 프리 파스칼 컴파일러와 라자루스 뿐 아니라 RTL 이나 LCL의 모든 유니트들의 소스 코드는 완전히 공개되어 있습니다. <br />
<br />
프리 파스칼과 라자루스는 델파이와 마찬가지로 일반적인 프로그래밍 툴 입니다. 이 의미는 다음과 같은 폭 넓고 다양한 프로그램을 개발하는 데 사용할 수 있다는 의미 입니다. <br />
<br />
<br />
=== 콘솔 어플리케이션 ===<br />
<br />
콘솔 어플리케이션은 GUI를 가지지 않습니다. 그 대신 일반적으로 콘솔상에서 실행되며 입력과 출력 모두 콘솔을 통해 이루어지게 됩니다. 콘솔은 윈도우즈 에서 보통 '''커맨드 프롬프트 윈도''' 라고 불리며 OS X나 리눅스에서는 '''터미널 윈도'''라고 불립니다. 콘솔 어플리케이션으로는 윈도우즈의 FC (파일비교:file compare)나 유닉스의 cd, cp 같은 작은 유틸리티를 예로 들 수 있습니다. 콘솔 어플리케이션은 GUI가 없지만 다른 프로그램이나 배치파일 (유닉스/리눅스에서는 셸 스크립트) 에서 실행될 수 있는 강력한 처리 계통 입니다. 프리 파스칼 컴파일러 및 함께 포함된 유틸리티들은 모두 콘솔 프로그램이며 따라서 콘솔이나 배치파일, 또는 라자루스 IDE 내에서 실행시킬 수 있습니다. <br />
<br />
콘솔 어플리케이션은 간단한 텍스트 에디터와 프리 파스칼 컴파일러 만으로도 개발할 수 있으며 굳이 라자루스를 사용할 필요는 없습니다. 그러나 라자루스 IDE 상에서 콘솔 어플리케이션을 작성한다면 보다 쉽게 소스 코드를 편집하고 컴파일을 할 수 있습니다.<br />
<br />
=== 동적 링크 라이브러리 === <br />
'''동적 링크 라이브러리'''는 컴파일된 함수의 집합이며, 다른 프로그램으로부터 호출할 수 있습니다. 그 명칭에서 알 수 있듯이, 이 라이브러리는 실행 파일이 컴파일 될 때 링크할 필요가 없으며, 실행시에 호출할 수 있습니다. 윈도우즈에서 이 라이브러리 파일은 .dll (dynamic-link library 또는 DLL) 이라는 확장자를 가집니다. OS X 에서의 확장자는 .dylib (dynamic shared library) 이며, 리눅스에서는 .so (shared object library) 라는 확장자가 붙습니다. 동적 링크 라이브러리는 일반적으로 다른 프로그램에 새로운 기능을 추가 하거나, C나 C++같은 언어에서 호출될 라이브러리를 만들거나, 아주 큰 프로젝트에서 각 프로그래머들이 기능을 분담해 개발하기 위한 용도로 사용됩니다. (역자 주: 마지막 문단은 "다른 개발자의 발가락을 밟지 않게 하기 위해 사용된다"는데... 이 표현을 우리말로 맛깔스럽게 옮기기가 쉽지 않네요. ㅠㅠ). 윈도우즈 자체도 수백개의 DLL로 구성되어 있으며, OpenOffice.org 같이 규모가 큰 어플리케이션도 마찬가지 방법을 쓰고 있습니다. <br />
<br />
콘솔 어플리케이션 개발과 마찬가지로 동적 링크 라이브러리도 간단한 텍스트 에디터와 프리 파스칼 컴파일러 만으로 개발할 수 있습니다. 물론 라자루스 IDE 상에서도 동적 링크 라이브러리의 프로젝트를 생성해 개발할 수 있습니다. <br />
<br />
윈도우 환경에서 DLL은 복잡하고 불안정하다는 별로 좋지 않은 평을 듣고 있습니다. This has more to do with the way they've sometimes been installed than it does with DLLs themselves. (이 문장 좀 도와주세요...) 실제로 DLL과 정보를 교환할 때는 표준, 또는 특정 언어에 종속적인 객체나 구조체가 아닌 간단한 데이터 타입을 넘겨 주어야 하는데, 이를 위해 프로그래머는 매우 세심한 주의를 기울여야 합니다. 물론 이것을 잘 해낼 수 있다면 보다 좋은 결과를 얻을 수 있고 프로그램은 안정적으로 동작 할 것입니다.<br />
<br />
=== GUI 어플리케이션 ===<br />
<br />
우리가 매일 사용하는 대부분의 프로그램은 GUI 어플리케이션 입니다. 워드 프로세서, 웹 브라우저, 스프레드쉬트, 그리고 많은 개발 툴들이 그러합니다. 라자루스와 델파이는 완전한 기능을 가지는 GUI 어플리케이션의 대표적인 예 입니다. 라자루스에서 GUI 어플리케이션을 개발할 때는, 단지 파스칼 코드를 유니트에 적어주는 것 외에도 비주얼 컨트롤들, 예를 들면 버튼이나 텍스트 박스 등을 이용해 폼을 디자인 할 수도 있습니다. 델파이와 마찬가지로 라자루스의 폼 디자인 역시 직관적입니다. 컨트롤들의 속성(property)는 IDE 또는 코드로 설정할 수 있습니다.<br />
<br />
LCL 컨트롤들이 여러가지 플랫폼을 지원하고 있기 때문에, 이를 사용한 GUI 어플리케이션은 하나의 플랫폼 (예를 들면 윈도우즈) 에서 개발을 하더라도 폼의 디자인 또는 코드 한 줄 바꾸지 않고도 다른 플랫폼 (예를 들어 OS X 또는 리눅스) 로 컴파일 할 수 있습니다.</div>Orankehttps://wiki.freepascal.org/index.php?title=Nomenclature/ko&diff=32300Nomenclature/ko2008-11-26T10:33:07Z<p>Oranke: </p>
<hr />
<div>{{Nomenclature}}<br />
<br />
* 프로퍼티는 동사가 아닌 <b>명사</b>로 시작해야 합니다. <br />
* 메소드는 <b>동사</b>로 시작합니다<br />
* "GetFoo" 라는 메소드 이름은 "Foo" 라는 프로퍼티의 값을 얻는 용도로 사용합니다.<br />
* "SetFoo" 라는 메소드 이름은 "Foo" 라는 프로퍼티의 값을 설정하는 용도로 사용합니다.<br />
* "DoFoo" 라는 메소드 이름은 "OnFoo" 이벤트를 호출하기 위한 용도로 사용합니다.<br />
* 제안사항: 어떤 프로퍼티를 갱신하거나 유효하게 만들려고 할 때, "DoSetFoo" 메소드 보다는 가급적 "UpdateFoo" 메소드를 사용하도록 합시다.<br />
* 이벤트 프로퍼티 이름 앞에는 On....을 붙이세요. 그 후에 수식어나 형용사가 이어지고 마지막으로 술어나 주어, 명사가 옵니다. 예를 들어 OnFilterRecord, OnPostError, OnDblClick 처럼 말이죠.<br />
* TControl로 부터 상속받은 객체에 대한 통지는 CNxxx 와 같이 이름을 붙여주세요. <br />
( 원문: notifications for TControl decendants should be named CNxxx. 번역이 이상하네요 수정 부탁..)</div>Orankehttps://wiki.freepascal.org/index.php?title=User_talk:Oranke&diff=32299User talk:Oranke2008-11-26T10:26:46Z<p>Oranke: /* 번역완료... */</p>
<hr />
<div>라자루스 위키 번역작업중.<br />
<br />
=== 번역중... ===<br />
<br />
* [[Lazarus_Documentation/ko]]<br />
* [[Nomenclature/ko]]<br />
* [[DesignGuidelines/ko]]<br />
* [[Overview_of_Free_Pascal_and_Lazarus/ko]]<br />
<br />
=== 번역완료... ===<br />
<br />
* [[Main_Page/ko]]</div>Orankehttps://wiki.freepascal.org/index.php?title=User_talk:Oranke&diff=32298User talk:Oranke2008-11-26T10:26:37Z<p>Oranke: /* 번역중... */</p>
<hr />
<div>라자루스 위키 번역작업중.<br />
<br />
=== 번역중... ===<br />
<br />
* [[Lazarus_Documentation/ko]]<br />
* [[Nomenclature/ko]]<br />
* [[DesignGuidelines/ko]]<br />
* [[Overview_of_Free_Pascal_and_Lazarus/ko]]<br />
<br />
=== 번역완료... ===<br />
<br />
* 없음</div>Orankehttps://wiki.freepascal.org/index.php?title=Overview_of_Free_Pascal_and_Lazarus/ko&diff=32293Overview of Free Pascal and Lazarus/ko2008-11-25T16:52:09Z<p>Oranke: /* GUI 어플리케이션 */</p>
<hr />
<div>{{Overview of Free Pascal and Lazarus}}<br />
<br />
프리 파스칼(FPC)은 두 개의 큰 특징을 가진 오픈 소스 파스칼 컴파일러 입니다. 첫번째는 [[Delphi|델파이]]와의 호환성입니다. 또 하나는 다중 플랫폼에 대한 지원으로서 현재 윈도우즈, 맥 OS X, 리눅스에서 사용할 수 있습니다. 프리 파스칼은 델파이에서 확장된 오브젝트 파스칼 프로그래밍 언어를 지원하는 것 뿐만 아니라, 델파이에서 사용되는 강력한 기능의 라이브러리나 클래스들도 함께 이용할 수 있습니다. 델파이 사용자에게 잘 알려져 있는 System, SysUtils, StrUtils, DateUtils, Classes, Variants, Math, IniFiles 그리고 Registry 등의 유니트들도 있으며, 이것들은 프리 파스칼이 동작하는 모든 플랫폼 상에서 동작 합니다. 그 외에도 프리 파스칼에는 Windows, ShellAPI, BaseUnix, Unix, 그리고 DynLibs 처럼 특정 운영체제를 위한 유니트들도 준비되어 있습니다. '''프리 파스칼 런타임 라이브러리'''(RTL)는 이 유니트들을 모아놓은 커다란 라이브러리 입니다. <br />
<br />
라자루스는 프리 파스칼용 통합 개발 환경(IDE)을 제공하는 오픈 소스 프로젝트 입니다. 프리 파스칼로 개발 되었으며, 문법 강조가 가능한 코드 에디터와 직관적인 폼 디자이너를 가지고 있습니다. 라자루스가 사용하는 '''라자루스 컴포넌트 라이브러리'''(LCL) 은 델파이의 '''비주얼 컴포넌트 라이브러리'''(VLC) 과 높은 호환성을 가지고 있으며 VCL 컨트롤과 마찬가지로 폼이나 버튼, 텍스트박스 등을 제공 합니다. 이 컨트롤들을 적절하게 배치하여 '''그래픽 사용자 인터페이스'''(GUI)를 가지는 어플리케이션을 작성할 수 있습니다.<br />
<br />
프리 파스칼과 라자루스는 파스칼 코드로 작성 되어 있습니다. 프리 파스칼 컴파일러와 라자루스 뿐 아니라 RTL 이나 LCL의 모든 유니트들의 소스 코드는 완전히 공개되어 있습니다. <br />
<br />
프리 파스칼과 라자루스는 델파이와 마찬가지로 일반적인 프로그래밍 툴 입니다. 이 의미는 다음과 같은 폭 넓고 다양한 프로그램을 개발하는 데 사용할 수 있다는 의미 입니다. <br />
<br />
<br />
=== 콘솔 어플리케이션 ===<br />
<br />
콘솔 어플리케이션은 GUI를 가지지 않습니다. 그 대신 일반적으로 콘솔상에서 실행되며 입력과 출력 모두 콘솔을 통해 이루어지게 됩니다. 콘솔은 윈도우즈 에서 보통 '''커맨드 프롬프트 윈도''' 라고 불리며 OS X나 리눅스에서는 '''터미널 윈도'''라고 불립니다. 콘솔 어플리케이션으로는 윈도우즈의 FC (파일비교:file compare)나 유닉스의 cd, cp 같은 작은 유틸리티를 예로 들 수 있습니다. 콘솔 어플리케이션은 GUI가 없지만 다른 프로그램이나 배치파일 (유닉스/리눅스에서는 셸 스크립트) 에서 실행될 수 있는 강력한 처리 계통 입니다. 프리 파스칼 컴파일러 및 함께 포함된 유틸리티들은 모두 콘솔 프로그램이며 따라서 콘솔이나 배치파일, 또는 라자루스 IDE 내에서 실행시킬 수 있습니다. <br />
<br />
콘솔 어플리케이션은 간단한 텍스트 에디터와 프리 파스칼 컴파일러 만으로도 개발할 수 있으며 굳이 라자루스를 사용할 필요는 없습니다. 그러나 라자루스 IDE 상에서 콘솔 어플리케이션을 작성한다면 보다 쉽게 소스 코드를 편집하고 컴파일을 할 수 있습니다.<br />
<br />
=== 동적 링크 라이브러리 === <br />
'''동적 링크 라이브러리'''는 컴파일된 함수의 집합이며, 다른 프로그램으로부터 호출할 수 있습니다. 그 명칭에서 알 수 있듯이, 이 라이브러리는 실행 파일이 컴파일 될 때 링크할 필요가 없으며, 실행시에 호출할 수 있습니다. 윈도우즈에서 이 라이브러리 파일은 .dll (dynamic-link library 또는 DLL) 이라는 확장자를 가집니다. OS X 에서의 확장자는 .dylib (dynamic shared library) 이며, 리눅스에서는 .so (shared object library) 라는 확장자가 붙습니다. 동적 링크 라이브러리는 일반적으로 다른 프로그램에 새로운 기능을 추가 하거나, C나 C++같은 언어에서 호출될 라이브러리를 만들거나, 아주 큰 프로젝트에서 각 프로그래머들이 기능을 분담해 개발하기 위한 용도로 사용됩니다. (역자 주: 마지막 문단은 "다른 개발자의 발가락을 밟지 않게 하기 위해 사용된다"는데... 이 표현을 우리말로 맛깔스럽게 옮기기가 쉽지 않네요. ㅠㅠ). 윈도우즈 자체도 수백개의 DLL로 구성되어 있으며, OpenOffice.org 같이 규모가 큰 어플리케이션도 마찬가지 방법을 쓰고 있습니다. <br />
<br />
콘솔 어플리케이션 개발과 마찬가지로 동적 링크 라이브러리도 간단한 텍스트 에디터와 프리 파스칼 컴파일러 만으로 개발할 수 있습니다. 물론 라자루스 IDE 상에서도 동적 링크 라이브러리의 프로젝트를 생성해 개발할 수 있습니다. <br />
<br />
윈도우 환경에서 DLL은 복잡하고 불안정하다는 별로 좋지 않은 평을 듣고 있습니다. This has more to do with the way they've sometimes been installed than it does with DLLs themselves. (이 문장 좀 도와주세요...) 실제로 DLL과 정보를 교환할 때는 표준, 그리고 간단한 데이터 타입(언어에 특정적인 객체나 구조체가 아닌)을 넘겨 주어야 하는데, 이 때문에 위해 프로그래머는 세심한 주의를 기울여야 합니다. 물론 이것을 잘 해낼 수 있다면 보다 좋은 결과를 얻을 수 있고 프로그램은 안정적으로 동작 할 것입니다.<br />
<br />
=== GUI 어플리케이션 ===<br />
<br />
우리가 매일 사용하는 대부분의 프로그램은 GUI 어플리케이션 입니다. 워드 프로세서, 웹 브라우저, 스프레드쉬트, 그리고 많은 개발 툴들이 그러합니다. 라자루스와 델파이는 완전한 기능을 가지는 GUI 어플리케이션의 대표적인 예 입니다. 라자루스에서 GUI 어플리케이션을 개발할 때는, 단지 파스칼 코드를 유니트에 적어주는 것 외에도 비주얼 컨트롤들, 예를 들면 버튼이나 텍스트 박스 등을 이용해 폼을 디자인 할 수도 있습니다. 델파이와 마찬가지로 라자루스의 폼 디자인 역시 직관적입니다. 컨트롤들의 속성(property)는 IDE 또는 코드로 설정할 수 있습니다.<br />
<br />
LCL 컨트롤들이 여러가지 플랫폼을 지원하고 있기 때문에, 이를 사용한 GUI 어플리케이션은 하나의 플랫폼 (예를 들면 윈도우즈) 에서 개발을 하더라도 폼의 디자인 또는 코드 한 줄 바꾸지 않고도 다른 플랫폼 (예를 들어 OS X 또는 리눅스) 로 컴파일 할 수 있습니다.</div>Orankehttps://wiki.freepascal.org/index.php?title=Overview_of_Free_Pascal_and_Lazarus/ko&diff=32292Overview of Free Pascal and Lazarus/ko2008-11-25T16:38:52Z<p>Oranke: /* GUI 어플리케이션 */</p>
<hr />
<div>{{Overview of Free Pascal and Lazarus}}<br />
<br />
프리 파스칼(FPC)은 두 개의 큰 특징을 가진 오픈 소스 파스칼 컴파일러 입니다. 첫번째는 [[Delphi|델파이]]와의 호환성입니다. 또 하나는 다중 플랫폼에 대한 지원으로서 현재 윈도우즈, 맥 OS X, 리눅스에서 사용할 수 있습니다. 프리 파스칼은 델파이에서 확장된 오브젝트 파스칼 프로그래밍 언어를 지원하는 것 뿐만 아니라, 델파이에서 사용되는 강력한 기능의 라이브러리나 클래스들도 함께 이용할 수 있습니다. 델파이 사용자에게 잘 알려져 있는 System, SysUtils, StrUtils, DateUtils, Classes, Variants, Math, IniFiles 그리고 Registry 등의 유니트들도 있으며, 이것들은 프리 파스칼이 동작하는 모든 플랫폼 상에서 동작 합니다. 그 외에도 프리 파스칼에는 Windows, ShellAPI, BaseUnix, Unix, 그리고 DynLibs 처럼 특정 운영체제를 위한 유니트들도 준비되어 있습니다. '''프리 파스칼 런타임 라이브러리'''(RTL)는 이 유니트들을 모아놓은 커다란 라이브러리 입니다. <br />
<br />
라자루스는 프리 파스칼용 통합 개발 환경(IDE)을 제공하는 오픈 소스 프로젝트 입니다. 프리 파스칼로 개발 되었으며, 문법 강조가 가능한 코드 에디터와 직관적인 폼 디자이너를 가지고 있습니다. 라자루스가 사용하는 '''라자루스 컴포넌트 라이브러리'''(LCL) 은 델파이의 '''비주얼 컴포넌트 라이브러리'''(VLC) 과 높은 호환성을 가지고 있으며 VCL 컨트롤과 마찬가지로 폼이나 버튼, 텍스트박스 등을 제공 합니다. 이 컨트롤들을 적절하게 배치하여 '''그래픽 사용자 인터페이스'''(GUI)를 가지는 어플리케이션을 작성할 수 있습니다.<br />
<br />
프리 파스칼과 라자루스는 파스칼 코드로 작성 되어 있습니다. 프리 파스칼 컴파일러와 라자루스 뿐 아니라 RTL 이나 LCL의 모든 유니트들의 소스 코드는 완전히 공개되어 있습니다. <br />
<br />
프리 파스칼과 라자루스는 델파이와 마찬가지로 일반적인 프로그래밍 툴 입니다. 이 의미는 다음과 같은 폭 넓고 다양한 프로그램을 개발하는 데 사용할 수 있다는 의미 입니다. <br />
<br />
<br />
=== 콘솔 어플리케이션 ===<br />
<br />
콘솔 어플리케이션은 GUI를 가지지 않습니다. 그 대신 일반적으로 콘솔상에서 실행되며 입력과 출력 모두 콘솔을 통해 이루어지게 됩니다. 콘솔은 윈도우즈 에서 보통 '''커맨드 프롬프트 윈도''' 라고 불리며 OS X나 리눅스에서는 '''터미널 윈도'''라고 불립니다. 콘솔 어플리케이션으로는 윈도우즈의 FC (파일비교:file compare)나 유닉스의 cd, cp 같은 작은 유틸리티를 예로 들 수 있습니다. 콘솔 어플리케이션은 GUI가 없지만 다른 프로그램이나 배치파일 (유닉스/리눅스에서는 셸 스크립트) 에서 실행될 수 있는 강력한 처리 계통 입니다. 프리 파스칼 컴파일러 및 함께 포함된 유틸리티들은 모두 콘솔 프로그램이며 따라서 콘솔이나 배치파일, 또는 라자루스 IDE 내에서 실행시킬 수 있습니다. <br />
<br />
콘솔 어플리케이션은 간단한 텍스트 에디터와 프리 파스칼 컴파일러 만으로도 개발할 수 있으며 굳이 라자루스를 사용할 필요는 없습니다. 그러나 라자루스 IDE 상에서 콘솔 어플리케이션을 작성한다면 보다 쉽게 소스 코드를 편집하고 컴파일을 할 수 있습니다.<br />
<br />
=== 동적 링크 라이브러리 === <br />
'''동적 링크 라이브러리'''는 컴파일된 함수의 집합이며, 다른 프로그램으로부터 호출할 수 있습니다. 그 명칭에서 알 수 있듯이, 이 라이브러리는 실행 파일이 컴파일 될 때 링크할 필요가 없으며, 실행시에 호출할 수 있습니다. 윈도우즈에서 이 라이브러리 파일은 .dll (dynamic-link library 또는 DLL) 이라는 확장자를 가집니다. OS X 에서의 확장자는 .dylib (dynamic shared library) 이며, 리눅스에서는 .so (shared object library) 라는 확장자가 붙습니다. 동적 링크 라이브러리는 일반적으로 다른 프로그램에 새로운 기능을 추가 하거나, C나 C++같은 언어에서 호출될 라이브러리를 만들거나, 아주 큰 프로젝트에서 각 프로그래머들이 기능을 분담해 개발하기 위한 용도로 사용됩니다. (역자 주: 마지막 문단은 "다른 개발자의 발가락을 밟지 않게 하기 위해 사용된다"는데... 이 표현을 우리말로 맛깔스럽게 옮기기가 쉽지 않네요. ㅠㅠ). 윈도우즈 자체도 수백개의 DLL로 구성되어 있으며, OpenOffice.org 같이 규모가 큰 어플리케이션도 마찬가지 방법을 쓰고 있습니다. <br />
<br />
콘솔 어플리케이션 개발과 마찬가지로 동적 링크 라이브러리도 간단한 텍스트 에디터와 프리 파스칼 컴파일러 만으로 개발할 수 있습니다. 물론 라자루스 IDE 상에서도 동적 링크 라이브러리의 프로젝트를 생성해 개발할 수 있습니다. <br />
<br />
윈도우 환경에서 DLL은 복잡하고 불안정하다는 별로 좋지 않은 평을 듣고 있습니다. This has more to do with the way they've sometimes been installed than it does with DLLs themselves. (이 문장 좀 도와주세요...) 실제로 DLL과 정보를 교환할 때는 표준, 그리고 간단한 데이터 타입(언어에 특정적인 객체나 구조체가 아닌)을 넘겨 주어야 하는데, 이 때문에 위해 프로그래머는 세심한 주의를 기울여야 합니다. 물론 이것을 잘 해낼 수 있다면 보다 좋은 결과를 얻을 수 있고 프로그램은 안정적으로 동작 할 것입니다.<br />
<br />
=== GUI 어플리케이션 ===<br />
<br />
우리가 매일 사용하는 대부분의 프로그램은 GUI 어플리케이션 입니다. 워드 프로세서, 웹 브라우저, 스프레드쉬트, 그리고 많은 개발 툴들이 그러합니다. 라자루스와 델파이는 완전한 기능을 가지는 GUI 어플리케이션의 대표적인 예 입니다. 라자루스에서 GUI 어플리케이션을 개발할 때는, 단지 파스칼 코드를 유니트에 적어주는 것 외에도 비주얼 컨트롤들, 예를 들면 버튼이나 텍스트 박스 등을 이용해 폼을 디자인 할 수도 있습니다. 델파이와 마찬가지로 라자루스의 폼 디자인 역시 직관적입니다. 컨트롤들의 속성(property)는 IDE 또는 코드로 설정할 수 있습니다.<br />
<br />
LCL 컨트롤들이 여러가지 플랫폼을 지원하고 있기 때문에, 이를 사용한 GUI 어플리케이션은 하나의 플랫폼 (예를 들면 윈도우즈) 에서 개발을 하더라도 폼의 디자인이 또는 코드 한 줄 바꾸지 않고도 다른 플랫폼 (예를 들어 OS X 또는 리눅스) 로 컴파일 할 수 있습니다.</div>Oranke