MingWを使用してFreeType 2ライブラリをリンクできません。ld.exe:-lfreetypeを見つけることができません

StackOverflow https://stackoverflow.com/questions/6091982

質問

Windows 7では、IDEとしてCODE ::ブロックを使用してMingWを使用してコンパイルしています。すべてが最新であるべきです。私はたくさんの似たような質問があることに気づいたが、それらは静的ライブラリをコンパイルしていない動的ライブラリーをリンクしているように思われた。

FTGLを使用しようとしていますOpenGLでテキストを使用できるようにしています。 FTGLには、FreeType 2がインストールされます。私はFreeTypeソースをダウンロードし、mingw32-make.exeを使用してcmd.exeから静的ライブラリを構築するためのinstall.gnu命令に従った。

表示された命令として、FreeTypeインストールの基本ディレクトリからMINGW32を実行しました。コンソールの出力は予想通りでした:

D:\freetype-2.4.4>mingw32-make

FreeType build system -- automatic system detection

The following settings are used:

  platform                     win32
  compiler                     gcc
  configuration directory      .\builds\win32
  configuration rules          .\builds\win32\w32-gcc.mk

If this does not correspond to your system or settings please remove the file
'config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type 'make' again to build the library.
or 'make refdoc' to build the API reference (the latter needs python).

Could Not Find D:\freetype-2.4.4\objs\ftmodule.h
Generating modules list in ./objs/ftmodule.h...
"* module: truetype  (Windows/Mac font files with extension *.ttf or *.ttc)"
"* module: type1     (Postscript font files with extension *.pfa or *.pfb)"
"* module: cff       (OpenType fonts with extension *.otf)"
"* module: cid       (Postscript CID-keyed fonts, no known extension)"
"* module: pfr       (PFR/TrueDoc font files with extension *.pfr)"
"* module: type42    (Type 42 font files with no known extension)"
"* module: winfnt    (Windows bitmap fonts with extension *.fnt or *.fon)"
"* module: pcf       (pcf bitmap fonts)"
"* module: bdf       (bdf bitmap fonts)"
"* module: sfnt      (helper module for TrueType & OpenType formats)"
"* module: autofit   (automatic hinting module)"
"* module: pshinter  (Postscript hinter module)"
"* module: raster    (monochrome bitmap renderer)"
"* module: smooth    (anti-aliased bitmap renderer)"
"* module: smooth    (anti-aliased bitmap renderer for LCDs)"
"* module: smooth    (anti-aliased bitmap renderer for vertical LCDs)"
"* module: psaux     (Postscript Type 1 & Type 2 helper module)"
"* module: psnames   (Postscript & Unicode Glyph name handling)"
done.
.

プラットフォームとコンパイラの両方としての見解が正しいことで、makeコマンドを再実行しました。

D:\freetype-2.4.4>mingw32-make
(bunch of calls, building objects then linking them, until:)
ar: creating objs/freetype.a
.

これはディレクトリd:\ freeetype-2.4.4 \ objs内のファイルfreeetype.aを作成しました。

CODE ::ブロックのステップをプロジェクトにリンクするには、FTGLをテストするためのコードのサンプルビットを追加し、それを構築しようとしました。

私が物事をやろうとする方法に応じて、2つのエラーがあります。

リンカに正しいディレクトリを入力した場合(-ld:\ freeetype-2.4.4 \ objs)と-lfreetypeとリンクすると、ld.exeがタイトルのエラーで終了するまですべてが問題ありませんが、見つかりません - lfreetype

正しいディレクトリを提供していない場合は、同じエラーが発生します。ライブラリが見つかりません。

ファイルの名前、freeType.a、libfreetype.aに変更し、正しいディレクトリを入力してください。代わりにいくつかの未定義の参照を取得します。

obj\Release\CApp_OnRender.o:CApp_OnRender.cpp:(.text+0x250): undefined reference to `FTPixmapFont::FTPixmapFont(char const*)'
obj\Release\CApp_OnRender.o:CApp_OnRender.cpp:(.text+0x258): undefined reference to `FTFont::Error() const'
obj\Release\CApp_OnRender.o:CApp_OnRender.cpp:(.text+0x274): undefined reference to `FTFont::FaceSize(unsigned int, unsigned int)'
obj\Release\CApp_OnRender.o:CApp_OnRender.cpp:(.text+0x308): undefined reference to `FTFont::Render(char const*, int, FTPoint, FTPoint, int)'
obj\Release\CApp_OnRender.o:CApp_OnRender.cpp:(.text+0x316): undefined reference to `FTPixmapFont::~FTPixmapFont()'
obj\Release\CApp_OnRender.o:CApp_OnRender.cpp:(.text+0x328): undefined reference to `FTPixmapFont::~FTPixmapFont()'
collect2: ld returned 1 exit status
.

誤ったディレクトリを入力した場合は、再度Libraryが見つかりませんでした。

Makeは、インストールファイル内の指示に従って、LIBから始めなかった名前のライブラリを作成しました。私はチェックし、他のすべての.aファイルがlib-から始めました。そして、リンカがlibfreetype.aファイルを探しているようです。それでは、なぜですか、なぜFreeType.Aが代わりにFreeType.Aを作成していますか?これは、プログラムをコンパイルするために使用しているライブラリのために同じコンパイラを使用しています。

とにかく、ここからどこへ行くべきかわからない。私はMINGWパッケージの一部であるMSYSシェルを使用することを考えましたが、ITの経験はあまりありません。install.unixの命令は、もっと明白なコマンドを知っていると思います。彼らは、何が賢明であるかもしれないかについて言及せずに、./configure [オプション]を使って言及します。システムのより多くの知識を持つ誰かにとってはおそらく明らかですが、MSYSはSHの最初の経験です。

この問題についてお願いします。

役に立ちましたか?

解決

私のlibfreetype.a(2.4.4、修正Debianパッケージから構築された)シンボルをエクスポートしていないリンカーが探している(FTPixMapFontコンストラクタ)、ヘッダはそのようなクラスを宣言していません。迅速なGoogle検索は、それらがFTGLに属することを示しています。

importファイルの名前をlibfreetype.aに名前を変更しました。(MingW LDはそれ以外の場合は見つかりません)、必要なFTGLライブラリにもリンクしていましたか?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top