Difference between revisions of "Lazarus Faq/ja"

From Free Pascal wiki
Jump to navigationJump to search
(categories)
 
(42 intermediate revisions by 9 users not shown)
Line 3: Line 3:
 
{{Japanese Menu}}
 
{{Japanese Menu}}
  
このFAQはwww.freepascal.orgからWikiにコピーされたので、保守、拡張しやすくなっています。
 
  
 
== 一般的なこと ==
 
== 一般的なこと ==
 +
=== どうしてコンパイル後のバイナリがこんなに大きいの? ===
 +
バイナリが大きくなる理由は、GDB(GNU Debugger)で利用するデバッグ情報を含んでいるためです。
  
=== どうしたらもっと他のFAQを見つけることができますか? ===
 
  
[http://www.lazarus.freepascal.org オフィシャルWEBサイト]を見てください. 他のFAQが同様にあるかもしれません。
+
実行ファイルからデバッグ情報を除去するオプション(-Xs)がありますが、 バージョン2.0.2以前のコンパイラではバグのため正しく動きません。バージョン2.0.4以降のコンパイラでは修正されています。
  
===どうして出来たバイナリがこんなに大きいの?===
+
"strip" というプログラムでデバッグ情報を除去することもできます。 これは、Lazarusディレクトリの下のlazarus\pp\bin\i386-win32\ にあります。
バイナリはgdg(GNU Debugger)で使うための多くのデバッグ情報を含んでいるために大きくなります。
 
  
コンパイラには実行ファイルから、デバッグインフォメーションを除去するためのオプション(-Xs)があります。しかしながら、2.0.2と、以前のバージョンでは、コンパイラーのバグによって、これは正しく動きません。しかし、開発版ではすでにこのバグは修正されています。
+
コマンドラインから、 "strip --strip-all <実行ファイルへのパス>" とタイプすることでデバッグ情報を除去できます。
  
また、デバッグシンボルを除去するために、"strip"というプログラムを利用することができます。Lazarusディレクトリの下の、lazarus\pp\bin\i386-win32\にあります。
+
さらにプログラムを小さくしたい場合は、実行ファイルの圧縮ツール [http://upx.sourceforge.net/ UPX(upx.exe)] も利用できます。 これは、"strip" と同じく、Lazarusディレクトリの下の、lazarus\pp\bin\i386-win32\ にあります。 圧縮を復元するためのメモリのオーバーヘッドはありませんし、復元速度も Pentium 133 で ~10MB/sec 程度と大変高速です。
コマンドラインで、 "strip --strip-all <実行ファイルパス>" とタイプするだけです。
 
  
もし、プログラムをもっと小さくしたいときは、[http://upx.sourceforge.net/ UPX] も試してみてください。UPXは実行ファイルの良い圧縮ツールです。圧縮を復元するためのメモリのオーバーヘッドはありません。Pentium 133で ~10MB/sec程度の高速な復元をおこないます。
+
コマンドラインから、"upx <実行ファイルへのパス>" とタイプすることで、"upx" を利用できます。
upxを使うには、コマンドラインから、"upx <実行ファイルパス>" とタイプするだけです。
 
  
stripとupxをLazarusをおこなうと、単純なGUIプログラムは
+
"strip" と "upx" を簡単な Lazarus の GUI プログラムに適用すると、Linux で 700kb 程度、 Windows で 420kb 程度のサイズに収まるでしょう。
* ~ 700kb on Linux
 
* ~ 420kb on Windows
 
になります。
 
  
もっと詳細な回答は、[[fpc:Size Matters]]にあります。
+
UPXの欠点などの詳細は、[[Size Matters|サイズについて]]にあります。
  
 +
また、重要なことですが、一般的な hello world すら lazarus で作成すると、以下のような大量の機能が含まれてしまいます。
  
The binaries are big because they include a lot of debug information necessary for using gdb (GNU Debugger).
+
* XML 利用ライブラリ
 +
* 画像利用ライブラリ(png, xpm, bmp, ico ファイルなど)
 +
* Lazarus Component Library(LCL) のほとんどすべてのウイジェット
 +
* すべての Free Pascal Runtime Library(RTL)
  
The compiler has an option to remove the debug information from the executable (-Xs), but due to a bug in the compiler (version 2.0.2 and earlier), this doesn't work correctly. It has been fixed in the development version of the compiler.
+
このためにとても大きなサイズになりますが、実用アプリケーションで必要とされる機能をすでに含んでいるともいえます。
  
You can use a program called "strip" to remove the debug symbols from the executable file. It is located under lazarus dir lazarus\pp\bin\i386-win32\.
+
Lazarus の実行ファイルのサイズは最初から大きいですが、ソースコードやフォームが増えても、少しづつしか増えません。 C++や他の言語では、hello world などはとても小さいかもしれませんが、実用的なアプリケーションを書くようになると急激にサイズが増加するでしょう。
  
Just type "strip --strip-all <your executable file with path>" on the command line.
+
[[Image:Lazarus_vs_cpp.png]]
  
If you want to make your program even smaller, you should try [http://upx.sourceforge.net/ UPX] too. UPX is a very good exe compressor. It includes no memory overhead due to in-place decompression. It also has a very fast decompression (~10 MB/sec on an Pentium 133).
 
  
To use upx just type "upx <your executable file with path>" on the command line.
+
'''Lazarus/FPC アプリケーションのサイズを縮小するための簡単なガイド''' ''(Lazarus 0.9.26 で確認)''
  
after using both strip and upx a simple GUI Lazarus program gets:
+
* 1. プロジェクト|コンパイラオプション|コード|スマートリンク可能な(-CX) -> チェックする。
* ~ 700kb on Linux
+
* 2. プロジェクト|コンパイラオプション|リンク|デバッグ中|実行ファイルからシンボルを除く(-Xs) -> チェックする。
* ~ 420kb on Windows
+
* 3. プロジェクト|コンパイラオプション|リンク|リンクスタイル|スマートリンク(-XX) -> チェックする。
  
A more detailed answer is given on [[fpc:Size Matters]].
+
特に 2. が重要と思われます。 単純なアプリケーションは、いままでの 15-20 MB から 1-3 MB になります。 以下を試すのもよいでしょう: プロジェクト|コンパイラオプション|コード|最適化|速度より最小化を優先(-Os) -> チェックする。 (実行速度が低下することに注意)
  
=== どうしてリンクがWindowsでは遅いのでしょうか? ===
+
* 4. "UPX <実行ファイルのパス>" によって 1/2~1/3 に圧縮されます。 (注意: [[Size Matters|サイズについて]]にもあるように、UPX利用の欠点もあります。)
  
一般的に、Windowsでのリンクは他のプラットホームでのリンクよりも時間がかかります。それは、Free Pascalで使われているGNU リンカが、Windowsでは動作が遅いからです。
+
''' Chart of default sizes for an empty Application with various settings and operating systems'''
  
テストとして、Lazarus 0.9.12ではLCLがスマートリンクされてリリースされていました。これで、以前のリリースとくらべ実行ファイルはstripとupxのあとで30%小さくなりました。しかし、この影響でリンク作業が複雑になり、他のGNU リンカの問題がでてきました。この問題についての調査は[[File size and smartlinking/ja]]にあります。
+
Well I ran tests I did on Lazarus 0.9.29 with FPC 2.4 (FPC
 +
2.2.4 with Windows). ''Optimized compiler'' mean using the advices above but ''without using UPX''. ''Default Lazarus'' means as installed from package/setup. ''LCL without debug informations'' mean after rebuilding Lazarus IDE and LCL without debug informations (-g-).
  
この問題はWindowsのみで発生しています。そして、比較的古いか、メモリの少ないコンピュータ(1GHz以下、128MB以下)で顕著に現れます。内臓リンカも開発中なので、この問題を解決してくれるでしょう。しかし、準備できるまでにまだ時間がかかります。
+
<TABLE WIDTH=642 BORDER=0 CELLPADDING=1 CELLSPACING=0>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263></TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=111>Default Lazarus</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=220>LCL without debug informations</TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263><U>Ubuntu 64 bits / Lazarus 64 bits</U></TD>
 +
<TD COLSPAN=4 WIDTH=372></TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>Default application</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=111>13,4&nbsp; Mb</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=220>7,5 Mb / 8</TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>Optimized compiler</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=111>4,4 Mb</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=220>2,70 Mb (0.29svn FPC2.4 2,5)</TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>&nbsp; &nbsp;</TD>
 +
<TD COLSPAN=4 WIDTH=372></TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263><U>Ubuntu 32 bits / Lazarus 32 bits</U></TD>
 +
<TD COLSPAN=4 WIDTH=372></TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>Default application</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=111>19,6&nbsp; Mb</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=220>5,7 Mb</TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>Optimized compiler</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=111>2,9 Mb</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=220>1,6 Mb</TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>&nbsp; &nbsp;</TD>
 +
<TD COLSPAN=4 WIDTH=372></TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263><U>Windows XP 32 bits / Lazarus 32 bits</U></TD>
 +
<TD COLSPAN=4 WIDTH=372></TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>Default application</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=111>11,8 Mb</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=220>2,14 Mb</TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>Optimized compiler</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=111>1,62 Mb</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=220>1,50 Mb</TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>&nbsp; &nbsp;</TD>
 +
<TD COLSPAN=4 WIDTH=372></TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263><U>Windows Seven 64 bits / Lazarus 64 bits</U></TD>
 +
<TD COLSPAN=4 WIDTH=372></TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>Default application</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=111>12,3&nbsp; Mb</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=220>3,20 Mb</TD>
 +
</TR>
 +
<TR VALIGN=TOP>
 +
<TD WIDTH=263>Optimized compiler</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=111>2,14 Mb</TD>
 +
<TD WIDTH=14>&nbsp; &nbsp;</TD>
 +
<TD WIDTH=220>2,16 Mb</TD>
 +
</TR>
 +
</TABLE>
  
しかし、現実的にこの問題を解決するにはどうしたらよいでしょうか。2つの選択肢があります。
+
=== 'Fatal: Circular unit reference between a and b'(ユニットの循環的参照)エラーの回避 ===
  
 +
新規ユーザーが、2つのフォーム(TForm)で相互にプロパティを参照し合いたい場合などに陥りやすいエラーです。このエラーは、「uses」を「interface」セクションで宣言しているためにおこり、「uses」を「implementation」に移すことで解消できます。
  
# smart linkingをOffにしてください。Lazarusでは、 メニューで、Project -> Compiler Options -> Linking tabでチェックボックスをOffにするだけでは不十分です。Otherタブのcustom optionsで "-XS" を指定してください。アプリケーションをコンパイルすれば、スマートリンクされなくなります。
+
エラーとなる例:
# LCLを再コンパイルしてください。メニューから"Tools" -> "Configure Build Lazarus"を選択します。LCLをclean+buildを指定し、その他のすべてを Noneに指定し、"Ok"を押します。そのあと、メニューから"Tools" -> "Build Lazarus"を選択してください。これでLCLはスマートリンクされなくなり、コンパイルが高速になります。しかし、実行ファイルサイズも大きくなります。
+
  unit a;
 +
 
 +
  interface
 +
 
 +
  uses b;
 +
 
 +
  implementation
 +
 
 +
  end.
 +
  ...
 +
  unit b;
 +
 
 +
  interface
 +
 
 +
  uses a;
 +
 
 +
  implementation
 +
 
 +
  end.
 +
エラーとならない例:
 +
  unit a;
 +
 
 +
  interface
 +
 
 +
  implementation
 +
 
 +
  uses b;
 +
 
 +
  end.
 +
  ...
 +
  unit b;
 +
 
 +
  interface
 +
 
 +
  implementation
 +
 
 +
  uses a;
 +
 
 +
  end.
  
Just recompile your LCL. Open Lazarus. Go on the menu "Tools" -> "Configure Build Lazarus". Set LCL to clean+build and everything else to None and click "Ok". Now go on "Tools" -> "Build Lazarus". Now your LCL is no longer smartlinked and the compilation should be much faster, but your exes will be bigger too.
+
=== どうしてリンクがWindowsでは遅いのでしょうか? ===
  
 +
この問題は、 FPC2.2 以降かつ Lazarus 0.9.24 以降で解決されています。 Lazarus を更新してみてください。 古いバージョンについては以下を参照してください。
  
Generally speaking, compilation on Windows takes more time then other platforms because the GNU Linker utilized by Free Pascal is slow on this platform.
+
一般的に、Windows でのリンクは他のプラットホームより時間がかかります。 これは、Free Pascal で利用している GNU リンカの動作が Windows で遅いためです。 この問題は Windows のみに影響し、比較的古くメモリの少ないコンピュータ (1GHz以下、128MB以下)で顕著に現れます。
  
Also, as a test, Lazarus 0.9.12 was released with Smartlinked LCL. This means that executables are now about 30% smaller after strip and upx when compared to previous releases. This also means that the linking is much more complicated now and other GNU Linker problems appeared. A study about this is located here: [[File size and smartlinking]]
+
また、LCL をスマートリンクしている場合、リンク作業はさらに遅くなります。 この問題についての調査は[[File size and smartlinking/ja|ファイルサイズとスマートリンク]]にあります。
  
This problem only affects Windows, and is only bad on relatively old computers (less then 1Ghz) and computers with little RAM (128MB or less).
+
内部リンカはすでに開発されていますが、 FreePascal 2.2 以上でないと利用できません。これは、リンク時間を劇的に短くします。
  
A internal linker is being developed. It should solve this, but will still take some time to be ready.
+
'''注意''': 2.1.1 では、Windows は win32/64/ce のために内部リンカを利用します。 これは作業を少し早めるでしょう。 Lazarus は 再コンパイルを行い、280MB ほどを使います。
  
But how to solve this in the mean time? You have two options:
 
# Turn of smart linking. Unfortunately Lazarus unchecking the checkbox in Project -> Compiler Options -> Linking tab, is not enough. You must also add "-XS" to the custom options on the Other tab. If you compile your application, it will not use smartlinking.
 
# Just recompile your LCL. Open Lazarus. Go on the menu "Tools" -> "Configure Build Lazarus". Set LCL to clean+build and everything else to None and click "Ok". Now go on "Tools" -> "Build Lazarus". Now your LCL is no longer smartlinked and the compilation should be much faster, but your exes will be bigger too.
 
  
 
=== ppc386.cfg や fpc.cfgは必要でしょうか? ===
 
=== ppc386.cfg や fpc.cfgは必要でしょうか? ===
  
fpc.cfgのみ必要です。コンパイラがライブラリを見つけるための方法が書いてあります。
+
fpc.cfgのみ必要です。 コンパイラがライブラリを見つけるための方法が書いてあります。
  
You only need fpc.cfg. This way the compiler knows where to find the libraries.
 
  
 
=== どうしたらLazarusをコンパイルできますか? ===
 
=== どうしたらLazarusをコンパイルできますか? ===
Line 89: Line 215:
 
  $ make clean all
 
  $ make clean all
  
Do something like this:
 
$ cd lazarus
 
$ make clean all
 
  
=== どのようにしたら、LCLをベースとした上に他のプロジェクトをビルドできますか?===
+
=== どのようにしたら、LCLをベースとした他のプロジェクトをビルドできますか?===
 +
 
 +
アプリケーション作成に IDE を使えない場合、lazbuild を利用してください。 これはコマンドライン版の Lazarus プロジェクトのビルド環境です。
 +
IDE も lazbuild も使えない場合、fpc.cfg の最後に次の行を追加してください。
  
もしアプリケーション作成にIDEを使えない場合、次の行をfpc.cfgの最後に入れてください。
+
  # 他のツールキットの探索パス (Linux)
 +
  -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{ツールキット}
  
# Add Lazarus libs
+
  # 他のツールキットの探索パス (Windows)
   -Fu/your.lazarus.root/lcl/units
+
   -Fu/{YourLazarusDirectory}/components/units/{ツールキット}
  -Fu/your.lazarus.root/lcl/units/{YourToolKit}
 
  -Fu/your.lazarus.root/components/units
 
  -Fu/your.lazarus.root/components/units/{YourToolKit}
 
  
: {YourToolKit} のところは、 GTK, Gnome , Win32 が入ります。
+
: {ツールキット} には、''gtk2''、''gnome''、''qt'' や ''win32'' などを入れ、下記を実行してください。
そして、下記を実行してください。
 
 
::ppc386 your.project.pp
 
::ppc386 your.project.pp
  
 +
'''ヒント:''' ツールキットの開発パッケージのインストールを忘れないでください。 こんなメッセージを受け取るかもしれません。: [[Linker message: cannot find -l]].
  
If you can't use the IDE to build your applications, add the following lines to the end of your fpc.cfg
 
 
# Add Lazarus libs
 
  -Fu/your.lazarus.root/lcl/units
 
  -Fu/your.lazarus.root/lcl/units/{YourToolKit}
 
  -Fu/your.lazarus.root/components/units
 
  -Fu/your.lazarus.root/components/units/{YourToolKit}
 
 
:Where {YourToolKit} may be GTK, Gnome or Win32 and run:
 
::ppc386 your.project.pp
 
  
=== どのバージョンのFPC(FreePascalCompiler)が必要ですか? ===
+
=== どのバージョンの FPC(FreePascalCompiler) が必要ですか? ===
  
FPC Version 2.0.2 が推奨バージョンです。しかしながら、svn version の fpc 2.0.3 and 2.1.x.も使えます。
+
FPC Version 2.2.2 が全オペレーティングシステムに対する推奨バージョンです。
  
FPC Version 2.0.2 has been released, and that is the recommended version. You can also use the svn version of fpc 2.0.3 and 2.1.x.
 
  
 
=== Lazarusのコンパイルができません。 ===
 
=== Lazarusのコンパイルができません。 ===
# コンパイラが正しいバージョンか、確認してください。
+
# コンパイラは正しいバージョンですか?
# fpcのライブラリが同じバージョンかどうか確認してください。
+
# fpcのライブラリは同じバージョンですか?
# fpc.cfgがあるかどうか、そして、古いppc386.cfgがないかどうか、確認してください。
+
# コンパイラのインストールパスはスペースを含まないように!
# OS依存のFAQを確認してください。
+
# fpc.cfg はありますか? 古い ppc386.cfg はあったらだめですよ。
 +
# OS 依存についての FAQ も確認してください。
  
# Check if the compiler has the correct version
 
# Check if the (fpc)libraries are from the same version.
 
# Check if you have a fpc.cfg and no old ppc386.cfg
 
# Check also the OS-dependent FAQs
 
  
 
=== プロジェクトをコンパイルしようとするとエラーがでます ===
 
=== プロジェクトをコンパイルしようとするとエラーがでます ===
 
==== "Cannot find Unit interfaces". これはどうしたら解決できますか?====
 
==== "Cannot find Unit interfaces". これはどうしたら解決できますか?====
  
このコンパイル済みのユニットは{LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppuにあります。これが、ただ一つそこにあることを確認してください。もし、色んなバージョンのinterfaces.ppuがあると、たとえば、lclの検索パスのディレクトリに入っていたりすると、間違ったコンフィグレーションになっている可能性が高いです。全てのinterfaces.ppuを削除して、上記のディレクトリのみのものだけにしてください。
+
これは、コンパイラが ''interfaces.ppu'' を見つけられなかったり、 見つけたが それがおかしなファイルであるときに表示されます。
 +
 
 +
このユニットは、 {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu にあります。 (例えば、/home/username/lazarus/lcl/units/i386-linux/gtk/interfaces.ppu)。
  
もし、これまで使ってきたwidgetsetと違うwidgetsetを選択した場合、そのwidgetset用にLCLをビルドする必要があります。
+
他の場所などに色々なバージョンの ''interfaces.ppu'' がある場合、間違った構成になっている(例えば、検索パスに lcl のディレクトリを追加していたり)可能性が高いため、全ての ''interfaces.ppu'' を削除して、上記のディレクトリの ''interfaces.ppu'' だけにしてください。
  
もし、このとおりになっていて、このエラーが発生した場合、コンパイルしているプロジェクト、利用しているLazarusIDE、とは異なったコンパイラの / rtlを使っています。この場合、次の事を試してください。
+
また、Lazarus をビルドするのに用いた widgetset と異なる widgetset を選択した場合、その widgetset 用に LCL をビルドする必要があります。
* LCL(もしくは、完全にLazarusを)を環境オプション内で選択しているコンパイラでリビルドします。リビルドは、Tools -> Build Lazarus で行えます。 これを行う前に、Tools -> Configure Build Lazarusで、現在の設定を確認してください。
 
  
* 環境オプションでコンパイラを、Lazarusをコンパイルしたものに変更してください。環境オプションで、Lazarusのパスが正しいかどうか、FPCのソースディレクトリが正しいかどうか、注意深く見てください。コンパイラコンフィグレーションファイルであるfpc.cfgがただ1つのバージョンのものがあるかどうか、確認してください。これは、Unixシステムでは、/etc/か、同じディレクトリに、Windowsシステムでは、fpcコンパイラと同じディレクトリにあります。
+
上記の確認後にもこのエラーが発生する場合、 あなたが Lazarus IDE をコンパイルするのに用いたコンパイラやrtlと異なるコンパイラやrtlを用いてプロジェクトをコンパイルしていると考えられます。 以下を試してください。
コンパイラを新しいバージョンにアップデートした場合、古いコピーが、しばしばこっそり残っています。これらは、ユーザーのホームディレクトリや、新しいコンパイラと同じディレクトリにあるかもしれません。これらを消去してください。
 
  
This compiled unit can be found in {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu.
+
* LCL (もしくは、Lazarus丸ごと) を 環境 -> オプション で選択しているコンパイラでリビルドしてください。 リビルドは、 ツール -> Lazarusを構築 で行えます。 構築前に、 ツール -> "Lazarus構築"を設定 で、現在の設定を確認してください。
  
Make sure, it is only there. If you have multiple versions of interfaces.ppu, then you have 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.
+
* 環境 -> オプション で、コンパイラを Lazarus をコンパイルしたものに変更してください。 また、環境 -> オプション で Lazarusディレクトリ や FPCソースディレクトリ へのパスが正しいかどうか確認してください。 さらに、コンパイラ構成ファイルである fpc.cfg が1つのバージョンのものだけがあるかどうか確認してください。 Linux/Unixシステムでは、/etc/ に、 Windows システムでは、fpcコンパイラと同じディレクトリにあるはずです。 "fpc -vt bogus" を実行し、どの fpc.cfg を利用しているかを確認してください。 コンパイラをアップデートした場合に、しばしば古いコピーがこっそり残ります。 ユーザーのホームディレクトリや新しいコンパイラをビルドしたディレクトリなどを確認して、これらを消去してください。
  
If you selected a different widgetset than you used to build lazarus, you need to build the LCL for this widgetset.  
+
* また、プロジェクトに利用しているウィジェットのセットを変更しても良いかもしれません。 例えば、Lazarus のサンプルフォルダにある "objectinspector" は、 gtk でコンパイルされています。 このプロジェクトを windows 上でコンパイルすると "Can't find unit interfaces" メッセージが表示されるでしょう。 ウィジェットセットを プロジェクト|コンパイラオプション...|LCLウィジェットタイプ(様々) から デフォルト(Win32) に変更することで問題が解決されます。
  
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
+
=== Delphi プロジェクトを lazarus でコンパイルしようとしたらエラーがでました ===
* Rebuild the LCL (or Lazarus completely) with the compiler selected in the Environmnent Options. You can this with Tools -> Build Lazarus. Before doing this, check the current settings in Tools -> Configure Build Lazarus.
+
==== {$R *.DFM}という行について: これはどのように解決できますか? ====
* 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. 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!!
 
  
=== When I try to compile delphi projects under lazarus, I have an error ===
+
Lazarus (Linux という方が分かりやすい) はリソースを解釈できませんので、Delphi/Win32 でしていたような方法をとることはできません。しかしながら、Lazarus はこれと似たようなシンプルな代替方法が使用できます。次の手順を使えば、 Delphi レイアウト(.dfm ファイル)を使用できます:
==== at the line :{$R *.DFM} How can I solve this problem ? ====
 
  
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:
+
*オリジナルの .dfm ファイルが必要です。 Delphi5 以降はこれがデフォルトに成っています。もし古いバージョンを使っているのなら: ALT + F12 でテキストでレイアウトを参照して、コピー&ペーストすることができます。テキストの .dfm ファイルが得られたら、.lfm ファイルにコピーして下さい。
 +
*(lazarus/tools の)lazres を使ってファイルを作成します。
  
*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.
+
      lazres yourform.lrs yourform.lfm
*Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm
+
 
*Add the following initialization section to
+
*イニシャライズセクションに次の行を付け加えます
  
 
       initialization
 
       initialization
 
       {$I yourform.lrs}
 
       {$I yourform.lrs}
  
Please keep in mind that not all properties in the dfm are supported yet by
+
lazarus では dfm ファイル内の全てのプロパティがサポートされているわけではないことを心にとどめておいて下さい。クラッシュする場合もあります。
lazarus, so you might get a crash.
 
  
 
==== 'Identifier not found LazarusResources'というエラーが発生します。 ====
 
==== 'Identifier not found LazarusResources'というエラーが発生します。 ====
  
フォームを作成しているとき、Lazarusは自動的に他のユニットをフォームユニットのusesセクションに追加します。
+
フォームを作成しているとき、Lazarusは自動的に他のユニットをフォームユニットのusesセクションに追加します。しかし、DelphiのユニットをLazarusのユニットに変換したときは、これは起こりません。
しかし、DelphiのユニットをLazarusのユニットに変換したときは、これは起こりません。
 
 
ですから、その場合LResourcesをフォームのユニットのUsesセクションに、追加する必要があります。
 
ですから、その場合LResourcesをフォームのユニットのUsesセクションに、追加する必要があります。
  
Line 187: Line 294:
  
 
FPCのソースパスは、次のように設定できます。
 
FPCのソースパスは、次のように設定できます。
Environment -> General Options -> Files -> FPC source path
 
 
Make sure, in the Project -> Project Inspector, that your project depends on the package 'LCL' and that you have installed the FPC sources.
 
 
Lazarus is the IDE and the visual components library LCL.
 
All other stuff, like IO, Database, FCL and RTL are provided by FPC.
 
The IDE needs the paths to all sources.
 
 
The FPC source path can be set via:
 
 
Environment -> General Options -> Files -> FPC source path
 
Environment -> General Options -> Files -> FPC source path
  
 
===別のファイルなしで、実行ファイルだけにできますか?どうしたらリソースを埋め込むことができますか?===
 
===別のファイルなしで、実行ファイルだけにできますか?どうしたらリソースを埋め込むことができますか?===
 
  
 
例えば、次のようにしてください:
 
例えば、次のようにしてください:
Line 221: Line 318:
  
  
For example:
+
=== Lazarusで使っている色んなファイル拡張子にはどんな意味がありますか? ===
  /your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...
+
 
will create sound.lrs from sound1.wav and sound2.wav.
+
[[Lazarus Tutorial/ja#The Lazarus files]]で例としていくつかの拡張子について説明しています。
 +
ここでは簡潔に示します。
 +
 
 +
; <code>*.lpi</code> : Lazarus Project Information ファイル (XML形式; プロジェクト固有の設定情報を持っています)
 +
; <code>*.lpr</code> : Lazarus Program file; メインのプログラムとなるパスカルのソースです。
 +
; <code>*.lfm</code> : Lazarus Form file; フォーム上の全てのオブジェクトの情報を持っています。 (Lazarus固有のフォーマットです。アクションは対応する<code>*.pas</code> ファイル内に記述されます)
 +
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code; Pascal で書かれたユニット (一般的にフォームは対応する<code>*.lfm</code>ファイルにあります。)
 +
; <code>*.lrs</code> : Lazarus Resource file; リソースファイル (これは生成されたファイルです。Windowsのリソースファイルと混同しないでください。). (訳注: フォームの要素などを定義したファイルです。)
 +
: このファイルは、lazres tool (ディレクトリLazarus/Toolsにある)で、コマンドラインを使って生成されます。
 +
   lazres myfile.lrs myfile.lfm
 +
; <code>*.ppu</code> : Compiled unit; コンパイルされたユニット
 +
; <code>*.lpk</code> : Lazarus package information file. (XML形式; パッケージ固有の設定情報を持っています)
 +
 
 +
=== テキストファイル型変数を ''var mytext: text;'' と宣言すると "Error: Error in type definition" と言われる。どうすればいいの? ===
 +
TControl クラスが [[doc:lcl/controls/tcontrol.text.html|Text]] プロパティを持っているからです。フォームのメソッドの中では、system ユニット(訳注: 暗黙のうちに uses される、Free Pascalのランタイムライブラリ)にある [[doc:rtl/system/text.html|Text]]よりもこちらが先に見えてしまいます。テキストファイル型に対するいいかえである[[doc:rtl/system/textfile.html|TextFile]] 型を使うか、ユニット名を明示して型宣言を行います。
 +
 
 +
var
 +
  MyTextFile: TextFile;
 +
  MyText: System.Text;
 +
 
 +
同様の問題がファイル名の登録とテキストファイルのクローズの際に起こります。TForm が ''assign'' メソッドと [[doc:lcl/forms/tcustomform.close.html|Close]] メソッドを持っているからです。 [[doc:rtl/objpas/assignfile.html|AssignFile]] 及び [[doc:rtl/objpas/closefile.html|CloseFile]] を用いるか、手続き名に system を付けて下さい(訳注: system.assign, system.close とする)
 +
 
 +
=== Printer.BeginDoc がエラーを起こす ===
 +
 
 +
Printers ユニットを uses 節に含める必要があります。
 +
 
 +
Printer4Lazarus パッケージをプロジェクトが必要とするものの中に含める必要があります。これはIDEから次のようにします:
 +
Project|Project Inspector|Add|New Requirement|Package Name:
 +
 
 +
ドロップダウンボックスの中に Printer4Lazarus パッケージがなければ、インストールしなければなりません。このパッケージは、Lazarusをインストールした時に次のディレクトリに置かれています:
 +
[lazarus installed directory]\components\printers
 +
 
 +
[lazarus installed directory] はデフォルトでは以下のの通りです:
 +
*Windows: c:\lazarus 
 +
*Linux: /usr/lib/lazarus
 +
 
 +
Printer.Printers を参照すると例外が発生する場合も同様にしてください。
 +
 
 +
=== TForm.ClientWidth/ClientHeightがTForm.Width/Heightと同じ値になるのはなぜ? ===
 +
 
 +
LCLではTForm.Width/Heightはフレームを含まないので、同じになります。なぜなら、すべてのプラットホームでフレームのサイズを取得する方法がないからです。
 +
(特定のOS上などに限定するなどして)信頼できる方法でなくてもよければ、LCLは(フレームを含まない指定値によって)フォームをスクリーン上で移動やリサイズすることができます。
 +
 
 +
一方、すべてのプラットホームで、フレーム込みのウインドウサイズについては取得することができ、変更することもできます。
 +
 
 +
過去のLCLフォームとの互換性を保つために特殊なバージョンの定数といくつかの拡張メソッドが追加されるでしょう。
  
Then include it *behind* the form lrs file:
 
  
...
+
== Debugger ==
initialization
 
{$i unit1.lrs} // this is main resource file (first)
 
{$i sound.lrs} // user defined resource file
 
 
end.
 
In your program you can then use:
 
Sound1AsString:=LazarusResources.Find('sound1').Value;
 
  
 
=== どうしたらデバッグ出力を見る事ができますか? ===
 
=== どうしたらデバッグ出力を見る事ができますか? ===
Line 254: Line 388:
 
Lazarusをデバッグする場合 :
 
Lazarusをデバッグする場合 :
 
Windowsでもっとも効果的な方法です。もし、出力をコンソールに出したい場合、lazarus.ppに{$APPTYPE console}を加えてください。そして、Lazarusをリビルドしてください。
 
Windowsでもっとも効果的な方法です。もし、出力をコンソールに出したい場合、lazarus.ppに{$APPTYPE console}を加えてください。そして、Lazarusをリビルドしてください。
 +
=== How Can I inspect properties? ===
  
 +
You have to use the latest FPC from trunk (2.5.1) or 2.4 once it is released.
  
 +
If you compile your application using -gw (dwarf debug info), you should be able to inspect properties.
  
The LCL has in the LCLProc procedure to write debug output:
+
Note this is only true for properties that map directly to a variable (the "read" declaration points to a member, not a function).
* '''DebugLn:''' works about the same as WriteLn, but accepts only strings.
 
* '''DbgOut:''' works about the same as Write, but accepts only strings.
 
  
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.
+
If your property returns the value of a function it is very dangerous to evaluate/inspect it. It would require this function to be called, and very often it would change the values of some of your variables. This would mean it would alter the state of your application in the debugger, and any further code-execution, debugging or inspections would return incorrect results.  
  
Debug output can also be written to file. The LCLProc unit checks in its initialization the command line parameters for '--debug-log=<file>'. If it finds it sends debug output to <file>.
+
The optional ability to explicitly inspect the results of functions (with the risks described) , and therefore calling code from the debugger is not yet implemented
  
If it doesn't find a --debug-log command line parameter, it looks if an environment variable xxx_debuglog exists, where xxx is the program file name without extension. For lazarus this would be lazarus_debuglog. If
+
=== Why does the debugger not show some Variables/Structures ("no such symbol"/"incomplete type") ===
such an environment variable exists, it uses that as file to write debug output to. Example: if you do:
 
set lazarus_debuglog=c:\lazarus\debug.txt
 
debug output will be written to c:\lazarus\debug.txt.
 
  
Since this is implemented in lclproc, every application using lclproc, can use this output facility.
+
For problems debugging:
 +
- properties<br>
 +
- Array of ... (Dynamic Array)<br>
 +
- Variables in Nested Procedures<br>
 +
- "no such symbol in context"<br>
 +
- "incomplete type"<br>
  
;Debuging Lazarus : Most usefull for windows: If you want output on a console, add {$APPTYPE console} to lazarus.pp ; Then rebuild Lazarus.
+
Please see [[GDB Debugger Tips]]
  
=== Lazarusで使っている色んなファイル拡張子にはどんな意味がありますか? ===
+
=== How can I debug FCL components from packages with Lazarus ===
 +
 
 +
FCL components and classes are built without debug information by default and as a result, gdb cannot access component methods or properties. To build package components they must be rebuilt with a debug-line information "-gl" switch.
 +
 
 +
This example assumes you have a Linux distribution with /usr/local/ installation prefix and that the Database package fcl-db is what is needed to contain debug-line information.  While the fcl-db is used in this example, you may issue this make command from ANY of the included packages.
 +
 
 +
Before you begin, you need to locate your FPC path by examining your FPC configuration file.  The file (fpc.cfg) is located at /etc/fpc.cfg.  Display the contents of fpc.cfg and find your fpc installation path.  Look for a line starting with -Fu in the fpc.cfg:
 +
 
 +
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/*
 +
 
 +
Make scripts are installing units into INSTALL_PATH/lib/fpc/$fpcversion/units/$fpctarget/,
 +
so you must be sure that /usr/local is the installation path, and should be assigned to INSTALL_PREFIX, otherwise the Make scripts will place units where they don't belong or the Make script will fail.
 +
 
 +
'''Step 1''': Open a shell terminal<br>
 +
'''Step 2''': cd /user/local/share/src/fpc-2.3.1/fpc/fcl-db/<br>
 +
'''Step 3''': sudo make clean all install INSTALL_PREFIX=/usr/local OPT=-gl<br>
 +
 
 +
Note: INSTALL_PREFIX parameter should  be properly configured for units to be installed.
 +
In the sample below /usr/local is a default fpc path for Linux, but may vary on other OSes.
 +
 
 +
make clean all install INSTALL_PREFIX=/usr/local OPT=-gl
 +
 
 +
Finally, after rebuilding any FCL units you may want to rebuild LCL as well.
 +
 
 +
=== Problems with GDB on Mac OSX ===
 +
 
 +
[[GDB_Debugger_Tips#Mac_OSX | Please see here for debugger issues under Mac]]
 +
 
 +
 
 +
== Contributing / Making Changes to Lazarus ==
 +
 
 +
=== IDE の、メッセージウィンドとソースエディタウィンドをドッキングできる素敵なパッチを作成したのですが、採用してくれませんか? ===
 +
 
 +
完全なドックマネージャ(ドッキングマネージャ)を作るという目標があるので、ドッキングについてのちょっとしたパッチは、採用されません。
 +
完全なドックマネージャとは、
 +
*すべてのIDEウインドウをドッキングできる。
 +
*ユーザー定義ウインドウをドッキングできる。
 +
*ドッキングレイアウトを保存して、次にロードされたときは再生できる。
 +
*ページとしてもドッキングできる。
 +
*ドラッグドロップを必ずしも必要としない。
 +
 
 +
これらは大変難しいものと思われますが、そうでなければパッチは拒否されます。
  
[[Lazarus Tutorial#The Lazarus files]]で例としていくつかの拡張子について説明しています。
+
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:
ここでは簡潔に示します。
 
  
; <code>*.lpi</code> : Lazarus Project Information ファイル (XML形式; プロジェクト固有の設定情報を持っています)
+
<pre>
; <code>*.lpr</code> : Lazarus Program file; メインのプログラムとなるパスカルのソースです。
+
+-------------------++--+
; <code>*.lfm</code> : Lazarus Form file; フォーム上の全てのオブジェクトの情報を持っています。 (Lazarus固有のフォーマットです。アクションは対応する<code>*.pas</code> ファイル内に記述されます)
+
|menu              ||  |
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code (一般的にフォームは対応する<code>*.lfm</code>ファイルにあります。)
+
+-------------------+|  |
; <code>*.lrs</code> : Lazarus Resource file (これは生成されたファイルです。Windowsのリソースファイルと混同しないでください。).
+
+--++---------------+|  |
: このファイルは、lazres tool (ディレクトリLazarus/Toolsにある)で、コマンドラインを使って生成されます。
+
|PI|| Source Editor ||CE|
   lazres myfile.lrs myfile.lfm
+
+--+|              ||  |
; <code>*.ppu</code> : Compiled unit
+
+--+|              ||  |
; <code>*.lpk</code> : Lazarus package information file. (XML形式; パッケージ固有の設定情報を持っています)
+
|  |+---------------++--+
 +
|OI|+-------------------+
 +
| ||messages          |
 +
+--++-------------------+
 +
</pre>
  
 +
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.
 +
All patches implementing docking without a dock manager makes it harder to implement a real dock manager and will be rejected.
  
; <code>*.lpi</code> : Lazarus Project Information file (stored in XML; contains project-specific settings)
+
As a temporary solution you can use this IDE extension: [[Manual Docker]]
; <code>*.lpr</code> : Lazarus Program file; contains Pascal source of main program
 
; <code>*.lfm</code> : Lazarus Form file; contains configuration information for all objects on a form (stored in a Lazarus-specific format; the actions are described by Pascal source code in a corresponding <code>*.pas</code> file)
 
; <code>*.pas</code> or <code>*.pp</code> : Unit with Pascal code (typically for a form stored in a corresponding <code>*.lfm</code> file)
 
; <code>*.lrs</code> : Lazarus Resource file (this is a generated file; not to be confused with a Windows resource file).
 
: This file can be created with lazres tool (in directory Lazarus/Tools) using commandline: lazres myfile.lrs myfile.lfm
 
; <code>*.ppu</code> : Compiled unit
 
; <code>*.lpk</code> : Lazarus package information file. (stored in XML; contains package-specific settings)
 
  
 
=== lazarusを修正したり、改良しました。どのようにしたら公式Lazarusソースに、自分の変更を加えることができますか? ===
 
=== lazarusを修正したり、改良しました。どのようにしたら公式Lazarusソースに、自分の変更を加えることができますか? ===
  
パッチを作成して、開発者グループに送ってください。詳細は、[[Creating A Patch]]を見てください。
+
パッチを作成して、開発者グループに送ってください。詳細は、[[Creating A Patch/ja]]を見てください。
  
Create a patch and send it to the developers. For details see [[Creating A Patch]].
+
=== どうしたら、lazarusの開発者、SVNのアクセス管理者、バグトラッカーになれますか? ===
 +
 
 +
まず最初に、Lazarusのことを学び、あなたのスキルと知識を証明してください。
 +
[[Lazarus_Documentation|wiki articles]]を読むことからはじめて、ソースコードを読み、 [http://www.lazarus.freepascal.org/mantis Lazarus Bug-Tracker]を見て、いくつかのバグをfixした上で、もし、あなたが充分そうなる資格があると思ったら、[http://www.mail-archive.com/lazarus@miraclec.com メーリングリストの開発者コミュニティ]にコンタクトしてみてください。
  
 
== 定義はどこにありますか? ==
 
== 定義はどこにありますか? ==
Line 320: Line 499:
 
== Linux ==
 
== Linux ==
  
=== How can I debug on Linux without the IDE? ===
+
=== Linux上でIDEから離れてデバッグを行いたいのですが ===
  
First of all you need a debugger. gdb is the standard debugger under linux and
+
まず、デバッガが必要です。GDBはLinuxの標準的デバッガでいくつかのGUIフロントエンドが使用できます。dddはそのなかでも一般的なもので、多くのディストリビューションに採用されています。lazarus/lclをデバッグ情報付きでコンパイルするには次のようにして、更にデバッグを開始して下さい。
there are several GUI-frontends available. One common frontend is ddd, which is
 
part of most common distributions. To compile lazarus/lcl with debug-information
 
you should then use the following commands to start a debug session:
 
  
 
   $ make clean; make OPT=-dDEBUG
 
   $ make clean; make OPT=-dDEBUG
 
   $ ddd lazarus
 
   $ ddd lazarus
  
Be warned however, that ddd is not as comfortable as e.g. the Lazarus debugger.
+
お断りしておきますがdddはlazarusのデバッガより扱いづらいと思います。例を挙げますと、ddd/gdbは大文字小文字の違いにうるさい言語を対象として作られていますが、Pascalはそうではありません。従ってあなたはそれらのコンテンツを見るためには、すべてを大文字でタイプしなければなりません。詳しくはfpcのマニュアルを参照して下さい。
Specially if it comes to view the contents of a variable you have to take into
 
account that ddd/gdb are case sensitive whereas Pascal is case-insensitive.
 
Therefore you have to type all variable names in uppercase to see their
 
contents. For more information take a look into the fpc-manuals.
 
  
=== I can debug now but ddd does not find my sources or complains that they contain no code. Whats that? ===
+
=== デバッグ中なのですが、dddはソースコードが見つからないとか、含まれていないとか言います。どうしたらいいんでしょう ===
  
This is a path-related problem with either gdb or ddd. You can aviod this by
+
それはgdbやdddに対してパスが指定されていないことに起因する問題によるものです。解決できる問題です。
  
* 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.
+
*dddのメニューから "Change directory"コマンドを使ってソースコードが存在するディレクトリを指定してください。しかしこの方法ではプログラムを開始したディレクトリを使用することができません。あなたは複数回ディレクトリを指定し直す必要があるかもしれません。
* In ddd goto [Edit] [gdb-settings] and set the search-path
+
 
* Create a $(HOME)/.gdbinit file like:
+
* dddのEditメニューからgdb-settingsをたどって、検索パスを追加して下さい。
 +
* $(HOME)/.gdbinitに次のようなテキストファイルを作って下さい。あるいは追加してやって下さい:
 
       directory /your/path/to/lazarus
 
       directory /your/path/to/lazarus
 
       directory /your/path/to/lazarus/lcl
 
       directory /your/path/to/lazarus/lcl
 
       directory /your/path/to/lazarus/lcl/include
 
       directory /your/path/to/lazarus/lcl/include
 +
::(訳注:ホームディレクトリ直下に.gdbinitというファイルを作ってくれ、という意味です。これは不可視属性になりますのでls -Aしないと見られなくなります--[[User:Tooka]])
 +
=== リンク中に/usr/bin/ld can't find -l<hogehoge>というエラーが出ます ===
 +
; '''パッケージベースのディストリビューションの場合(大抵はこれ)''':hogehoge.soとかhogehoge.aという名前のファイルを含むパッケージをインストールして下さい。Linuxにおいてダイナミックリンクライブラリは.so、スタティックリンクライブラリは.aの拡張子を持つことになります。Linuxディストリビューションによってはすでにパッケージの名前がhogehogeのものがインストールされているかもしれません。しかし、そのときは開発用パッケージが必要なのかもしれません。hogehoge-devのインストールをしてみましょう。そのなかにhogehoge.aやhogehoge.soがある、ということはよくあることです。
  
=== I receive an error during the linking that states /usr/bin/ld can't find -l<some lib> ===
+
; '''ソースコードベースのディストリビューションや自分で設定したシステムの場合(LFS)''' : hogehoge.aをmakeしてパスの通ったディレクトリにおいて下さい。必要ならば、hogehoge-version.so(.a)へのシンボリックリンクをhogehoge.so(.a)に作成しておきましょう.
  
; '''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).
+
; '''FreeBSD''' : これはソースコードベースのディストリビューションと同じく、makeしてやって-Fl/use/local/libをfpc.cfgに追加するか、追加して更にLazarusライブラリパスに配置します。 GTK1.2には「FreeBSDのパッケージ名としてのgtk12」があるのを覚えておいてください。 (glibと同じように)
  
; '''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).
+
; '''NetBSD''' : これはソースコードベースのディストリビューションと同じく、makeしてやって-Fl/use/local/libをfpc.cfgに追加するか、追加して更にLazarusライブラリパスに配置します。
  
; '''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)
+
=== どうやってKylix2のプロジェクトをLazarusに変換して取り込めばいいでしょう ===
  
; '''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
+
Kylixのプロジェクトの変換はDelphi/VCLプロジェクトの変換に似ています。
  
=== How can I convert a kylix 2 project into a lazarus project? ===
+
LCL(Lazarus Component Library)はDelphiのVCLと互換性を持つように作られています。
 +
KylixのCLXはQTと互換性を持つように作られています。
 +
一般的なヒントを以下に記します:
  
Nearly the same way as converting a Kylix project into a Delphi/VCL project.
+
*すべてのCLXが使うQ-ユニット——QForms,QControls,QGraphicsとか——をVCL風に変更してください。Forms,Control,Graphicsのように。
 
+
*Formを使うソースコードのusesセクションにLResourcesを追加してください。
The LCL (Lazarus Component Library) tries to be compatible to Delphis VCL.
+
*すべての.xfmファイルをコピーするかリネームして拡張子を.lfmにしてください。
Kylix CLX tries to be QT compatible.
+
*すべての.dprファイルをコピーするかリネームして拡張子を.lprにしてください、
Here are some general hints:
+
*.lprファイルのinterfaceセクションに、Interfacesを追加してください。
 
+
*{$R *.res}という記述を削除してください。
* Rename all used CLX Q-units like QForms, QControls, QGraphics, ... into their VCL counterparts: Forms, Controls, Graphics, ...
+
*{$R *.xfm}という記述を削除してください。
* Add LResources to the uses section of every form source
+
*.pasファイルと.lprファイルに{$mode objfpc}{$H+}{$mode delphi}{$H+}という記述を追加してください。
* Rename or copy all .xfm files to .lfm files.
 
* Rename or copy .dpr file to .lpr file.
 
* Add "Interfaces" to the uses section in the .lpr file.
 
* Remove {$R *.res} directive
 
* Remove {$R *.xfm} directive
 
* Add {$mode objfpc}{$H+} or {$mode delphi}{$H+} directive to .pas and .lpr files
 
 
* Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):
 
* Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):
 
   initialization
 
   initialization
Line 381: Line 553:
 
* Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.
 
* Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.
  
=== When compiling lazarus the compiler can not find a unit. e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB ===
+
=== lazarusをコンパイルしているとき、コンパイラがユニットを見つけられません。e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB ===
  
1. Check a clean rebuild: do a 'make clean all'
+
1. 完全にクリーンな状態してください: 'make clean all' を実行します
  
2. Check if the compiler has the correct version (2.0.0 or higher)
+
2. コンパイラのバージョンを確認してください(2.0.0 以上)
  
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.
+
3. コンパイラが正しい設定ファイルを使用しているか確認してください。通常は /etc/fpc.cfg にインストールされます。しかし、fpc は ~/.ppc386.cfg や、~/.fpc.cfg、/etc/ppc386.cfg といったファイルを調べ、最初に見つけたものだけを使用します。
 +
(~ はホームディレクトリを指します)
  
:'''Hint:''' You can see which config file is used with 'ppc386 -vt bogus'
+
:'''ヒント:''' 'ppc386 -vt bogus'とすることでコンフィグファイルを探すことが出来ます。
:Remove any ppc386.cfg as it is really obsolete.
+
:複数の ppc386.cfg を使用するのは古い方法ですので削除して下さい。
  
4. Check if the config file (/etc/fpc.cfg) contains the right paths to your fpc libs. There must be three lines like this:
+
4. コンフィグファイル(/etc/fpc.cfg)の中で fpc のライブラリのパスが正しく設定されているか確認して下さい。fpc のライブラリパスの設定は次のように行います。
 
     -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
 
     -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
 
     -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
 
     -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
 
     -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
 
     -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
: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/... .
+
:最初の部分のパス(/usr/lib/fpc)は、あなたの環境に適合させて下さい。システムによっては、/usr/local/lib/fpc/...とった指定の仕方をする場合もあります。
:'''Hint:''' You can see your searchpaths with 'ppc386 -vt bogus'
+
:'''ヒント:''' コマンドラインから'ppc386 -vt bogus'とすることでサーチパスを確認することが出来ます。
  
5. Check that the config file (/etc/fpc.cfg) does not contain search paths to the lcl source files (.pp, .pas):
+
5. コンフィグファイル(/etc/fpc.cfg)の中で LCL のソースファイル(.pp、.pas)が正しく設定されているか確認して下さい:
 
   forbidden: -Fu(lazarus_source_directory)/lcl
 
   forbidden: -Fu(lazarus_source_directory)/lcl
 
   forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk
 
   forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk
: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:
+
:もしあなたの fpc プロジェクトに LCL を付け加えたいなら、上述のfpc のライブラリのパスの後に、次の二つのパスを設置します。:
 
   -Fu(lazarus_source_directory)/lcl/units/$fpctarget
 
   -Fu(lazarus_source_directory)/lcl/units/$fpctarget
 
   -Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk
 
   -Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk
  
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/$version/units/i386-linux/gtk/. If it does not exists, the fpc lib is corrupt and should be reinstalled.
+
6. 見つからないユニット(glib.ppu)fpc ライブラリのディレクトリに存在しているか確認して下さい。例えば、gtk.ppu /usr/lib/fpc/$version/units/i386-linux/gtk/ の中に見つけることができます。もしこれらが存在していないならば、fpc ライブラリは正常ではないので、再インストールして下さい。
  
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.
+
7. ソースファイルが NFS でマウントされたディレクトリに置かれていないか確認して下さい。あるケースでは、NFS が作成したファイルを不正に更新していました。ソースを NFS ではないディレクトリに移動させて、コンパイルをして下さい。
  
 
=== I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS ===
 
=== I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS ===
Line 425: Line 598:
 
Environment->General Options->Files->Lazarus Directory Top
 
Environment->General Options->Files->Lazarus Directory Top
  
===Lazarus compiles, but linking fails with: libgdk-pixbuf not found===
+
===Lazarusのコンパイルをして、リンク中にこんなことを言われます: libgdk-pixbuf not found===
Either install the gdk-pixbuf library for gtk1.x or disable the use:
+
gdk-pixbufライブラリ(gkt1.x)をインストールするか使用しないようにします。
  
Where to find the gdk-pixbuf library:
+
gdk-pixbufライブラリはこちらにあります:
  
 
RPMs:
 
RPMs:
 
http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=
 
http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=
  
Debian packages:
+
Debianパッケージ:
 
libgdk-pixbuf-dev
 
libgdk-pixbuf-dev
  
Sources:
+
ソースコード:
 
ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/
 
ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/
  
 
+
Lazarusでしないように設定するには:"ツール"→"Lazarusのビルド設定"にオプションを追加します。
How to disable the use in lazarus: In Tools->Configure "Build Lazarus" add the option
 
 
'-dNoGdkPixBufLib'
 
'-dNoGdkPixBufLib'
or at command line:
+
もしくはコマンドラインで次のようにしてください。
 
"make clean all OPT=-dNoGdkPixBufLib".
 
"make clean all OPT=-dNoGdkPixBufLib".
  
===I have SuSE and I get /usr/bin/ld: cannot find -lgtk Error: Error while linking===
+
===SuSEを使っていますが、リンク時に/usr/bin/ld が Cannot find -lgtk Error というエラーを返します===
SuSE installs the gtk devel libs under /opt/gnome/lib (or /opt/gnome/lib64 for 64 bits), which is not in
+
 
the standard lib path. Simply add it to your /etc/fpc.cfg.
+
SuSE gtk の開発用ライブラリを /opt/gnome/lib (64bits 版の場合は /opt/gnome/lib64)にインストールします。このパスは標準的なものではありません。シンプルな解決方法は、/etc/fpc.cfg にこのパスを追加することです。
 
(-Fl/opt/gnome/lib).
 
(-Fl/opt/gnome/lib).
  
Line 471: Line 643:
 
''Hint:'' Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.
 
''Hint:'' Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.
  
===When I run a program with threads I get runtime error 232===
+
=== スレッドを含むプログラムを実行するとランタイムエラー232で終了する ===
The complete error message is:
+
 
 +
正確なエラーメッセージは:
 
  This binary has no thread support compiled in.
 
  This binary has no thread support compiled in.
 
  Recompile the application with a thread-driver in the program uses
 
  Recompile the application with a thread-driver in the program uses
 
  clause before other units using thread.
 
  clause before other units using thread.
 
  Runtime error 232
 
  Runtime error 232
'''Solution''': Add cthreads as first unit to the uses clause of your main program, usually the .lpr-file.
+
'''解決方法''':  
 +
メインプログラム(通常は .lpr ファイルです)の uses 節の先頭に cthreads を追加して下さい。
  
===I have Ubuntu Breezy and my fonts in Lazarus IDE look too big===
+
===Ubuntu 6.06でIDEのフォントが文字化けするのですが===
If Lazarus is compiled with Gtk1.2, the settings in Gnome Preferences/Font don't have any effect as
+
LazarusがGtk1.2でコンパイルされた場合、Gtk2のためのGnome設定/フォントは無効です。
they are related to Gtk2.
+
この場合、次のように対処してみてください:
You could try this solution:
+
(もしまだなければ).gtkrc.mineというファイルをホームディレクトリに作成します。その中に以下の行を納入してください。
Create a file named .gtkrc.mine in your home directory (if it's not already there) and add
 
these lines to it:
 
  
 
<pre>
 
<pre>
 
style "default-text" {
 
style "default-text" {
       fontset = "-*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\
+
       fontset = "-ipa-uigothic-medium-r-normal-*-*-120-*-*-*-*-jisx0212.1990-0,
 +
                  -*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\
 
                   -*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
 
                   -*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
 
}
 
}
Line 494: Line 667:
 
class "GtkWidget" style "default-text"
 
class "GtkWidget" style "default-text"
 
</pre>
 
</pre>
 +
ここで120というのはフォントサイズ(12になる)です。適当に調整してください。
  
===I have Ubuntu and I cannot compile for Gtk2 due to missing libraries===
+
===Ubuntuを使っています。ライブラリが見つからないために Gtk2 プログラムがコンパイルできません===
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:
+
 
 +
Ubuntu には、インストールしたライブラリをリンク可能にするためのシンボリックリンクが、全てのライブラリで作成されるわけではないという問題があります。Gtk2 をリンクしようとした際に見つからないと指摘されたライブラリに、適切なシンボリックリンクがあるかどうか確認してください。例えば次のような方法があります:
  
 
<pre>
 
<pre>
Line 503: Line 678:
 
</pre>
 
</pre>
  
Make sure that the [whatever].so symbolic links are created and point to the actual libraries.
+
実際のライブラリ(上の例では libgdk-x11-2.0.so.0)に対し、[ライブラリ名].so (上の例では libgdk-x11-2.0.so)というリンク可能なシンボリックリンクが作られます。
  
===How can I compile a program for Gtk2?===
+
===どうすればGtk2プログラムをコンパイルすることが出来ますか?===
  
At the moment, the Gtk2 compiled IDE is a little unstable, but you can compile software for Gtk2 using the Gtk1 IDE.
+
今のところ、Gtk2 版 IDE は少し不安定(little unstable)です。ですが、Gtk1 版 IDE を使って Gtk2 のソフトウェアをコンパイルすることは可能です。
  
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.
+
Gtk2 用の LCL でリコンパイルするには、メニューの“Tools”->“Configure Build Lazarus”から、LCL を clean+build に、everything else none にセットします。
  
Now click Ok and go to the menu "Tools"->"Build Lazarus"
+
Ok ボタンをクリックし、“Tools”->“Build Lazarus”を選択します。
  
Now you can compile your software with Gtk2 going on the Compiler options and changing the widgetset to Gtk2.
+
続いてコンパイラオプションに進み、Gtk2 用のウィジェットセットに変更することで、Gtk2 のソフトウェアをコンパイルできるようになります。
  
 
== Windows ==
 
== Windows ==
  
=== 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. ===
+
=== コンパイラを使っているときに、"The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time." というメッセージが出ることがあります。===
  
In the compiler dir exists an OS2 scriptfile named make.cmd. NT sees this also
+
コンパイラディレクトリに make.cmdというOS2用のscriptfileが存在しています。Windows-NTでは、それは必要ないのですが、NTがスクリプトファイルとみなしますので、取り除いてください。
as a script file, so remove it since on NT we don't need it.
 
  
=== When I cycle the compiler, I get: make[3]: ./ppc1.exe: Command not found ===
+
=== コンパイルしているときに、"make[3]: ./ppc1.exe: Command not found"というメッセージが出ます。 ===
  
I don't know why but somehow make has lost its path. Try to cycle with a
+
どういう訳か、makeコマンドがパスを消失しています。basedirを次のようにセットしてください。
basedir set like: make cycle BASEDIR=your_fpc_source_dir_herecompiler
+
: make cycle BASEDIR=your_fpc_source_dir_herecompiler
  
=== When I try to make Lazarus I get:===
+
=== Lazarusをコンパイルしているときに受け取るメッセージ ===
 
====make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2 ====
 
====make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2 ====
You need to upgrade your make.
+
 
 +
makeファイルを更新する必要があります。
  
 
====makefile:27: *** You need the GNU utils package to use this Makefile.  Stop.====
 
====makefile:27: *** You need the GNU utils package to use this Makefile.  Stop.====
Make sure you didn't install FPC in a path with spaces in the name. The
 
Makefile doesn't support it.
 
 
  
 +
スペースがはいっているパスにFPCをインストールしていないかどうか、確認してください。スペースがはいっているパスを、Makefileはサポートしません。
  
 
===どうしたらlazarusのように、自分が作ったプログラムをXP風の見栄えにできますか?===
 
===どうしたらlazarusのように、自分が作ったプログラムをXP風の見栄えにできますか?===
Line 565: Line 738:
 
LazarusIDEの場合は、Project menu -> Compiler Options -> Linking -> target OS Specific optionsで、コンパイラオプションダイアログでWindows GUIをチェックしてください。
 
LazarusIDEの場合は、Project menu -> Compiler Options -> Linking -> target OS Specific optionsで、コンパイラオプションダイアログでWindows GUIをチェックしてください。
  
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.
+
== Mac OS X ==
 +
 
 +
=== Why does compiling a project fail with 'unknown section attribute: no_dead_strip'?===
 +
 
 +
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
 +
 
 +
*Code > Unit style > Smart linkable (-CX)
 +
*and Linking > Link Style > Link smart (-XX)
 +
 
 +
== Licensing ==
 +
 
 +
=== Can I make commercial applications with Lazarus ? ===
 +
 
 +
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.
 +
 
 +
=== Why are some components restricted from usage in commercial application ? ===
 +
 
 +
Lazarus comes with additional components, that were developed by third parties. Those are under various other Licenses. If you wish to use them you need to see the License within the source files of those packages.
 +
Most of those 3rd party components are in the directory "components".
 +
 
 +
=== How do I know if a Component is part of the LCL ? ===
 +
 
 +
All LCL units are in the directory "lcl". A List of units belonging to the LCL can be found here http://lazarus-ccr.sourceforge.net/docs/lcl/ . If you code uses units not listed on this page, you may have used a component that is not part of the LCL.
 +
 
 +
=== Can I make commercial plug-ins for Lazarus ? ===
 +
 
 +
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.
  
 
== Contributors and Comments ==
 
== Contributors and Comments ==
  
 
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq version].
 
This page has been converted from the epikwiki [http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq version].
 +
 +
 +
{{AutoCategory}}
 +
[[Category:Lazarus/ja]]
 +
[[Category:FAQs/ja]]

Latest revision as of 19:52, 6 June 2015

العربية (ar) Deutsch (de) English (en) español (es) français (fr) magyar (hu) italiano (it) 日本語 (ja) 한국어 (ko) português (pt) русский (ru) slovenčina (sk) 中文(中国大陆)‎ (zh_CN) 中文(台灣)‎ (zh_TW)

日本語版メニュー
メインページ - Lazarus Documentation日本語版 - 翻訳ノート - 日本語障害情報


一般的なこと

どうしてコンパイル後のバイナリがこんなに大きいの?

バイナリが大きくなる理由は、GDB(GNU Debugger)で利用するデバッグ情報を含んでいるためです。


実行ファイルからデバッグ情報を除去するオプション(-Xs)がありますが、 バージョン2.0.2以前のコンパイラではバグのため正しく動きません。バージョン2.0.4以降のコンパイラでは修正されています。

"strip" というプログラムでデバッグ情報を除去することもできます。 これは、Lazarusディレクトリの下のlazarus\pp\bin\i386-win32\ にあります。

コマンドラインから、 "strip --strip-all <実行ファイルへのパス>" とタイプすることでデバッグ情報を除去できます。

さらにプログラムを小さくしたい場合は、実行ファイルの圧縮ツール UPX(upx.exe) も利用できます。 これは、"strip" と同じく、Lazarusディレクトリの下の、lazarus\pp\bin\i386-win32\ にあります。 圧縮を復元するためのメモリのオーバーヘッドはありませんし、復元速度も Pentium 133 で ~10MB/sec 程度と大変高速です。

コマンドラインから、"upx <実行ファイルへのパス>" とタイプすることで、"upx" を利用できます。

"strip" と "upx" を簡単な Lazarus の GUI プログラムに適用すると、Linux で 700kb 程度、 Windows で 420kb 程度のサイズに収まるでしょう。

UPXの欠点などの詳細は、サイズについてにあります。

また、重要なことですが、一般的な hello world すら lazarus で作成すると、以下のような大量の機能が含まれてしまいます。

  • XML 利用ライブラリ
  • 画像利用ライブラリ(png, xpm, bmp, ico ファイルなど)
  • Lazarus Component Library(LCL) のほとんどすべてのウイジェット
  • すべての Free Pascal Runtime Library(RTL)

このためにとても大きなサイズになりますが、実用アプリケーションで必要とされる機能をすでに含んでいるともいえます。

Lazarus の実行ファイルのサイズは最初から大きいですが、ソースコードやフォームが増えても、少しづつしか増えません。 C++や他の言語では、hello world などはとても小さいかもしれませんが、実用的なアプリケーションを書くようになると急激にサイズが増加するでしょう。

Lazarus vs cpp.png


Lazarus/FPC アプリケーションのサイズを縮小するための簡単なガイド (Lazarus 0.9.26 で確認)

  • 1. プロジェクト|コンパイラオプション|コード|スマートリンク可能な(-CX) -> チェックする。
  • 2. プロジェクト|コンパイラオプション|リンク|デバッグ中|実行ファイルからシンボルを除く(-Xs) -> チェックする。
  • 3. プロジェクト|コンパイラオプション|リンク|リンクスタイル|スマートリンク(-XX) -> チェックする。

特に 2. が重要と思われます。 単純なアプリケーションは、いままでの 15-20 MB から 1-3 MB になります。 以下を試すのもよいでしょう: プロジェクト|コンパイラオプション|コード|最適化|速度より最小化を優先(-Os) -> チェックする。 (実行速度が低下することに注意)

  • 4. "UPX <実行ファイルのパス>" によって 1/2~1/3 に圧縮されます。 (注意: サイズについてにもあるように、UPX利用の欠点もあります。)

Chart of default sizes for an empty Application with various settings and operating systems

Well I ran tests I did on Lazarus 0.9.29 with FPC 2.4 (FPC 2.2.4 with Windows). Optimized compiler mean using the advices above but without using UPX. Default Lazarus means as installed from package/setup. LCL without debug informations mean after rebuilding Lazarus IDE and LCL without debug informations (-g-).

    Default Lazarus     LCL without debug informations
Ubuntu 64 bits / Lazarus 64 bits
Default application     13,4  Mb     7,5 Mb / 8
Optimized compiler     4,4 Mb     2,70 Mb (0.29svn FPC2.4 2,5)
   
Ubuntu 32 bits / Lazarus 32 bits
Default application     19,6  Mb     5,7 Mb
Optimized compiler     2,9 Mb     1,6 Mb
   
Windows XP 32 bits / Lazarus 32 bits
Default application     11,8 Mb     2,14 Mb
Optimized compiler     1,62 Mb     1,50 Mb
   
Windows Seven 64 bits / Lazarus 64 bits
Default application     12,3  Mb     3,20 Mb
Optimized compiler     2,14 Mb     2,16 Mb

'Fatal: Circular unit reference between a and b'(ユニットの循環的参照)エラーの回避

新規ユーザーが、2つのフォーム(TForm)で相互にプロパティを参照し合いたい場合などに陥りやすいエラーです。このエラーは、「uses」を「interface」セクションで宣言しているためにおこり、「uses」を「implementation」に移すことで解消できます。

エラーとなる例:

 unit a;
 
 interface
 
 uses b;
 
 implementation
 
 end.
 ...
 unit b;
 
 interface
 
 uses a;
 
 implementation
 
 end.

エラーとならない例:

 unit a;
 
 interface
 
 implementation
 
 uses b;
 
 end.
 ...
 unit b;
 
 interface
 
 implementation
 
 uses a;
 
 end.

どうしてリンクがWindowsでは遅いのでしょうか?

この問題は、 FPC2.2 以降かつ Lazarus 0.9.24 以降で解決されています。 Lazarus を更新してみてください。 古いバージョンについては以下を参照してください。

一般的に、Windows でのリンクは他のプラットホームより時間がかかります。 これは、Free Pascal で利用している GNU リンカの動作が Windows で遅いためです。 この問題は Windows のみに影響し、比較的古くメモリの少ないコンピュータ (1GHz以下、128MB以下)で顕著に現れます。

また、LCL をスマートリンクしている場合、リンク作業はさらに遅くなります。 この問題についての調査はファイルサイズとスマートリンクにあります。

内部リンカはすでに開発されていますが、 FreePascal 2.2 以上でないと利用できません。これは、リンク時間を劇的に短くします。

注意: 2.1.1 では、Windows は win32/64/ce のために内部リンカを利用します。 これは作業を少し早めるでしょう。 Lazarus は 再コンパイルを行い、280MB ほどを使います。


ppc386.cfg や fpc.cfgは必要でしょうか?

fpc.cfgのみ必要です。 コンパイラがライブラリを見つけるための方法が書いてあります。


どうしたらLazarusをコンパイルできますか?

たとえば次のようにしてください。

$ cd lazarus
$ make clean all


どのようにしたら、LCLをベースとした他のプロジェクトをビルドできますか?

アプリケーション作成に IDE を使えない場合、lazbuild を利用してください。 これはコマンドライン版の Lazarus プロジェクトのビルド環境です。 IDE も lazbuild も使えない場合、fpc.cfg の最後に次の行を追加してください。

  # 他のツールキットの探索パス (Linux)
  -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{ツールキット}
  # 他のツールキットの探索パス (Windows)
 -Fu/{YourLazarusDirectory}/components/units/{ツールキット}
{ツールキット} には、gtk2gnomeqtwin32 などを入れ、下記を実行してください。
ppc386 your.project.pp

ヒント: ツールキットの開発パッケージのインストールを忘れないでください。 こんなメッセージを受け取るかもしれません。: Linker message: cannot find -l.


どのバージョンの FPC(FreePascalCompiler) が必要ですか?

FPC Version 2.2.2 が全オペレーティングシステムに対する推奨バージョンです。


Lazarusのコンパイルができません。

  1. コンパイラは正しいバージョンですか?
  2. fpcのライブラリは同じバージョンですか?
  3. コンパイラのインストールパスはスペースを含まないように!
  4. fpc.cfg はありますか? 古い ppc386.cfg はあったらだめですよ。
  5. OS 依存についての FAQ も確認してください。


プロジェクトをコンパイルしようとするとエラーがでます

"Cannot find Unit interfaces". これはどうしたら解決できますか?

これは、コンパイラが interfaces.ppu を見つけられなかったり、 見つけたが それがおかしなファイルであるときに表示されます。

このユニットは、 {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu にあります。 (例えば、/home/username/lazarus/lcl/units/i386-linux/gtk/interfaces.ppu)。

他の場所などに色々なバージョンの interfaces.ppu がある場合、間違った構成になっている(例えば、検索パスに lcl のディレクトリを追加していたり)可能性が高いため、全ての interfaces.ppu を削除して、上記のディレクトリの interfaces.ppu だけにしてください。

また、Lazarus をビルドするのに用いた widgetset と異なる widgetset を選択した場合、その widgetset 用に LCL をビルドする必要があります。

上記の確認後にもこのエラーが発生する場合、 あなたが Lazarus IDE をコンパイルするのに用いたコンパイラやrtlと異なるコンパイラやrtlを用いてプロジェクトをコンパイルしていると考えられます。 以下を試してください。

  • LCL (もしくは、Lazarus丸ごと) を 環境 -> オプション で選択しているコンパイラでリビルドしてください。 リビルドは、 ツール -> Lazarusを構築 で行えます。 構築前に、 ツール -> "Lazarus構築"を設定 で、現在の設定を確認してください。
  • 環境 -> オプション で、コンパイラを Lazarus をコンパイルしたものに変更してください。 また、環境 -> オプション で Lazarusディレクトリ や FPCソースディレクトリ へのパスが正しいかどうか確認してください。 さらに、コンパイラ構成ファイルである fpc.cfg が1つのバージョンのものだけがあるかどうか確認してください。 Linux/Unixシステムでは、/etc/ に、 Windows システムでは、fpcコンパイラと同じディレクトリにあるはずです。 "fpc -vt bogus" を実行し、どの fpc.cfg を利用しているかを確認してください。 コンパイラをアップデートした場合に、しばしば古いコピーがこっそり残ります。 ユーザーのホームディレクトリや新しいコンパイラをビルドしたディレクトリなどを確認して、これらを消去してください。
  • また、プロジェクトに利用しているウィジェットのセットを変更しても良いかもしれません。 例えば、Lazarus のサンプルフォルダにある "objectinspector" は、 gtk でコンパイルされています。 このプロジェクトを windows 上でコンパイルすると "Can't find unit interfaces" メッセージが表示されるでしょう。 ウィジェットセットを プロジェクト|コンパイラオプション...|LCLウィジェットタイプ(様々) から デフォルト(Win32) に変更することで問題が解決されます。

Delphi プロジェクトを lazarus でコンパイルしようとしたらエラーがでました

{$R *.DFM}という行について: これはどのように解決できますか?

Lazarus (Linux という方が分かりやすい) はリソースを解釈できませんので、Delphi/Win32 でしていたような方法をとることはできません。しかしながら、Lazarus はこれと似たようなシンプルな代替方法が使用できます。次の手順を使えば、 Delphi レイアウト(.dfm ファイル)を使用できます:

  • オリジナルの .dfm ファイルが必要です。 Delphi5 以降はこれがデフォルトに成っています。もし古いバージョンを使っているのなら: ALT + F12 でテキストでレイアウトを参照して、コピー&ペーストすることができます。テキストの .dfm ファイルが得られたら、.lfm ファイルにコピーして下さい。
  • (lazarus/tools の)lazres を使ってファイルを作成します。
     lazres yourform.lrs yourform.lfm
  • イニシャライズセクションに次の行を付け加えます
     initialization
     {$I yourform.lrs}

lazarus では dfm ファイル内の全てのプロパティがサポートされているわけではないことを心にとどめておいて下さい。クラッシュする場合もあります。

'Identifier not found LazarusResources'というエラーが発生します。

フォームを作成しているとき、Lazarusは自動的に他のユニットをフォームユニットのusesセクションに追加します。しかし、DelphiのユニットをLazarusのユニットに変換したときは、これは起こりません。 ですから、その場合LResourcesをフォームのユニットのUsesセクションに、追加する必要があります。

オブジェクトのイベントにアクセスする時、たとえば、ボタンのolclickイベントなどで、次のようなエラーが出ます。 ERROR unit not found: stdCtrls

Project -> Project Inspectorで、プロジェクトが'LCL'パッケージに依存していることを確かめてください。そして、FPCソースをインストールしていることを確かめてください。

LazarusはIDEであり、LCLというビジュアルコンポーネントライブラリです。その他のIO,Database,FCL,RTLといったものは、FPCから提供されます。IDEは全てのソースへのパスを必要とします。

FPCのソースパスは、次のように設定できます。 Environment -> General Options -> Files -> FPC source path

別のファイルなしで、実行ファイルだけにできますか?どうしたらリソースを埋め込むことができますか?

例えば、次のようにしてください:

/your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...

これは、sound1.wavとsound2.wabから、sound.lrs(訳注:というLazarusのリソースファイル)を生成します。

そして、これをlrsフォームにこっそりインクルードします。

...
initialization
{$i unit1.lrs} // 必ず最初にメインのリソースファイルを指定します。
{$i sound.lrs} // ユーザー定義のリソースファイル

end.

プログラムで、これらのファイルを使うことが出来ます。

Sound1AsString:=LazarusResources.Find('sound1').Value;

(訳注:とりあえずバイナリファイルをStringとして取り出すことができる あとは、これをファイルに書き出して読み込むか、ストリームとして流し込むか、など)


Lazarusで使っている色んなファイル拡張子にはどんな意味がありますか?

Lazarus Tutorial/ja#The Lazarus filesで例としていくつかの拡張子について説明しています。 ここでは簡潔に示します。

*.lpi
Lazarus Project Information ファイル (XML形式; プロジェクト固有の設定情報を持っています)
*.lpr
Lazarus Program file; メインのプログラムとなるパスカルのソースです。
*.lfm
Lazarus Form file; フォーム上の全てのオブジェクトの情報を持っています。 (Lazarus固有のフォーマットです。アクションは対応する*.pas ファイル内に記述されます)
*.pas or *.pp
Unit with Pascal code; Pascal で書かれたユニット (一般的にフォームは対応する*.lfmファイルにあります。)
*.lrs
Lazarus Resource file; リソースファイル (これは生成されたファイルです。Windowsのリソースファイルと混同しないでください。). (訳注: フォームの要素などを定義したファイルです。)
このファイルは、lazres tool (ディレクトリLazarus/Toolsにある)で、コマンドラインを使って生成されます。
 lazres myfile.lrs myfile.lfm
*.ppu
Compiled unit; コンパイルされたユニット
*.lpk
Lazarus package information file. (XML形式; パッケージ固有の設定情報を持っています)

テキストファイル型変数を var mytext: text; と宣言すると "Error: Error in type definition" と言われる。どうすればいいの?

TControl クラスが Text プロパティを持っているからです。フォームのメソッドの中では、system ユニット(訳注: 暗黙のうちに uses される、Free Pascalのランタイムライブラリ)にある Textよりもこちらが先に見えてしまいます。テキストファイル型に対するいいかえであるTextFile 型を使うか、ユニット名を明示して型宣言を行います。

var
  MyTextFile: TextFile;
  MyText: System.Text;

同様の問題がファイル名の登録とテキストファイルのクローズの際に起こります。TForm が assign メソッドと Close メソッドを持っているからです。 AssignFile 及び CloseFile を用いるか、手続き名に system を付けて下さい(訳注: system.assign, system.close とする)

Printer.BeginDoc がエラーを起こす

Printers ユニットを uses 節に含める必要があります。

Printer4Lazarus パッケージをプロジェクトが必要とするものの中に含める必要があります。これはIDEから次のようにします: Project|Project Inspector|Add|New Requirement|Package Name:

ドロップダウンボックスの中に Printer4Lazarus パッケージがなければ、インストールしなければなりません。このパッケージは、Lazarusをインストールした時に次のディレクトリに置かれています: [lazarus installed directory]\components\printers

[lazarus installed directory] はデフォルトでは以下のの通りです:

  • Windows: c:\lazarus
  • Linux: /usr/lib/lazarus
Printer.Printers を参照すると例外が発生する場合も同様にしてください。

TForm.ClientWidth/ClientHeightがTForm.Width/Heightと同じ値になるのはなぜ?

LCLではTForm.Width/Heightはフレームを含まないので、同じになります。なぜなら、すべてのプラットホームでフレームのサイズを取得する方法がないからです。 (特定のOS上などに限定するなどして)信頼できる方法でなくてもよければ、LCLは(フレームを含まない指定値によって)フォームをスクリーン上で移動やリサイズすることができます。

一方、すべてのプラットホームで、フレーム込みのウインドウサイズについては取得することができ、変更することもできます。

過去のLCLフォームとの互換性を保つために特殊なバージョンの定数といくつかの拡張メソッドが追加されるでしょう。


Debugger

どうしたらデバッグ出力を見る事ができますか?

LCLにはデバッグ出力に書くためのLCLProc手続きがあります。

  • DebugLn: は引数に1つの文字列しか受け取れませんが、WriteLnと同じように動作します。* DbgOut: は引数に1つの文字列しか受け取れませんが、Writeと同じように動作します。

(*訳注:PascalではWrite,WriteLnは可変引数を取る稀有な関数である。)

普通の環境では、出力はstdoutに対して行われます。しかし、stdoutが閉じている場合(たとえば、{$AppType Gui}のアプリケーションであったり、Windowsで -WGオプションが指定されてコンパイルされている場合など)、出力されません。

デバッグ出力は、そのような時でもファイルに出力されます。LCLProcユニットはinitialization部で、'--debug-log=<file>'というコマンドラインパラメータをチェックします。もし、これがあれば、デバッグ出力を<file>にします。

この--debug-logコマンドラインパラメータがない場合、環境変数 xxx_debuglogが存在するかどうか確認します。xxxは、拡張子のないプログラムファイル名です。lazarusの場合は、lazarus_debuglogです。もし、このような環境変数がある場合、デバッグ出力のためのファイルを使います。たとえば、

 set lazarus_debuglog=c:\lazarus\debug.txt

としたとしましょう。 デバッグ出力は、c:\lazarus\debug.txtに行われます。

この実装は、lclproc内で行われ、全てのアプリケーションはlclprocを使うため、この出力手法を使うことができます。 Lazarusをデバッグする場合 : Windowsでもっとも効果的な方法です。もし、出力をコンソールに出したい場合、lazarus.ppに{$APPTYPE console}を加えてください。そして、Lazarusをリビルドしてください。

How Can I inspect properties?

You have to use the latest FPC from trunk (2.5.1) or 2.4 once it is released.

If you compile your application using -gw (dwarf debug info), you should be able to inspect properties.

Note this is only true for properties that map directly to a variable (the "read" declaration points to a member, not a function).

If your property returns the value of a function it is very dangerous to evaluate/inspect it. It would require this function to be called, and very often it would change the values of some of your variables. This would mean it would alter the state of your application in the debugger, and any further code-execution, debugging or inspections would return incorrect results.

The optional ability to explicitly inspect the results of functions (with the risks described) , and therefore calling code from the debugger is not yet implemented

Why does the debugger not show some Variables/Structures ("no such symbol"/"incomplete type")

For problems debugging: - properties
- Array of ... (Dynamic Array)
- Variables in Nested Procedures
- "no such symbol in context"
- "incomplete type"

Please see GDB Debugger Tips

How can I debug FCL components from packages with Lazarus

FCL components and classes are built without debug information by default and as a result, gdb cannot access component methods or properties. To build package components they must be rebuilt with a debug-line information "-gl" switch.

This example assumes you have a Linux distribution with /usr/local/ installation prefix and that the Database package fcl-db is what is needed to contain debug-line information. While the fcl-db is used in this example, you may issue this make command from ANY of the included packages.

Before you begin, you need to locate your FPC path by examining your FPC configuration file. The file (fpc.cfg) is located at /etc/fpc.cfg. Display the contents of fpc.cfg and find your fpc installation path. Look for a line starting with -Fu in the fpc.cfg:

-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/*

Make scripts are installing units into INSTALL_PATH/lib/fpc/$fpcversion/units/$fpctarget/, so you must be sure that /usr/local is the installation path, and should be assigned to INSTALL_PREFIX, otherwise the Make scripts will place units where they don't belong or the Make script will fail.

Step 1: Open a shell terminal
Step 2: cd /user/local/share/src/fpc-2.3.1/fpc/fcl-db/
Step 3: sudo make clean all install INSTALL_PREFIX=/usr/local OPT=-gl

Note: INSTALL_PREFIX parameter should be properly configured for units to be installed. In the sample below /usr/local is a default fpc path for Linux, but may vary on other OSes.

make clean all install INSTALL_PREFIX=/usr/local OPT=-gl

Finally, after rebuilding any FCL units you may want to rebuild LCL as well.

Problems with GDB on Mac OSX

Please see here for debugger issues under Mac


Contributing / Making Changes to Lazarus

IDE の、メッセージウィンドとソースエディタウィンドをドッキングできる素敵なパッチを作成したのですが、採用してくれませんか?

完全なドックマネージャ(ドッキングマネージャ)を作るという目標があるので、ドッキングについてのちょっとしたパッチは、採用されません。 完全なドックマネージャとは、

  • すべてのIDEウインドウをドッキングできる。
  • ユーザー定義ウインドウをドッキングできる。
  • ドッキングレイアウトを保存して、次にロードされたときは再生できる。
  • ページとしてもドッキングできる。
  • ドラッグドロップを必ずしも必要としない。

これらは大変難しいものと思われますが、そうでなければパッチは拒否されます。

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:

+-------------------++--+
|menu               ||  |
+-------------------+|  |
+--++---------------+|  |
|PI|| Source Editor ||CE|
+--+|               ||  |
+--+|               ||  |
|  |+---------------++--+
|OI|+-------------------+
|  ||messages           |
+--++-------------------+

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. All patches implementing docking without a dock manager makes it harder to implement a real dock manager and will be rejected.

As a temporary solution you can use this IDE extension: Manual Docker

lazarusを修正したり、改良しました。どのようにしたら公式Lazarusソースに、自分の変更を加えることができますか?

パッチを作成して、開発者グループに送ってください。詳細は、Creating A Patch/jaを見てください。

どうしたら、lazarusの開発者、SVNのアクセス管理者、バグトラッカーになれますか?

まず最初に、Lazarusのことを学び、あなたのスキルと知識を証明してください。 wiki articlesを読むことからはじめて、ソースコードを読み、 Lazarus Bug-Trackerを見て、いくつかのバグをfixした上で、もし、あなたが充分そうなる資格があると思ったら、メーリングリストの開発者コミュニティにコンタクトしてみてください。

定義はどこにありますか?

仮想キーコード定数

仮想キーコード定数は、LCLTypeに定義されています。仮想キーコード定数を使うユニットのuses内にLCLTypeを加えてください。 Virtual key constants are defined in LCLType. Add LCLtype to your uses.

IDEを使う

どうしたら"identifier 補完"を使えますか?

[ctrl][space]で、identifier補完機能を呼び出すことができます。

メニューのEnvironment -> Editor Options -> Code Tools -> Automatic Features で、identifier補完が自動的に高速におこなわれるようにセットすることができます。

Linux

Linux上でIDEから離れてデバッグを行いたいのですが

まず、デバッガが必要です。GDBはLinuxの標準的デバッガでいくつかのGUIフロントエンドが使用できます。dddはそのなかでも一般的なもので、多くのディストリビューションに採用されています。lazarus/lclをデバッグ情報付きでコンパイルするには次のようにして、更にデバッグを開始して下さい。

 $ make clean; make OPT=-dDEBUG
 $ ddd lazarus

お断りしておきますがdddはlazarusのデバッガより扱いづらいと思います。例を挙げますと、ddd/gdbは大文字小文字の違いにうるさい言語を対象として作られていますが、Pascalはそうではありません。従ってあなたはそれらのコンテンツを見るためには、すべてを大文字でタイプしなければなりません。詳しくはfpcのマニュアルを参照して下さい。

デバッグ中なのですが、dddはソースコードが見つからないとか、含まれていないとか言います。どうしたらいいんでしょう

それはgdbやdddに対してパスが指定されていないことに起因する問題によるものです。解決できる問題です。

  • dddのメニューから "Change directory"コマンドを使ってソースコードが存在するディレクトリを指定してください。しかしこの方法ではプログラムを開始したディレクトリを使用することができません。あなたは複数回ディレクトリを指定し直す必要があるかもしれません。
  • dddのEditメニューからgdb-settingsをたどって、検索パスを追加して下さい。
  • $(HOME)/.gdbinitに次のようなテキストファイルを作って下さい。あるいは追加してやって下さい:
     directory /your/path/to/lazarus
     directory /your/path/to/lazarus/lcl
     directory /your/path/to/lazarus/lcl/include
(訳注:ホームディレクトリ直下に.gdbinitというファイルを作ってくれ、という意味です。これは不可視属性になりますのでls -Aしないと見られなくなります--User:Tooka

リンク中に/usr/bin/ld can't find -l<hogehoge>というエラーが出ます

パッケージベースのディストリビューションの場合(大抵はこれ)
hogehoge.soとかhogehoge.aという名前のファイルを含むパッケージをインストールして下さい。Linuxにおいてダイナミックリンクライブラリは.so、スタティックリンクライブラリは.aの拡張子を持つことになります。Linuxディストリビューションによってはすでにパッケージの名前がhogehogeのものがインストールされているかもしれません。しかし、そのときは開発用パッケージが必要なのかもしれません。hogehoge-devのインストールをしてみましょう。そのなかにhogehoge.aやhogehoge.soがある、ということはよくあることです。
ソースコードベースのディストリビューションや自分で設定したシステムの場合(LFS)
hogehoge.aをmakeしてパスの通ったディレクトリにおいて下さい。必要ならば、hogehoge-version.so(.a)へのシンボリックリンクをhogehoge.so(.a)に作成しておきましょう.
FreeBSD
これはソースコードベースのディストリビューションと同じく、makeしてやって-Fl/use/local/libをfpc.cfgに追加するか、追加して更にLazarusライブラリパスに配置します。 GTK1.2には「FreeBSDのパッケージ名としてのgtk12」があるのを覚えておいてください。 (glibと同じように)
NetBSD
これはソースコードベースのディストリビューションと同じく、makeしてやって-Fl/use/local/libをfpc.cfgに追加するか、追加して更にLazarusライブラリパスに配置します。

どうやってKylix2のプロジェクトをLazarusに変換して取り込めばいいでしょう

Kylixのプロジェクトの変換はDelphi/VCLプロジェクトの変換に似ています。

LCL(Lazarus Component Library)はDelphiのVCLと互換性を持つように作られています。 KylixのCLXはQTと互換性を持つように作られています。 一般的なヒントを以下に記します:

  • すべてのCLXが使うQ-ユニット——QForms,QControls,QGraphicsとか——をVCL風に変更してください。Forms,Control,Graphicsのように。
  • Formを使うソースコードのusesセクションにLResourcesを追加してください。
  • すべての.xfmファイルをコピーするかリネームして拡張子を.lfmにしてください。
  • すべての.dprファイルをコピーするかリネームして拡張子を.lprにしてください、
  • .lprファイルのinterfaceセクションに、Interfacesを追加してください。
  • {$R *.res}という記述を削除してください。
  • {$R *.xfm}という記述を削除してください。
  • .pasファイルと.lprファイルに{$mode objfpc}{$H+}か{$mode delphi}{$H+}という記述を追加してください。
  • Add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):
 initialization
   {$I unit1.lrs}
The .lrs files can be created via the lazres tool in: (lazarusdir)/tools/lazres.
For example: ./lazres unit1.lrs unit1.lfm
  • Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.

lazarusをコンパイルしているとき、コンパイラがユニットを見つけられません。e.g.: gtkint.pp(17,16) Fatal: Can't find unit GLIB

1. 完全にクリーンな状態してください: 'make clean all' を実行します

2. コンパイラのバージョンを確認してください(2.0.0 以上)

3. コンパイラが正しい設定ファイルを使用しているか確認してください。通常は /etc/fpc.cfg にインストールされます。しかし、fpc は ~/.ppc386.cfg や、~/.fpc.cfg、/etc/ppc386.cfg といったファイルを調べ、最初に見つけたものだけを使用します。 (~ はホームディレクトリを指します)

ヒント: 'ppc386 -vt bogus'とすることでコンフィグファイルを探すことが出来ます。
複数の ppc386.cfg を使用するのは古い方法ですので削除して下さい。

4. コンフィグファイル(/etc/fpc.cfg)の中で fpc のライブラリのパスが正しく設定されているか確認して下さい。fpc のライブラリパスの設定は次のように行います。

   -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
   -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
   -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
最初の部分のパス(/usr/lib/fpc)は、あなたの環境に適合させて下さい。システムによっては、/usr/local/lib/fpc/...とった指定の仕方をする場合もあります。
ヒント: コマンドラインから'ppc386 -vt bogus'とすることでサーチパスを確認することが出来ます。

5. コンフィグファイル(/etc/fpc.cfg)の中で LCL のソースファイル(.pp、.pas)が正しく設定されているか確認して下さい:

 forbidden: -Fu(lazarus_source_directory)/lcl
 forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk
もしあなたの fpc プロジェクトに LCL を付け加えたいなら、上述のfpc のライブラリのパスの後に、次の二つのパスを設置します。:
 -Fu(lazarus_source_directory)/lcl/units/$fpctarget
 -Fu(lazarus_source_directory)/lcl/units/$fpctarget/gtk

6. 見つからないユニット(glib.ppu)が fpc ライブラリのディレクトリに存在しているか確認して下さい。例えば、gtk.ppu は /usr/lib/fpc/$version/units/i386-linux/gtk/ の中に見つけることができます。もしこれらが存在していないならば、fpc ライブラリは正常ではないので、再インストールして下さい。

7. ソースファイルが NFS でマウントされたディレクトリに置かれていないか確認して下さい。あるケースでは、NFS が作成したファイルを不正に更新していました。ソースを NFS ではないディレクトリに移動させて、コンパイルをして下さい。

I have installed the binary version, but when compiling a simple project, lazarus gives: Fatal: Can't find unit CONTROLS

Probably you are using a newer fpc package, than that used for building the lazarus binaries. The best solution is to download the sources and compile lazarus manually. You can download the source snapshot or get the source via svn:

 $ bash
 $ svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus
 $ cd lazarus
 $ make clean all

Make sure that lazarus get the new source directory: Environment->General Options->Files->Lazarus Directory Top

Lazarusのコンパイルをして、リンク中にこんなことを言われます: libgdk-pixbuf not found

gdk-pixbufライブラリ(gkt1.x)をインストールするか使用しないようにします。

gdk-pixbufライブラリはこちらにあります:

RPMs: http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=

Debianパッケージ: libgdk-pixbuf-dev

ソースコード: ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/

Lazarusでしないように設定するには:"ツール"→"Lazarusのビルド設定"にオプションを追加します。 '-dNoGdkPixBufLib' もしくはコマンドラインで次のようにしてください。 "make clean all OPT=-dNoGdkPixBufLib".

SuSEを使っていますが、リンク時に/usr/bin/ld が Cannot find -lgtk Error というエラーを返します

SuSE は gtk の開発用ライブラリを /opt/gnome/lib (64bits 版の場合は /opt/gnome/lib64)にインストールします。このパスは標準的なものではありません。シンプルな解決方法は、/etc/fpc.cfg にこのパスを追加することです。 (-Fl/opt/gnome/lib).

Lazarus crashes with runtime error 211 after I installed a component

After I installed a component, Lazarus crashes with the following message:

Threading has been used before cthreads was initialized.
Make cthreads one of the first units in your uses clause.
Runtime error 211 at $0066E188

How can I fix this?

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:

1) Change the source of ide/lazarus.pp: add the cthreads as first unit to the uses clause, so that is looks like this:

uses
  //cmem,
  cthreads, 
  {$IFDEF IDE_MEM_CHECK}
...

and rebuild lazarus.

2) In order to avoid modifying lazarus.pp file, a fpc compiler option could be used. Once package that uses threads has been compiled, 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.

Hint: Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.

スレッドを含むプログラムを実行するとランタイムエラー232で終了する

正確なエラーメッセージは:

This binary has no thread support compiled in.
Recompile the application with a thread-driver in the program uses
clause before other units using thread.
Runtime error 232

解決方法: メインプログラム(通常は .lpr ファイルです)の uses 節の先頭に cthreads を追加して下さい。

Ubuntu 6.06でIDEのフォントが文字化けするのですが

LazarusがGtk1.2でコンパイルされた場合、Gtk2のためのGnome設定/フォントは無効です。 この場合、次のように対処してみてください: (もしまだなければ).gtkrc.mineというファイルをホームディレクトリに作成します。その中に以下の行を納入してください。

style "default-text" {
       fontset = "-ipa-uigothic-medium-r-normal-*-*-120-*-*-*-*-jisx0212.1990-0,
                  -*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\
                  -*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
}

class "GtkWidget" style "default-text"

ここで120というのはフォントサイズ(12になる)です。適当に調整してください。

Ubuntuを使っています。ライブラリが見つからないために Gtk2 プログラムがコンパイルできません

Ubuntu には、インストールしたライブラリをリンク可能にするためのシンボリックリンクが、全てのライブラリで作成されるわけではないという問題があります。Gtk2 をリンクしようとした際に見つからないと指摘されたライブラリに、適切なシンボリックリンクがあるかどうか確認してください。例えば次のような方法があります:

cd /usr/lib
sudo ln -s libgdk-x11-2.0.so.0 libgtk-x11-2.0.so

実際のライブラリ(上の例では libgdk-x11-2.0.so.0)に対し、[ライブラリ名].so (上の例では libgdk-x11-2.0.so)というリンク可能なシンボリックリンクが作られます。

どうすればGtk2プログラムをコンパイルすることが出来ますか?

今のところ、Gtk2 版 IDE は少し不安定(little unstable)です。ですが、Gtk1 版 IDE を使って Gtk2 のソフトウェアをコンパイルすることは可能です。

Gtk2 用の LCL でリコンパイルするには、メニューの“Tools”->“Configure Build Lazarus”から、LCL を clean+build に、everything else を none にセットします。

Ok ボタンをクリックし、“Tools”->“Build Lazarus”を選択します。

続いてコンパイラオプションに進み、Gtk2 用のウィジェットセットに変更することで、Gtk2 のソフトウェアをコンパイルできるようになります。

Windows

コンパイラを使っているときに、"The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time." というメッセージが出ることがあります。

コンパイラディレクトリに make.cmdというOS2用のscriptfileが存在しています。Windows-NTでは、それは必要ないのですが、NTがスクリプトファイルとみなしますので、取り除いてください。

コンパイルしているときに、"make[3]: ./ppc1.exe: Command not found"というメッセージが出ます。

どういう訳か、makeコマンドがパスを消失しています。basedirを次のようにセットしてください。

make cycle BASEDIR=your_fpc_source_dir_herecompiler

Lazarusをコンパイルしているときに受け取るメッセージ

make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2

makeファイルを更新する必要があります。

makefile:27: *** You need the GNU utils package to use this Makefile. Stop.

スペースがはいっているパスにFPCをインストールしていないかどうか、確認してください。スペースがはいっているパスを、Makefileはサポートしません。

どうしたらlazarusのように、自分が作ったプログラムをXP風の見栄えにできますか?

myprogram.exeというプログラムの場合は、myprogram.exe.manifestというファイルを作成し、次をコピーペーストしてください。


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity processorArchitecture="*" version="1.0.0.0" type="win32" name="myprogram"/>
<description>programom</description>
<dependency>
  <dependentAssembly>
   <assemblyIdentity
     type="win32"
     name="Microsoft.Windows.Common-Controls"
     version="6.0.0.0"
     publicKeyToken="6595b64144ccf1df"
     language="*"
     processorArchitecture="*" />
  </dependentAssembly>
  </dependency>
</assembly>

ほらね、XP風でしょ?

WindowsでLazarusで作ったプログラムを実行させるとDOS窓で開始してしまいます

コマンドラインのコンパイラを使っている場合は-WGオプション(=Windows GUI)を指定してください。 LazarusIDEの場合は、Project menu -> Compiler Options -> Linking -> target OS Specific optionsで、コンパイラオプションダイアログでWindows GUIをチェックしてください。

Mac OS X

Why does compiling a project fail with 'unknown section attribute: no_dead_strip'?

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

  • Code > Unit style > Smart linkable (-CX)
  • and Linking > Link Style > Link smart (-XX)

Licensing

Can I make commercial applications with Lazarus ?

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.

Why are some components restricted from usage in commercial application ?

Lazarus comes with additional components, that were developed by third parties. Those are under various other Licenses. If you wish to use them you need to see the License within the source files of those packages. Most of those 3rd party components are in the directory "components".

How do I know if a Component is part of the LCL ?

All LCL units are in the directory "lcl". A List of units belonging to the LCL can be found here http://lazarus-ccr.sourceforge.net/docs/lcl/ . If you code uses units not listed on this page, you may have used a component that is not part of the LCL.

Can I make commercial plug-ins for Lazarus ?

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.

Contributors and Comments

This page has been converted from the epikwiki version.