8
votes

I have been trying for a few days now to build a static version of Qt with Visual Studio 2013. I just cannot figure out what I did wrong.

System:

  • Windows 7 64 bit
  • Visual Studio 2013 (Visual Studio 2012 is still installed)
  • Perl is installed (ActivePerl-5.18.2.1801-MSWin32-x64-297964.msi)
  • Python is installed (python-2.7.6.amd64.msi)
  • Direct X 10 SDK is installed (DXSDK_Jun10.exe I had to use this workaround)
  • Downloaded Qt 5.2.1
  • Downloaded Qt 5.3.0 alpha

What I did multiple time:

  • Extract the sources in a temp folder (C:\QtSrc)
  • Delete qtwebkit and qtwebkit-examples directories

For each folder I launched a Visual Studio x86 command line and ran:

  • cd C:\QtSrc
  • configure -c++11 -mp -debug-and-release -static -angle -nomake tests -nomake examples -prefix C:\Qt\5.2.1\msvc2013 -platform win32-msvc2013
  • nmake
  • nmake install

This was always sucessfull for every variations of -static vs -shared or Qt 5.2.1 vs Qt 5.3.0 alpha that I tried.

In Qt Creator

I can register the various Kits, compile and launch any example using the shared Qt library. The examples using the static Qt library on the other hand never compiled. The error always looks like this: LNK1104: cannot open file 'C:/Qt/5.3.0/msvc2013-static/lib/translator_common.lib'. The problem is that the file is missing (either translator_commond.lib in debug mode or translator_common.lib in release mode)

In Visual Studio 2013 (with Visual Studio Addin 1.2.3 alpha)

I can add the Qt version and change the Qt version of my solution. If can compile and run a very simple program like this one using the shared version of Qt:

#include <QtCore>
#include <QtGui>
#include <QtWidgets>

Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);

int main(int argc,char*argv[]){
    QApplication app(argc,argv);
    QMessageBox::critical(nullptr,"Hello","Hello Qt!");
    return 0;}

I get unresolved external linker errors when using the static version of Qt:

1>libGLESv2d.lib(Shader.obj) : error LNK2019: unresolved external symbol _ShInitialize referenced in function "private: void __thiscall gl::Shader::initializeCompiler(void)" (?initializeCompiler@Shader@gl@@AAEXXZ)
1>libGLESv2d.lib(Shader.obj) : error LNK2019: unresolved external symbol _ShFinalize referenced in function "public: static void __cdecl gl::Shader::releaseCompiler(void)" (?releaseCompiler@Shader@gl@@SAXXZ)
1>libGLESv2d.lib(Shader.obj) : error LNK2019: unresolved external symbol _ShInitBuiltInResources referenced in function "private: void __thiscall gl::Shader::initializeCompiler(void)" (?initializeCompiler@Shader@gl@@AAEXXZ)
1>libGLESv2d.lib(Shader.obj) : error LNK2019: unresolved external symbol _ShConstructCompiler referenced in function "private: void __thiscall gl::Shader::initializeCompiler(void)" (?initializeCompiler@Shader@gl@@AAEXXZ)
1>libGLESv2d.lib(Shader.obj) : error LNK2019: unresolved external symbol _ShDestruct referenced in function "public: static void __cdecl gl::Shader::releaseCompiler(void)" (?releaseCompiler@Shader@gl@@SAXXZ)
1>libGLESv2d.lib(Shader.obj) : error LNK2019: unresolved external symbol _ShCompile referenced in function "protected: void __thiscall gl::Shader::compileToHLSL(void *)" (?compileToHLSL@Shader@gl@@IAEXPAX@Z)
1>libGLESv2d.lib(Shader.obj) : error LNK2019: unresolved external symbol _ShGetInfo referenced in function "protected: void __thiscall gl::Shader::compileToHLSL(void *)" (?compileToHLSL@Shader@gl@@IAEXPAX@Z)
1>libGLESv2d.lib(Shader.obj) : error LNK2019: unresolved external symbol _ShGetInfoLog referenced in function "protected: void __thiscall gl::Shader::compileToHLSL(void *)" (?compileToHLSL@Shader@gl@@IAEXPAX@Z)
1>libGLESv2d.lib(Shader.obj) : error LNK2019: unresolved external symbol _ShGetObjectCode referenced in function "protected: void __thiscall gl::Shader::compileToHLSL(void *)" (?compileToHLSL@Shader@gl@@IAEXPAX@Z)
1>libGLESv2d.lib(Shader.obj) : error LNK2019: unresolved external symbol _ShGetInfoPointer referenced in function "protected: void __thiscall gl::Shader::compileToHLSL(void *)" (?compileToHLSL@Shader@gl@@IAEXPAX@Z)

Despite all my efforts I was unable to find which lib to include to resolve those missing symbols.

Do you have any idea what I have done wrong ?

2
Since this is a predominantly English-speaking site, I'd recommend translating the error messages. With that being said, I believe the errors are saying that it can't resolve the external references in the function __thiscall, is that correct?Taegost
I Translated the error messages. You are quite correct for Visual Studio, I need to link to some library but I cannot find which one.Arnaud
I don't know a lot about it, but it looks like it is missing an OpenGL implementation. Perhaps try linking with something such as this? code.google.com/p/angleprojectDark Falcon
@DarkFalcon Thanks for your help! But this is what the -angle option is for in configure. The link you provided however states that Directx11 is needed (this is the installed version on my computer) but I only have the SDK for direct x10. I will try on Windows 8 where The install for directx10 does not force to uninstall some components.Arnaud

2 Answers

4
votes

There is a bug in make install when using -angle and -static.

You can find the bug report here.

A simple workaround is to add a few copy at the end of the build process:

copy qtbase\lib\translator_common.lib C:\Qt\5.3.0\msvc2013-static\lib\
copy qtbase\lib\translator_common.prl C:\Qt\5.3.0\msvc2013-static\lib\
copy qtbase\lib\translator_commond.lib C:\Qt\5.3.0\msvc2013-static\lib\
copy qtbase\lib\translator_commond.prl C:\Qt\5.3.0\msvc2013-static\lib\

copy qtbase\lib\translator_hlsl.lib C:\Qt\5.3.0\msvc2013-static\lib\
copy qtbase\lib\translator_hlsl.prl C:\Qt\5.3.0\msvc2013-static\lib\
copy qtbase\lib\translator_hlsld.lib C:\Qt\5.3.0\msvc2013-static\lib\
copy qtbase\lib\translator_hlsld.prl C:\Qt\5.3.0\msvc2013-static\lib\

copy qtbase\lib\preprocessor.lib C:\Qt\5.3.0\msvc2013-static\lib\
copy qtbase\lib\preprocessor.prl C:\Qt\5.3.0\msvc2013-static\lib\
copy qtbase\lib\preprocessord.lib C:\Qt\5.3.0\msvc2013-static\lib\
copy qtbase\lib\preprocessord.prl C:\Qt\5.3.0\msvc2013-static\lib\

I hope this can help others.

2
votes

I happened to met with the same issue. I think the lib file you want to link against is translator_commond.lib. It contains the ANGEL symbols.

Here is how I found out the name of the library, in case it could be helpful when you met with other unresolved external symbols with Qt.

The dumpbin.exe tool is quite helpful here. You could execute dumpbin.exe /symbols some_lib.lib | findstr /c:"SOME_SYMBOL" to found whether a library contains or uses an symbol.

Since there are so many libs in Qt, I simply search for all *.lib files in Qt directory and copy them into a single directory, and then I do a batch search using the command below.

for %f in (*.lib) do echo %f >> symbols.txt && dumpbin /symbols %f | findstr /c:"SOME_SYMBOL" >> symbols.txt

Once done, you could check the generated symbols.txt and find out the name of the library that contains the symbol you are looking for.

BTW, since there are several huge libs, e.g. Qt5Core, Qt5Quick, etc, you probably would like to exclude them from searching.