先按照这个帖子弄好静态库

http://www.cnblogs.com/rollenholt/articles/2518642.html 

 

注意原文中config那一步最后一个"-"输入成了中文状态下的"—",正确的如下:

configure -debug-and-release -fast -static -platform win32-msvc2010 -no-qt3support -script -scripttools -qt-zlib -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -qt-sql-sqlite -plugin-sql-sqlite -qt-style-windows -qt-style-windowsxp -qt-style-windowsvista -qt-style-plastique -qt-style-cleanlooks -qt-style-motif -qt-style-cde -nomake demos -nomake examples -nomake docs -mp

 

选中VS的Qt菜单中Qt->Qt Options 的Qt Versions标签。点击右边的Add增加

Version name我输入的是4.8.3_static, path就是选中刚才你那个Qt源码的目录

增加完成后就在下面那个ComboBox中选中你刚才加的版本。

 

对于已经在vs中建好的Qt工程, 右键点击工程->Qt Project Settings

然后在弹出的对话框的Properties标签中的Version选项选择你刚才建立的版本。

 

最后需要在你的代码中导入这两个库

#pragma comment (lib, "winmm.lib")

#pragma comment (lib, "imm32.lib")

注:我这边只用了Qt的Core library和GUI library,对于引用了Qt其他模块的可能需要导入更多的库

 

注2:对于Release版的编译,可能会出现在lib库中函数多重定义的错误,需要在项目的

属性-> 链接器 -> 输入 

然后选择右边的忽略特定默认库输入MSVCRT.lib 

看起来就像下面这个样子:

vs2010静态链接Qt

相关文章:

  • 2021-08-20
  • 2022-12-23
  • 2021-10-19
  • 2021-08-10
  • 2021-06-20
  • 2022-12-23
  • 2022-02-11
  • 2021-07-31
猜你喜欢
  • 2022-02-07
  • 2021-08-21
  • 2021-07-09
  • 2022-01-30
  • 2021-09-24
  • 2022-12-23
相关资源
相似解决方案