gpt4 book ai didi

c++ - 使用 new 运算符创建对象导致无法解析的外部符号错误 C++ FTGL

转载 作者:太空宇宙 更新时间:2023-11-04 12:03:12 28 4
gpt4 key购买 nike

我在我的 Microsoft Visual Studio 2012 C++ 项目中使用 FTGL 库。我终于设法将它正确地链接到我的项目,因为我可以使用以下方法正确地呈现字体:

FTGLPixmapFont font("C:/Windows/Fonts/Arial.ttf");
font.Render("Hello world");

在我尝试使用 new 运算符创建对象之前一切似乎都正常:

FTGLPixmapFont* font = new FTGLPixmapFont("C:/Windows/Fonts/Arial.ttf"); // This causes error
font->Render("Hello world");

上面的代码产生了这个错误:

AppLayer.obj : error LNK2001: unresolved external symbol "public: virtual float __thiscall FTFont::Advance(unsigned short const *,int,class FTPoint)" (?Advance@FTFont@@UAEMPBGHVFTPoint@@@Z)
1>AppLayer.obj : error LNK2001: unresolved external symbol "public: virtual class FTBBox __thiscall FTFont::BBox(unsigned short const *,int,class FTPoint,class FTPoint)" (?BBox@FTFont@@UAE?AVFTBBox@@PBGHVFTPoint@@1@Z)
1>AppLayer.obj : error LNK2001: unresolved external symbol "public: virtual class FTPoint __thiscall FTFont::Render(unsigned short const *,int,class FTPoint,class FTPoint,int)" (?Render@FTFont@@UAE?AVFTPoint@@PBGHV2@1H@Z)

我完全不知道这是什么原因。如果有任何答案,我将不胜感激。

谢谢!

最佳答案

您似乎忘记链接库,或在构建中包含文件。该类继承类 FTFont。检查您是否正确链接了包含此定义的库。

在视觉上,您可以通过将 .lib 文件添加到项目来链接列表,就像它是一个 cpp 一样。

如果您从可视化解决方案链接另一个项目,请检查您项目的属性是否正确设置了对其他项目的依赖性。

最好的

关于c++ - 使用 new 运算符创建对象导致无法解析的外部符号错误 C++ FTGL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13307993/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com