[SOLVED] Very strange errors when building a Qt project in MSVS

  • Hello!

    I have a very strange problem that makes me completely puzzled.

    I'm working in MSVS 2012 with the Visual Studio Add-in 1.2.2 installed, and in my project I'm using Intel's Perceptual SDK. So I have to link two of their libraries (*.lib files). Now if I use a "New project..." wizard to create, say, simple "MFC application" or "Win32 console application", everything works fine.
    But if use it to create a "Qt application" I get 6 "unresolved external symbol" errors when building the project. And these unresolved symbols are not about Qt, they are about Intel's SDK! Here are just 3 of them:
    1>mainwindow.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall UtilPipelineFace::EnableFaceLocation(unsigned short *)" (?EnableFaceLocation@UtilPipelineFace@@UAEXPAG@Z)

    1>mainwindow.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall UtilPipelineFace::EnableFaceLandmark(unsigned short *)" (?EnableFaceLandmark@UtilPipelineFace@@UAEXPAG@Z)

    1>mainwindow.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall
    UtilPipelineGesture::EnableGesture(unsigned short *)" (?EnableGesture@UtilPipelineGesture@@UAEXPAG@Z)
    So I link exactly the same two Intel’s libraries and when building a "standard" Visual C++ project everything is ok, but when building a "Qt" project these unresolved symbols appear out of nowhere!

    And this problem is not about wrong library path/name or whatever. If I remove any of these 2 libraries from the linker’s input I get more than 6 unresolved symbols. And at the same time just these 2 libraries works fine for the “standard” Visual C++ projects.

    So as I’ve already said I have no idea what’s going on. Has anybody experienced something like this? Or do you have any ideas why it can happen? I would really appreciate.

    [edit, code tags added, koahnig]

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Could you compare the linker flags from your working project and the one from your Qt project ?

    There might be some difference that could explain the strange behavior

    Hope it helps

  • Hello, SGaist. Thank you for the welcome and for your reply. I've compared linker's command lines for both projects. There were some differences(namely /INCREMENTAL and /SAFESH flags), but I've made them completely identical, except for the project-related files (OUT location, *.pdb file, *.pgd file, *.manifest file). It didn't help :(
    Now I feel even more puzzled. What else can it be???

  • I figured it out at last! It was all about the /Zc:wchar_t (wchar_t Is Native Type) flag of the compiler. It affects C++ decorated names - that's why I had linker errors. Discussion of this problem can be found here:

    P. S. Anyway, thanks for your answer! It made me think in the right direction ;)

  • Lifetime Qt Champion

    You're welcome !

    As a side note, this flag changed from Qt 4 to Qt 5. Depending on the libraries you are using you can also rebuild Qt changing the value of that flag in the mkspec.

    Don't forget to update the thread's title to solved so other forum users may know a solution has been found :)

  • Thanks for your tips. In the qmake.conf from the Qt 5.1.0 sources I found:

    QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t

    Looks like it is compiled WITH "wchar as a native type" by default.

  • Lifetime Qt Champion

    Yes, this started with Qt 5

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.