Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to run Unit Test and main project ?

How to run Unit Test and main project ?

Scheduled Pinned Locked Moved Solved C++ Gurus
7 Posts 3 Posters 549 Views
  • 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.
  • S Offline
    S Offline
    Sakhana99
    wrote on 1 Aug 2024, 09:41 last edited by
    #1

    I want to run Unit test for my Qt project and i got an error with the definition of the main and it indicates that one or more multiply defined symbols found :
    main.obj:-1: error: LNK2005: main already defined in test_api.obj
    debug\Pixii_App_1.exe:-1: error: LNK1169: one or more multiply defined symbols found
    Here you found the .pro file :

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 1 Aug 2024, 09:44 last edited by
      #2

      You have to create two separate executables

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      S 1 Reply Last reply 1 Aug 2024, 09:51
      0
      • C Christian Ehrlicher
        1 Aug 2024, 09:44

        You have to create two separate executables

        S Offline
        S Offline
        Sakhana99
        wrote on 1 Aug 2024, 09:51 last edited by
        #3

        @Christian-Ehrlicher How to create them?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 1 Aug 2024, 10:04 last edited by
          #4

          Add a second add_executable() to your CMakeLists.txt.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          S 1 Reply Last reply 1 Aug 2024, 10:27
          3
          • C Christian Ehrlicher
            1 Aug 2024, 10:04

            Add a second add_executable() to your CMakeLists.txt.

            S Offline
            S Offline
            Sakhana99
            wrote on 1 Aug 2024, 10:27 last edited by
            #5

            @Christian-Ehrlicher I'm using qmake i had .pro file

            1 Reply Last reply
            0
            • C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 1 Aug 2024, 10:32 last edited by
              #6

              Then create a subdirecory for your test and create a new pro file in there.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 1 Aug 2024, 11:51 last edited by
                #7

                Hi,

                The best way to do it is to create a subdirs project as described here. Even though it shows it for an application with libraries, the same concept applies to adding tests. You can check the Qt 5 sources, they are using that concept there.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2
                • S Sakhana99 has marked this topic as solved on 11 Sept 2024, 16:07

                7/7

                1 Aug 2024, 11:51

                • Login

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