【问题标题】:Statically Compiling Qt 4.6.2静态编译 Qt 4.6.2
【发布时间】:2011-01-28 12:59:43
【问题描述】:

这是我所做的,但它会导致错误:

1:在 win32-msvc2008\qmake.conf 我设置QMAKE_CFLAGS_RELEASE = -O1 -Og -GL -MD

2:我从 MSVC2008 CMD 运行 vcvarsall.bat x86vcvars32.bat "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin

3:从 Qt 4.6.2 CMD 我运行以下命令

C:\Qt\4.6.2>配置-release -nomake 示例 -nomake 演示 -no-exceptions -n o-stl -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -no-sql-sqlite -平台 win32-msvc2008 -static -qt-libjpeg -qt-zlib -qt-libpng

然后nmake

但是,我每次都遇到这些错误:

    link /LIBPATH:"c:\Qt\4.6.2\lib"

/LIBPATH:"c:\Qt\4.6.2\lib" /NOLOGO /增量:无 /清单 /MANIFESTFILE:"tmp\obj\release_static\assistant_adp.interme diate.manifest" /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' 名称='微 soft.Windows.Common-Controls' 版本='6.0.0.0' publicKeyToken='6595b64144ccf1df' 语言='' 处理器架构=''" /OUT:......\bin\assistant_adp.exe @C :\DOCUME~1\Geeko\LOCALS~1\Temp\nm3F8.tmp fontpanel.obj : MSIL .netmodule 或 发现用 /GL 编译的模块; 重新启动与 /LTCG 的链接;添加 /LTCG 到链接命令行来改进 链接器性能 main.obj:错误 LNK2001:未解析的外部符号 “类 QObject * __cdecl qt _plugin_instance_qjpeg(void)" (?qt_plugin_instance_qjpeg@@YAPAVQObject@@XZ) ......\bin\assistant_adp.exe:致命 错误 LNK1120:1 个未解决的外部问题

NMAKE:致命错误 U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN \link.EXE"':返回 代码“0x460”停止。

NMAKE : 致命错误 U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN \nmake.exe"' : return code '0x2' Stop.

NMAKE : 致命错误 U1077: 'cd' : return code '0x2' Stop.

NMAKE : 致命错误 U1077: 'cd' : return code '0x2' Stop.

NMAKE : 致命错误 U1077: 'cd' : return code '0x2' Stop.

真的谢谢你。

【问题讨论】:

    标签: qt static linker compilation


    【解决方案1】:

    我尝试使用 MS VS 2008 进行此操作,并且成功了。

    C:\Qt\4.6.2>configure -release -static -opensource -no-fast -no-exceptions -no-accessibility -no-rtti -no-stl -no-opengl -no-openvg -no-incredibuild-xge -no-style-plastique -no-style-cleanlooks -no-style-motif -no-style-cde -no-style-windowsce -no-style-windowsmobile -no-style-s60 -no-gif -no-libpng -no-libtiff -no-libjpeg -no-libmng -no-qt3support -no-mmx -no-3dnow -no-sse -no-sse2 -no-iwmmxt -no-openssl -no-dbus -platform win32-msvc2008 -arch windows -no-phonon -no-phonon-backend -no-multimedia -no-audio-backend -no-script -no-scripttools -webkit -no-declarative
    

    但是,我在构建静态链接到 QWebKit 的项目时遇到这些错误:

    1>Creating library C:\Users\Geeko\Desktop\Qt\TestQ\Release\TestQ.lib and object C:\Users\Geeko\Desktop\Qt\TestQ\Release\TestQ.exp
    
    1>QtWebKit.lib(PluginPackageWin.obj) : error LNK2019: unresolved external symbol _VerQueryValueW@16 referenced in function "class WebCore::String __cdecl WebCore::getVersionInfo(void * const,class WebCore::String const &)" (?getVersionInfo@WebCore@@YA?AVString@1@QAXABV21@@Z)
    
    1>QtWebKit.lib(PluginPackageWin.obj) : error LNK2019: unresolved external symbol _GetFileVersionInfoW@16 referenced in function "private: bool __thiscall WebCore::PluginPackage::fetchInfo(void)" (?fetchInfo@PluginPackage@WebCore@@AAE_NXZ)
    
    1>QtWebKit.lib(PluginPackageWin.obj) : error LNK2019: unresolved external symbol _GetFileVersionInfoSizeW@8 referenced in function "private: bool __thiscall WebCore::PluginPackage::fetchInfo(void)" (?fetchInfo@PluginPackage@WebCore@@AAE_NXZ)
    
    1>QtWebKit.lib(PluginDatabaseWin.obj) : error LNK2019: unresolved external symbol __imp__PathRemoveFileSpecW@4 referenced in function "class WebCore::String __cdecl WebCore::safariPluginsDirectory(void)" (?safariPluginsDirectory@WebCore@@YA?AVString@1@XZ)
    
    1>QtWebKit.lib(PluginDatabaseWin.obj) : error LNK2019: unresolved external symbol __imp__SHGetValueW@24 referenced in function "void __cdecl WebCore::addWindowsMediaPlayerPluginDirectory(class WTF::Vector<class WebCore::String,0> &)" (?addWindowsMediaPlayerPluginDirectory@WebCore@@YAXAAV?$Vector@VString@WebCore@@$0A@@WTF@@@Z)
    
    1>QtWebKit.lib(PluginDatabaseWin.obj) : error LNK2019: unresolved external symbol __imp__PathCombineW@12 referenced in function "void __cdecl WebCore::addMacromediaPluginDirectories(class WTF::Vector<class WebCore::String,0> &)" (?addMacromediaPluginDirectories@WebCore@@YAXAAV?$Vector@VString@WebCore@@$0A@@WTF@@@Z)
    
    1>C:\Users\Geeko\Desktop\Qt\TestQ\Release\TestQ.exe : fatal error LNK1120: 6 unresolved externals
    

    我需要检查 Qt 项目选项中的内容吗? 我检查了 QtCore、QtGui、Network 和 WebKit。

    【讨论】:

    • Webkit 不能用静态标志构建!
    • 其实我是静态编译成功的
    【解决方案2】:

    尝试设置这些环境变量:

    • QTDIR : c:\Qt\4.6.2 或解压 Qt 源代码的任何位置。
    • QMAKESPEC:win32-msvc2008
    • %QTDIR%/binPATH

    并使用“Visual Studio 2008 命令提示符”(在 VS2008 的工具菜单中)而不是 Qt。

    【讨论】:

    • 感谢您的回复。这就是我所拥有的。不过似乎有一些进展:)有什么想法吗? BTE 我跟着这个:formortals.com/build-qt-static- c1xx:致命错误 C1027:/Ym 的值在创建和使用预编译头 qsequentialanimationgroup.cpp 之间不一致 c1xx:致命错误 C1027:/Ym 的值在创建和使用预编译头 qparallelanimationgroup.cpp 之间不一致c1xx:致命错误 C1027:创建和使用预编译头文件 qpauseanimation.cpp 之间的 /Ym 值不一致
    • 不一致可能是由先前编译留下的对象引起的。你清理了Qt目录吗? -- 顺便说一句,您的链接会导致 404 错误...
    • 您好,这次我尝试了 nmake clean 然后 nmake,但仍然:c1xx:致命错误 C1027:/Ym 的值在创建和使用预编译头 NMAKE 之间不一致:致命错误 U1077:'"c: \Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.EXE"' :返回代码 '0x2' 停止。 NMAKE:致命错误 U1077:'"c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe"':返回代码 '0x2' 停止。 NMAKE:致命错误 U1077:“cd”:返回代码“0x2”停止。该网站是formortals.com/…
    • 也许nmake clean 还不够,您还需要运行nmake confclean -- 这将清理您的makefile -- 然后从configure 步骤重新启动。
    • gregseth: 仍然有这个错误: 错误 LNK2001: 无法解析的外部符号 "class QObject * __cdecl qt _plugin_instance_qjpeg(void)" (?qt_plugin_instance_qjpeg@@YAPAVQObject@@XZ) ..\..\.. \bin\assistant_adp.exe:致命错误 LNK1120:1 个未解决的外部 NMAKE:致命错误 U1077:'"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN \link.EXE"':返回代码 '0x460' 停止。 NMAKE : 致命错误 U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN \nmake.exe"' : 返回码 '0x2' 停止。 NMAKE : 致命错误 U1077: 'cd' : return code '0x2' Stop.
    【解决方案3】:

    您是否考虑过 Qt 默认选择的 std::string 类型?

    这是一个小的编译器开关-Zc:wchar_t-,它明确地将wchar_t 定义为无符号短整型而不是内置类型。 如果您在末尾省略 -,即 -Zc:wchar_t,它会发生变化并且可能更适合您的项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多