Q:

Converting QString to QByteArray using toLatin1() gives a linker error

I have a simple Qt-5 console application that I am developing in Visual Studio 2015.  I can use Qt objects such as QStrings so I'm sure Qt is installed correctly, but I need to convert a QString to a char* so I can pass it to a library function. 
I followed this answer: QString to char* conversion
So I now have code that looks like:
QString myStr = "SomeString";
QByteArray ba = myStr.toLatin1();
const char *c_str = ba.data();

But when I build the solution I get the following error:
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: class QByteArray __thiscall QString::toLatin1(void)const & " (__imp_?toLatin1@QString@@QGBE?AVQByteArray@@XZ) referenced in function _main    

The problem seems to be the toLatin1() call, but I have no idea why the linker can't find it, especially since I can use other QString methods with no problem. 

A:

The linker error shows you the "mangled" C++ symbol name, which contains the class and parameters, encoded.  There is no standard on C++ symbol name mangling, so different compilers do it differently.  Even different versions of "same" compiler may change this (among other things, there is no standard C++ ABI), and Microsoft has done this several times with Visual C++. 
As a result, any C++ libraries you use must be compiled with same C++ compiler toolchain (or a compatible compiler, but on Windows there's a lot of... unfortunate diversity, here). 
This applies to Qt as well.  This is why you find several downloads of Qt offline installer for Windows, and why the online installer shows so many different Qt versions with same version number but different toolchain name.  If you find pre-built Qt for the compiler you want to use, great!  Install that and be happy.  
If not you have two options:

Build Qt libs yourself using your chosen compiler.  This is not hard, instructions are good, but it can be a bit tedious on Windows, as there are a few pre-requisites like Python, which you need to get separately. 
Switch compiler toolchain, so that you get a pre-built Qt libs for it (Qt Online installer can install MinGW toolchains matching the Qt libs it has for MinGW, which is rather convenient, if you don't have requirement to use something else).