0

到目前为止,我一直在尝试使用这个库在 OpenGL 应用程序上输出文本,我得到了一个预编译的库,所以我更容易上手,所以代码如下:

#include <SDL/SDL_opengl.h>
#include <FTGL/ftgl.h>
...
...
int main( int argc, char* args[] )
{
...
...

//Y U NO WORK!
FTGLPixmapFont font("ariblk.ttf");
if(font.Error())

...
...

 SDL_Quit();

 return 0;
 }

所以如果我用这个链接器编译它:
-lmingw32 -lSDLmain -lSDL -lopengl32 -lglu32 -lSDL_image -lm -lgdi32 -lsdl_mixer -lSDL_ttf

我得到这个错误:

OPENGL ETC\SDLOPENGL\main.cpp|108|undefined reference to `FTPixmapFont::FTPixmapFont(char const*)'|

OPENGL ETC\SDLOPENGL\main.cpp|109|undefined reference to `FTFont::Error() const'|

OPENGL ETC\SDLOPENGL\main.cpp|303|undefined reference to `FTPixmapFont::~FTPixmapFont()'|

OPENGL ETC\SDLOPENGL\main.cpp|303|undefined reference to `FTPixmapFont::~FTPixmapFont()'|
||=== Build finished: 4 errors, 0 warnings ===|

现在这应该是因为如果我包含剩下的 2 个链接器,我忘了把链接器放在正确的 IDK 上:

-lfreetype2 -lftgl

我得到了 50 个错误我不会把它们放在这里我不想弄坏你们的眼睛。

那么我能做些什么来解决这个问题呢?

IDE:代码块操作系统:Windows

编辑:

所以在更改订单后我仍然会收到错误

错误:

||=== SDL, Debug ===|
int)]+0x12)||undefined reference to `glPushAttrib@4'|
int)]+0x21)||undefined reference to `glPushClientAttrib@4'|
int)]+0x30)||undefined reference to `glEnable@4'|
int)]+0x47)||undefined reference to `glBlendFunc@8'|
int)]+0x6c)||undefined reference to `glGetFloatv@8'|
int)]+0x82)||undefined reference to `glPixelTransferf@8'|
int)]+0x98)||undefined reference to `glPixelTransferf@8'|
int)]+0xae)||undefined reference to `glPixelTransferf@8'|
int)]+0xc4)||undefined reference to `glPixelTransferf@8'|
int)]+0x147)||undefined reference to `glPopClientAttrib@0'|
int)]+0x14c)||undefined reference to `glPopAttrib@0'|
int)]+0x12)||undefined reference to `glPushAttrib@4'|
int)]+0x21)||undefined reference to `glPushClientAttrib@4'|
int)]+0x30)||undefined reference to `glEnable@4'|
int)]+0x47)||undefined reference to `glBlendFunc@8'|
int)]+0x6c)||undefined reference to `glGetFloatv@8'|
int)]+0x82)||undefined reference to `glPixelTransferf@8'|
int)]+0x98)||undefined reference to `glPixelTransferf@8'|
int)]+0xae)||undefined reference to `glPixelTransferf@8'|
int)]+0xc4)||undefined reference to `glPixelTransferf@8'|
int)]+0x147)||undefined reference to `glPopClientAttrib@0'|
int)]+0x14c)||undefined reference to `glPopAttrib@0'|

c:\program     
files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `glBitmap@28'|

c:\program   files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `glPixelStorei@8'|

c:\program   files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `glPixelStorei@8'|

c:\program  files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `glDrawPixels@20'|

c:\program  files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `glBitmap@28'|
||=== Build finished: 27 errors, 0 warnings ===|

编辑:

在做了casualcoder所说的错误之后,现在似乎它不会为你的答案工作

||=== SDL, Debug ===|
c:\program    
files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `FT_Render_Glyph'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `FT_Render_Glyph'|

c:\program       
files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_New_Face'|

c:\program   files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_New_Face'|

c:\program    files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_New_Memory_Face'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_New_Memory_Face'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Done_Face'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Done_Face'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Done_Face'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Attach_File'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Attach_Stream'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Get_Kerning'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Load_Glyph'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a      
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Get_Kerning'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a   
(FTSize.o):FTSize.cpp|| undefined reference to `FT_Set_Char_Size'|
)]+0x54)||undefined reference to `FT_Outline_Get_CBox'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Set_Charmap'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Get_Char_Index'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Set_Charmap'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Get_Char_Index'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Select_Charmap'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Get_Char_Index'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTLibrary.o):FTLibrary.cpp|| undefined reference to `FT_Done_FreeType'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTLibrary.o):FTLibrary.cpp|| undefined reference to `FT_Done_FreeType'|

c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libftgl.a
(FTLibrary.o):FTLibrary.cpp|| undefined reference to `FT_Init_FreeType'|
||=== Build finished: 25 errors, 0 warnings ===|

最后更新

正确的顺序是:

-lmingw32 -lSDLmain -lSDL -lSDL_image -lm -lgdi32 -lsdl_mixer -lSDL_ttf -lftgl -lfreetype2 -lopengl32 -lglu32

4

1 回答 1

2

尝试移动-lopengl32 -lglu32-lftgl。让我们知道会发生什么。

查看此问题以获取有关您的问题以及将来如何解决该问题的更多详细信息:

为什么链接库的顺序有时会导致 GCC 出错?

于 2012-01-04T00:37:53.280 回答