February 24, 2011

XerXi XerXi
Lab Rat
36 posts

error LNK2001

 

Hello,

I’m developing a Windows Mobile 6.5 application with MSVisual Studio 2008 Professional and Qt Visual Studio add-in installed.

I have a class with slots and signals, so I put Q_OBJECT in its header. If I build the project it compiles but doesn’t link fine. I’m getting this errors:

  1. (...)error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl(...)
  2. (...)error LNK2001: unresolved external symbol "public: virtual void * __cdecl(...)
  3. (...)error LNK2001: unresolved external symbol "public: virtual int __cdecl(...)

I’ve readen in a guide of Qt this:

If this ever happens to you, run qmake again to update the makefile, then
rebuild the application.

But I don’t know what I must do if I work with MSVisual Studio 2008 Professional and Qt Visual Studio add-in installed.

Thank you very much,
SBC

 Signature 

SergiBC - Developer

5 replies

February 24, 2011

Volker Volker
Ant Farmer
5428 posts

You should reimport your .pri file. You have split your qmake project into .pro for the general settings, and .pri containing the file lists (HEADERS, SOURCES, FORMS), do you?

Otherwise you must add the moc steps for the newly QObjectifyed class manually.

February 25, 2011

vishwajeet vishwajeet
Lab Rat
83 posts

I have faced the same issue but regenerating Makefile and rebuilding project solved the issue

 Signature 

Born To Code !!!

February 25, 2011

XerXi XerXi
Lab Rat
36 posts

I didn’t add new files (classes and headers) to .pro file….I did it and run qmake another time and it has worked.

But one thing, I didn’t have a .pri file, why is it necessary?

Thank you very much!!

 Signature 

SergiBC - Developer

February 25, 2011

Volker Volker
Ant Farmer
5428 posts

It’s not really necessary, but works well with the Visual Studio AddIn.

If you import a .pro file, the VS project will be regenerated from scratch and you are loosing all modifications you did manually (optimizations, special path settings and so on). Most times you will have added new classes and forms to your project and want to pull them into the VS project. This is where the “import .pri into current project” of the AddIn comes in. It leaves your settings as is and just add/remove the sources and adds the moc and uic steps if necessary.

The import step is also necessary, if you add the Q_OBJECT macro to a class later on.

If you are on the command line and use nmake to compile your project, all this “magic” is not necessary then; just re-run qmake.

February 25, 2011

XerXi XerXi
Lab Rat
36 posts

Ok Volker, thank you VERY MUCH!!

 Signature 

SergiBC - Developer

 
  ‹‹ SQLITE Database in Project      Gui application failed to start ››

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