FTGL到处都是未定义的引用

FTGL undefined references everywere?

本文关键字:未定义 引用 FTGL      更新时间:2023-10-16

我试图使用这个库在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 ETCSDLOPENGLmain.cpp|108|undefined reference to `FTPixmapFont::FTPixmapFont(char const*)'|
OPENGL ETCSDLOPENGLmain.cpp|109|undefined reference to `FTFont::Error() const'|
OPENGL ETCSDLOPENGLmain.cpp|303|undefined reference to `FTPixmapFont::~FTPixmapFont()'|
OPENGL ETCSDLOPENGLmain.cpp|303|undefined reference to `FTPixmapFont::~FTPixmapFont()'|
||=== Build finished: 4 errors, 0 warnings ===|

现在这应该是因为我忘记把链接器放在右边IDK因为如果我包括剩下的两个链接器

-lfreetype2 -lftgl

我有50个错误,我不打算把它们放在这里,我不想弄坏你们的眼睛。

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

IDE: CodeBlocks操作系统: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     
filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `glBitmap@28'|
c:program   filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `glPixelStorei@8'|
c:program   filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `glPixelStorei@8'|
c:program  filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `glDrawPixels@20'|
c:program  filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `glBitmap@28'|
||=== Build finished: 27 errors, 0 warnings ===|
编辑:

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

||=== SDL, Debug ===|
c:program    
filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `FT_Render_Glyph'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTPixmapGlyph.o):FTPixmapGlyph.cpp|| undefined reference to `FT_Render_Glyph'|
c:program       
filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_New_Face'|
c:program   filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_New_Face'|
c:program    filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_New_Memory_Face'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_New_Memory_Face'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Done_Face'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Done_Face'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Done_Face'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Attach_File'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Attach_Stream'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Get_Kerning'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Load_Glyph'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a      
(FTFace.o):FTFace.cpp|| undefined reference to `FT_Get_Kerning'|
c:program filescodeblocksmingwbin..libgccmingw324.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 filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Set_Charmap'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Get_Char_Index'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Set_Charmap'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Get_Char_Index'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Select_Charmap'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTCharmap.o):FTCharmap.cpp|| undefined reference to `FT_Get_Char_Index'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTLibrary.o):FTLibrary.cpp|| undefined reference to `FT_Done_FreeType'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1......libftgl.a
(FTLibrary.o):FTLibrary.cpp|| undefined reference to `FT_Done_FreeType'|
c:program filescodeblocksmingwbin..libgccmingw324.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

尝试将-lopengl32 -lglu32移到-lftgl之后。让我们知道发生了什么。

看看这个问题,了解更多关于你的问题的细节,以及将来如何解决它:

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