Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [Solved] QtTest project Linker errors on VS2010
Forum Updated to NodeBB v4.3 + New Features

[Solved] QtTest project Linker errors on VS2010

Scheduled Pinned Locked Moved Installation and Deployment
22 Posts 3 Posters 13.2k 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.
  • L Offline
    L Offline
    Link0
    wrote on last edited by
    #12

    That was actually a stab in the dark on my end, back when i thought enumerators were to blame. without it the same thing happened.

    Anyway, i've changed the test to a notably less complex class, and the same linker errors still occur.

    new file in question:
    QConnector.h
    @#ifndef CONNECTORITEM_H
    #define CONNECTORITEM_H

    #include "qgraphicsitem.h"

    class QConnector: public QGraphicsItem
    {
    public:
    QConnector(QGraphicsItem*);
    ~QConnector(void);
    void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
    QRectF boundingRect() const;
    int parX, parY, parW, parH;

    };

    #endif@

    and the test:
    @void GateTest::connTest(){
    QConnector* conn = new QConnector(0);
    QCOMPARE(1,1);
    }@

    That said, which steps do you mean by step by step.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #13

      [quote author="Link0" date="1337076512"]
      That said, which steps do you mean by step by step. [/quote]

      Removing the duality of constructors and seeing what the next issue is.

      If you the same (should be a different now, because you changed classes) linking error, it has something to do with the linking process. Use a small example and pack everything into one source and one header file. This should work. After this separate the files. This may help to localize your problem.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dbzhang800
        wrote on last edited by
        #14

        [quote author="Link0" date="1337068365"]

        Write the original project, including Gate.cpp and Gate.h

        Add a new test project to the original project's solution.

        Added the QtTest module to the test project.

        Add the original project's main folder as a dependency

        Write the toUpper() test and successfully build.

        Write TypeTest(), and get the linker errors.

        [/quote]

        Seems you did something basicly wrong.

        As I said before, if your original project is library, you should link the library to your test project. if not, you should add the source files to your test project.

        "dependency" don't help you to solve the problem. They are still two dependent projects, the only side effect is that when you build your test project, original project will be build first.

        Debao

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Link0
          wrote on last edited by
          #15

          Right you are! Had to add the folder under additional include directories. Apparently no one ever did. Thank you for both of your time.

          (they really need to make VS more straightforward)

          EDIT: wait. dang. i had the relevant code commented in this version. problem persists.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Link0
            wrote on last edited by
            #16

            Some testing later.

            Putting all code into a header file and then including that worked, as soon as i pull the relevant code back into a cpp file, the linker errors return.

            As for the other idea, It's not a library, so i can't link to it statically.
            Attempting to add the .cpp file to the project did not work either, surprisingly, and i'm not entirely sure if i should do that in any case, considering the code changes and such.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #17

              [quote author="Link0" date="1337068365"]
              These are the exact steps i've performed in VS2010 to get here:

              Write the original project, including Gate.cpp and Gate.h

              Add a new test project to the original project's solution.

              Added the QtTest module to the test project.

              Add the original project's main folder as a dependency

              Write the toUpper() test and successfully build.

              Write TypeTest(), and get the linker errors.

              [/quote]

              What do you actually mean with:

              Add the original project's main folder as a dependency

              ??

              Are you adding the files of your original project as "existing items" ?

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • L Offline
                L Offline
                Link0
                wrote on last edited by
                #18

                Visual Studio allows me to define projects as "project dependencies". It also allows me to add them as references, but the point of that is still eluding me as well. (linking errors in that case too)

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  koahnig
                  wrote on last edited by
                  #19

                  The project dependency is for projects with libs. You got 3 projects lib1, lib2 and a main. You change main, it will compile main and link the lib1 and lib2 to main to get exe. You change lib2, lib2 will be compiled and linked with lib1 and main to exe. And whatever mutations.

                  However, you have libs and the outcome, the libs, has to be linked to your project. To my understanding you have no libs, but you got two exe in two projects. For this it does not work. You need to add the source and header files as "existing items" to your test applications. They will be compiled again and linked to your test application.

                  Otherwise you can create a lib project and two application projects. However, you need to link to both application projects the lib. Otherwise it will not work.

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    Link0
                    wrote on last edited by
                    #20

                    Yeah, I've been trying to split the code into a library for the last hour or so. Getting some rather profound linker errors on a specific class so I'll need to look into that.

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      Link0
                      wrote on last edited by
                      #21

                      There, fixed them. Some weird or nonstandard includes throwing a fit. The tests now work as they should, and there's no more linker errors. This time for real, i double checked.

                      Thank you again for your support, both of you.

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        koahnig
                        wrote on last edited by
                        #22

                        Good to know that your problem has been solved.

                        I marked your post as [Solved]. Please do next time.

                        Vote the answer(s) that helped you to solve your issue(s)

                        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