In order to code can adapt to both VC + + and MinGW compiler, I changed my code, into:
#ifdef _msc_ver
#pragma comment (lib, "Crypt32.lib")//Link Ok,linux also comes with these two libraries, in the format-lcrypt32-lws2_32
#pragma comment (lib, "Ws2_32.lib")//Link OK
#pragma comment (lib, "Dnsapi.lib")//Not necessary
#ifdef _DEBUG
#pragma comment (lib, "... /libs/chilkatdbg.lib ")//Link OK
#else
#pragma comment (lib, "... /libs/chilkatrel.lib)//Link OK
#endif
#endif
However do not know how to do, compile not directly error, but finally in the link when the error:
"Undefined reference to ' vtable for MyClass"
Causes the Q_object macro to contain several virtual functions that are not known.
Online are said to be myclass.h no MOC expansion, re-run qmake can be. Of course, don't forget to delete the. user file and the makefile file, and don't forget to add the Myclass.h file to your project. But all tried, no.
At this time I just use QT creator not a few days, also thought that Qt creator and MinGW will not be used, so the engineering parameters are not set well. No way, uninstall the whole QT5, reinstall, incredibly problem still.
----------------------------------------------------------------------------------
Really have no way, had to return to VS2010 do QT development. Did not expect the same error, but more detailed, the MOC started the process of error:
My_tool.h: Note:no relevant classes found. No output generated.
The last error:
1>my_class.obj:error lnk2001:unresolved external symbol "public:virtual struct qmetaobject const * __thiscall MyCla Ss::metaobject (void) const "([email protected]@@[email protected] @XZ)
1>my_class.obj:error lnk2001:unresolved external symbol "public:virtual void * __thiscall Myclass::qt_metacast (char Const *) "([email protected]@@[email protected])
1>my_class.obj:error lnk2001:unresolved external symbol "Public:virtual int __thiscall myclass::qt_metacall (enum QM Etaobject::call,int,void *) "([email protected]@@[email protected]@@[email protected])
1>my_class.obj:error lnk2019:unresolved external symbol "Public:void __thiscall myclass::restoreprogress (unsigned __int64,unsigned __int64,class QString) "([email protected]@@[email protected]@@z) referenced in function" Public:bool _ _thiscall MyClass::D ownloadfilelist (class qstringlist *,class qstring,class qstring,class qhash<class QString, Class Qstring> &) "([email protected]@@[email protected]@[email protected]@[email Protected]@@[email protected] @@@z)
Since two compilers and different IDE and environment variables are all wrong, it's almost certainly my problem. But today I do not write the code, why is it wrong?
Lenovo to the online said Q_object problem, is estimated to be changed before the #ifdef macro definition conditions, causing problems. Find out the old version of the macro definition to change, sure enough, no problem.
It appears that the C + + compiler did not recognize (or judge the error) the macro definition conditions I wrote that caused Q_object to expand (or not to expand), causing it to fail to compile properly.
However, the C + + compiler is an error q_object after the expansion of the function processing results, so suddenly unexpected so many causes and consequences.
Wasted hours, I was angry, but always understand, handy to write down.
Angry dead people do not die, q_object caused by C + + error, but also can not understand