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.