c++ - FTGL 到处都是 undefined reference ?

标签 c++ opengl codeblocks ftgl

到目前为止,我一直在尝试使用这个库在 OpenGL 应用程序上输出文本,我得到了一个 prcompiled 库,这样我就可以更容易上手,所以这是代码:

#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 ===|

现在这应该是因为我忘记将链接器放在正确的 IDK 中,因为如果我包含 2 个剩余的链接器:

-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

最佳答案

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

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

Why does the order in which libraries are linked sometimes cause errors in GCC?

关于c++ - FTGL 到处都是 undefined reference ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8714155/

相关文章:

c++ - 从 Scilab 迁移到 C++

c++ - 增量变量是否可在平局调用中重用?

c++ - 是否可以使用代码块从文件运行一些案例测试而不使用文件函数

c++ - 如何计算二值图像上的白色物体?

c++ - 无效指针参数,传递缓冲区

c++ - 如何有效地从 C++ 中的集合中删除开始和结束元素?

opengl - 3 个索引缓冲区

opengl - 为 OpenGL 实现细节级别算法

c++ - Opengl - 渲染不同的顶点格式

c++ - 错误 : no match for 'operator[]'