Resolving the LNK2019 error while linking QT app

If you’re developing a QT based application(which links QT libs as statically) and get LNK2019unresolved external symbol’ link errors when you try to link the other static library,
Then you probably start looking those link settings such as,
☐ whether the architecture for the binary is correct(Are you trying to link an x86 lib to the x64 binary?)
☐ the static library file name specified to Input property was correct(Configuration Properties > Linker > Input > Additional Dependencies)
☐ they both use the same platform toolset or CRT lib(MT or MD)
☐ ‘dumpbin /headers’ for looking into export symbols
☐ or looking for some name mangling exists which might have caused the issue
However, if you’re still getting the LNK2019 unresolved link errors and it started frustrating although tried every setting you could, then you really should check the following setting as well.
The QT project seems to have the ’Treat WChar_t As Built in Type’ setting as ‘Noby default(see the attachment screen capture). However, Visual C++ static library project uses the option as Yes unless you haven’t changed it intentionally. Well, for me, the link error was resolved when I changed the option to Yes from the main QT application project settings.
qt_setting_1
Set to ‘Yes’ for the QT application to link a static library. Of course, it will be different in case you use different ‘Treat WChar_t As Built in Type’ setting  for the static library.
qt_setting_2


2>xxxwidget.obj : error LNK2019: unresolved external symbol "void __cdecl yyy::zzzstring(…)" (?zzzstring@xxx@@YAXPAU_GUID@@AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z) referenced in function __catch$?nnn@mmm@@…… :
fatal error LNK1120: 1 unresolved externals

view raw

output.log

hosted with ❤ by GitHub

 source: http://stackoverflow.com/questions/6987006/linking-to-a-c-static-library-from-a-qt-application

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s