Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Error LNK2001
Forum Updated to NodeBB v4.3 + New Features

Error LNK2001

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 3 Posters 9.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    XerXi
    wrote on last edited by
    #1

    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:

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

    I've readen in a guide of Qt this:

    bq. 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

    SergiBC - Developer

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      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.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vishwajeet
        wrote on last edited by
        #3

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

        Born To Code !!!

        1 Reply Last reply
        0
        • X Offline
          X Offline
          XerXi
          wrote on last edited by
          #4

          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!!

          SergiBC - Developer

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            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.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • X Offline
              X Offline
              XerXi
              wrote on last edited by
              #6

              Ok Volker, thank you VERY MUCH!!

              SergiBC - Developer

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved