August 1, 2011

Maxim Prishchepa Maxim Prishchepa
Hobby Entomologist
93 posts

[SOLVED] QtSingleApplication

 

Hi All!
I write in VS2008, I wont create QtSingleApplication application. I’m create Qt Application, then add to my project path to “src” files QtSingleApplication, then rewrite QtApplication to QtSingleApplication, write

  1. #include "QtSingleApplication";
, and start build project. But linker write error:
  1. 1>LINK : D:\Projects\test\test\Debug\test.exe not found or not built by the last incremental link; performing full link
  2. 1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall QtSingleApplication::QtSingleApplication(int &,char * *,bool)" (??0QtSingleApplication@@QAE@AAHPAPAD_N@Z) referenced in function _main
  3. 1>D:\Projects\test\test\Debug\test.exe : fatal error LNK1120: 1 unresolved externals

Who can tall, why this happen? What is I do wrong?

Code main.cpp:

  1. #include "test.h"
  2.  
  3. #include "QtSingleApplication"
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.     QtSingleApplication a(argc, argv);
  8.     test w;
  9.     w.show();
  10.     return a.exec();
  11. }

 Signature 

Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

12 replies

August 1, 2011

Gerolf Gerolf
Mad Scientist
3005 posts

You did not add the QtSingleApplication.cpp and .h source file to your project.
It is not part of QtGui!

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

August 1, 2011

Maxim Prishchepa Maxim Prishchepa
Hobby Entomologist
93 posts

Ok. After adding, I have a more errors: (if i add all of headers and source files “qtlocalpeer”, “qtlockedfile”, “qtsingleapplication” and “qtsinglecoreapplication”)

  1. 1>Linking...
  2. 1>qtlocalpeer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QLocalServer::QLocalServer(class QObject *)" (__imp_??0QLocalServer@@QAE@PAVQObject@@@Z) referenced in function "public: __thiscall QtLocalPeer::QtLocalPeer(class QObject *,class QString const &)" (??0QtLocalPeer@@QAE@PAVQObject@@ABVQString@@@Z)
  3. 1>qtlocalpeer.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QLocalServer::metaObject(void)const " (?metaObject@QLocalServer@@UBEPBUQMetaObject@@XZ)
  4. 1>qtlocalpeer.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QLocalServer::qt_metacast(char const *)" (?qt_metacast@QLocalServer@@UAEPAXPBD@Z)
  5. 1>qtlocalpeer.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QLocalServer::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QLocalServer@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
  6. 1>qtlocalpeer.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QLocalServer::hasPendingConnections(void)const " (?hasPendingConnections@QLocalServer@@UBE_NXZ)
  7. 1>qtlocalpeer.obj : error LNK2001: unresolved external symbol "public: virtual class QLocalSocket * __thiscall QLocalServer::nextPendingConnection(void)" (?nextPendingConnection@QLocalServer@@UAEPAVQLocalSocket@@XZ)
  8. 1>qtlocalpeer.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QLocalServer::incomingConnection(unsigned int)" (?incomingConnection@QLocalServer@@MAEXI@Z)
  9. 1>qtlocalpeer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QLocalServer::~QLocalServer(void)" (__imp_??1QLocalServer@@UAE@XZ) referenced in function "public: virtual void * __thiscall QLocalServer::`scalar deleting destructor'(unsigned int)" (??_GQLocalServer@@UAEPAXI@Z)
  10. 1>qtlocalpeer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QString __thiscall QLocalServer::errorString(void)const " (__imp_?errorString@QLocalServer@@QBE?AVQString@@XZ) referenced in function "public: bool __thiscall QtLocalPeer::isClient(void)" (?isClient@QtLocalPeer@@QAE_NXZ)
  11. 1>qtlocalpeer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QLocalServer::listen(class QString const &)" (__imp_?listen@QLocalServer@@QAE_NABVQString@@@Z) referenced in function "public: bool __thiscall QtLocalPeer::isClient(void)" (?isClient@QtLocalPeer@@QAE_NXZ)
  12. 1>qtlocalpeer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual bool __thiscall QLocalSocket::waitForReadyRead(int)" (__imp_?waitForReadyRead@QLocalSocket@@UAE_NH@Z) referenced in function "public: bool __thiscall QtLocalPeer::sendMessage(class QString const &,int)" (?sendMessage@QtLocalPeer@@QAE_NABVQString@@H@Z)
  13. 1>qtlocalpeer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual bool __thiscall QLocalSocket::waitForBytesWritten(int)" (__imp_?waitForBytesWritten@QLocalSocket@@UAE_NH@Z) referenced in function "public: bool __thiscall QtLocalPeer::sendMessage(class QString const &,int)" (?sendMessage@QtLocalPeer@@QAE_NABVQString@@H@Z)
  14. 1>qtlocalpeer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QLocalSocket::~QLocalSocket(void)" (__imp_??1QLocalSocket@@UAE@XZ) referenced in function "public: bool __thiscall QtLocalPeer::sendMessage(class QString const &,int)" (?sendMessage@QtLocalPeer@@QAE_NABVQString@@H@Z)
  15. 1>qtlocalpeer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QLocalSocket::waitForConnected(int)" (__imp_?waitForConnected@QLocalSocket@@QAE_NH@Z) referenced in function "public: bool __thiscall QtLocalPeer::sendMessage(class QString const &,int)" (?sendMessage@QtLocalPeer@@QAE_NABVQString@@H@Z)
  16. 1>qtlocalpeer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QLocalSocket::connectToServer(class QString const &,class QFlags<enum QIODevice::OpenModeFlag>)" (__imp_?connectToServer@QLocalSocket@@QAEXABVQString@@V?$QFlags@W4OpenModeFlag@QIODevice@@@@@Z) referenced in function "public: bool __thiscall QtLocalPeer::sendMessage(class QString const &,int)" (?sendMessage@QtLocalPeer@@QAE_NABVQString@@H@Z)
  17. 1>qtlocalpeer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QLocalSocket::QLocalSocket(class QObject *)" (__imp_??0QLocalSocket@@QAE@PAVQObject@@@Z) referenced in function "public: bool __thiscall QtLocalPeer::sendMessage(class QString const &,int)" (?sendMessage@QtLocalPeer@@QAE_NABVQString@@H@Z)
  18. 1>D:\Projects\test\test\Debug\test.exe : fatal error LNK1120: 16 unresolved externals

 Signature 

Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

August 1, 2011

Maxim Prishchepa Maxim Prishchepa
Hobby Entomologist
93 posts

but if i add just “qtsingleapplication” I have next errors:

  1. 1>Linking...
  2. 1>qtsingleapplication.obj : error LNK2019: unresolved external symbol "public: __thiscall QtLocalPeer::QtLocalPeer(class QObject *,class QString const &)" (??0QtLocalPeer@@QAE@PAVQObject@@ABVQString@@@Z) referenced in function "private: void __thiscall QtSingleApplication::sysInit(class QString const &)" (?sysInit@QtSingleApplication@@AAEXABVQString@@@Z)
  3. 1>qtsingleapplication.obj : error LNK2019: unresolved external symbol "public: bool __thiscall QtLocalPeer::isClient(void)" (?isClient@QtLocalPeer@@QAE_NXZ) referenced in function "public: bool __thiscall QtSingleApplication::isRunning(void)" (?isRunning@QtSingleApplication@@QAE_NXZ)
  4. 1>qtsingleapplication.obj : error LNK2019: unresolved external symbol "public: bool __thiscall QtLocalPeer::sendMessage(class QString const &,int)" (?sendMessage@QtLocalPeer@@QAE_NABVQString@@H@Z) referenced in function "public: bool __thiscall QtSingleApplication::sendMessage(class QString const &,int)" (?sendMessage@QtSingleApplication@@QAE_NABVQString@@H@Z)
  5. 1>D:\Projects\test\test\Debug\test.exe : fatal error LNK1120: 3 unresolved externals

 Signature 

Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

August 1, 2011

Gerolf Gerolf
Mad Scientist
3005 posts

you need all of them, but you should check, whther there are some import/export statements. If yes and you add them to your exe, remove them.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

August 1, 2011

Vass Vass
Gene Splicer
710 posts

Seems like you forgot add library to LIBS var in your .pro file

 Signature 


Vasiliy

August 1, 2011

Gerolf Gerolf
Mad Scientist
3005 posts

In which library should QtSingleApplication be located? AFAIK it is part of the old Qt solutions, which you get as source. You can add it to a library or put the sources directly to your app.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

August 2, 2011

Maxim Prishchepa Maxim Prishchepa
Hobby Entomologist
93 posts

You mean, I need compile QtSolutions like lib, and than add this lib to my project?

 Signature 

Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

August 2, 2011

Gerolf Gerolf
Mad Scientist
3005 posts

Or add the files to your sources and remove the dllexport/import statements in front of the classes

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

August 2, 2011

loladiro loladiro
Gene Splicer
596 posts

Watch out for licensing issues though. AFAIK, Qt solutions is under the LGPL and therefore if you include it directly in your code, it has to be an open source app.

August 2, 2011

Gerolf Gerolf
Mad Scientist
3005 posts

I don’t know how it is now, but some time ago, it was the same license as Qt itself, so if you have a commercial license, it was commercial, etc….

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

August 2, 2011

loladiro loladiro
Gene Splicer
596 posts

It’s still that way (at least if your license agreement includes the Qt Solutions). BTW, for everybody that doesn’t know, the Qt Solutions archive is located at ftp://ftp.qt.nokia.com/qt/solutions/ !

August 3, 2011

Maxim Prishchepa Maxim Prishchepa
Hobby Entomologist
93 posts

Thx, a lot for the help!
I’m compile source like lib and dll than add them to project and include headers to project.

 Signature 

Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

 
  ‹‹ [SOLVED]How to promote QMdiArea in designer?      How to access to Qt class private member ››

You must log in to post a reply. Not a member yet? Register here!