C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – QT 5.6静态未解析的外部符号大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用QWidget开发一个小应用程序并静态链接Qt 5.6.我现在正在使用VS12.

#include <QMainWindow>
#include <QApplication>

int main(int argc,char *argv[])
{
  QApplication a(argc,argv);
  QMainWindow w;
  w.show();

  return a.exec();
}

它编译得很好,但我收到链接错误.

1>libGLESv2d.lib(global_state.obj) : error LNK2019: unresolved external symbol "unsigned long __cdecl CreateTLSIndex(void)" (?CreateTLSIndex@@YAKXz) referenced in function "struct A0x6526a104::Current * __cdecl `anonymous namespace'::GetCurrentData(void)" (?GetCurrentData@?A0x6526a104@@YAPAUCurrent@1@Xz)
1>libGLESv2d.lib(global_state.obj) : error LNK2019: unresolved external symbol "bool __cdecl DestroyTLSIndex(unsigned long)" (?DestroyTLSIndex@@YA_NK@z) referenced in function _DllMain_ANGLE@12
1>libGLESv2d.lib(global_state.obj) : error LNK2019: unresolved external symbol "bool __cdecl SetTLSValue(unsigned long,void *)" (?SetTLSValue@@YA_NKPAX@z) referenced in function "struct A0x6526a104::Current * __cdecl `anonymous namespace'::AllocateCurrent(void)" (?AllocateCurrent@?A0x6526a104@@YAPAUCurrent@1@Xz)
1>libGLESv2d.lib(global_state.obj) : error LNK2019: unresolved external symbol "void * __cdecl GetTLSValue(unsigned long)" (?GetTLSValue@@YAPAXK@z) referenced in function "void __cdecl `anonymous namespace'::DeallocateCurrent(void)" (?DeallocateCurrent@?A0x6526a104@@YAXXz)
1>libGLESv2d.lib(Program.obj) : error LNK2019: unresolved external symbol "bool __cdecl sh::InterpolationTypesmatch(enum sh::InterpolationType,enum sh::InterpolationTypE)" (?InterpolationTypesmatch@sh@@YA_NW4InterpolationType@1@0@z) referenced in function "private: static bool __cdecl gl::Program::linkValidateVaryings(class gl::InfoLog &,class std::basic_String<char,struct std::char_Traits<char>,class std::allocator<char> > const &,struct sh::Varying const &,struct sh::Varying const &)" (?linkValidateVaryings@Program@gl@@CA_NAAVInfoLog@2@ABV?$basic_String@DU?$char_Traits@D@std@@V?$allocator@D@2@@std@@ABUVarying@sh@@2@z)
1>libGLESv2d.lib(Program.obj) : error LNK2019: unresolved external symbol "public: struct sh::ShaderVariable & __thiscall sh::ShaderVariable::operator=(struct sh::ShaderVariable const &)" (??4ShaderVariable@sh@@QAEAAU01@ABU01@@z) referenced in function "private: bool __thiscall gl::Program::linkAttributes(class gl::InfoLog &,class gl::AttributeBindings const &,class gl::Shader const *)" (?linkAttributes@Program@gl@@AAE_NAAVInfoLog@2@ABVAttributeBindings@2@PBVShader@2@@z)
1>libGLESv2d.lib(Program.obj) : error LNK2019: unresolved external symbol "public: __thiscall sh::Attribute::Attribute(void)" (??0Attribute@sh@@QAE@Xz) referenced in function "public: __thiscall gl::Program::Program(class rx::ProgramImpl *,class gl::resourceManager *,unsigned int)" (??0Program@gl@@QAE@PAVProgramImpl@rx@@PAVresourceManager@1@I@z)
1>libGLESv2d.lib(Program.obj) : error LNK2019: unresolved external symbol "public: __thiscall sh::Attribute::~Attribute(void)" (??1Attribute@sh@@QAE@Xz) referenced in function "public: __thiscall gl::Program::Program(class rx::ProgramImpl *,unsigned int)" (??0Program@gl@@QAE@PAVProgramImpl@rx@@PAVresourceManager@1@I@z)
1>libGLESv2d.lib(ProgramImpl.obj) : error LNK2001: unresolved external symbol "public: __thiscall sh::Attribute::~Attribute(void)" (??1Attribute@sh@@QAE@Xz)
1>libGLESv2d.lib(Program.obj) : error LNK2019: unresolved external symbol "public: struct sh::Attribute & __thiscall sh::Attribute::operator=(struct sh::Attribute const &)" (??4Attribute@sh@@QAEAAU01@ABU01@@z) referenced in function "void __cdecl std::_Fill<struct sh::Attribute *,struct sh::Attribute>(struct sh::Attribute *,struct sh::Attribute *,struct sh::Attribute const &)" (??$_Fill@PAUAttribute@sh@@U12@@std@@YAXPAUAttribute@sh@@0ABU12@@z)

我已经包含以下库:

winmm.lib
imm32.lib
Ws2_32.lib
opengl32.lib
Qt5Guid.lib
Qt5Widgetsd.lib
qtpcred.lib
qtharfbuzzngd.lib
Qt5PlatformSupportd.lib
qwindowsd.lib
libEGLd.lib
libGLESv2d.lib
qtfreetyped.lib
Qt5Cored.lib

有趣的是,如果使用QtCreator它编译,链接和运行就好了.
我看到的是QtCreator添加了以下编译标志:

-DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_OPENGL_ES_2_ANGLE_STATIC -DGL_APICALL= -DEGLAPI=

我在我的项目中尝试了它们,但它没有改变任何东西.
我错过了什么?我需要什么才能使程序链接

解决方法

我找到了.这是使其工作所需的库列表:

winmm.lib
imm32.lib
Ws2_32.lib
Qt5Guid.lib
Qt5Widgetsd.lib
qtpcred.lib
qtharfbuzzngd.lib
Qt5PlatformSupportd.lib
qwindowsd.lib
libEGLd.lib
libGLESv2d.lib
qtfreetyped.lib
Qt5Cored.lib
+ preprocessord.lib
+ translatord.lib
+ d3d9.lib
+ dxguid.lib

不需要opengl32.lib.我仍然不知道为什么QtCreator知道需要哪些库以及为什么VS2013不需要.谢谢你的帮助.

@H_301_49@

大佬总结

以上是大佬教程为你收集整理的c – QT 5.6静态未解析的外部符号全部内容,希望文章能够帮你解决c – QT 5.6静态未解析的外部符号所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。