Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "Undefined symbols in architecture" Compile Error after Refactoring Directories
Forum Updated to NodeBB v4.3 + New Features

"Undefined symbols in architecture" Compile Error after Refactoring Directories

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 869 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.
  • ResistorInTheDarkR Offline
    ResistorInTheDarkR Offline
    ResistorInTheDark
    wrote on last edited by
    #1

    First of all, I've already checked out the other forum threads and stackoverflows on "Undefined symbols in architecture" errors but I felt that they didn't match my error.

    I recently started using Qt for a school project. Along the way I accumulated a bunch of #define macros that I grouped into several headers (.h files). But as the number of constants and macros grew and the number of header files grew, the header files began to cloud the workspace (i.e. the source code).

    So following some examples, I dividing the directory into two folders src and convenience. Directory Hierarchy

    But when building and running, I get this error:
    Compile Error The main.cpp file is under the src directory.

    I'm using Qt Creator 4.6.0 on a MacOS High Sierra v10.13.4.

    Any help would be appreciated.

    jsulmJ 1 Reply Last reply
    0
    • ResistorInTheDarkR ResistorInTheDark

      First of all, I've already checked out the other forum threads and stackoverflows on "Undefined symbols in architecture" errors but I felt that they didn't match my error.

      I recently started using Qt for a school project. Along the way I accumulated a bunch of #define macros that I grouped into several headers (.h files). But as the number of constants and macros grew and the number of header files grew, the header files began to cloud the workspace (i.e. the source code).

      So following some examples, I dividing the directory into two folders src and convenience. Directory Hierarchy

      But when building and running, I get this error:
      Compile Error The main.cpp file is under the src directory.

      I'm using Qt Creator 4.6.0 on a MacOS High Sierra v10.13.4.

      Any help would be appreciated.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @ResistorInTheDark How do your pro files look? Did you rerun qmake and rebuild?
      In C++ you should not use #define for constants that much :-)
      Use const instead and put your constants in name spaces.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • ResistorInTheDarkR Offline
        ResistorInTheDarkR Offline
        ResistorInTheDark
        wrote on last edited by ResistorInTheDark
        #3

        @jsulm
        QtCombinedApp .pro file:

        TEMPLATE = subdirs
        
        SUBDIRS = src convenience
        CONFIG   += ordered
        
        

        convenience .pro file:

        SOURCES += \
            conveniencefile.cpp
        
        HEADERS += \
            appdisplay.h \
            appfont.h \
          (and several other files)
        

        src .pro file:

        QT       += core gui sql
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = QtCombinedApp
        TEMPLATE = app
        DEFINES += QT_DEPRECATED_WARNINGS
        
        SOURCES += \
            main.cpp \
            mainwindow.cpp \
            (other .cpp source files)
        
        HEADERS += \
            mainwindow.h \
            (other .h source files)
        
        RESOURCES += \
            images.qrc
        

        I also tried running qmake, no errors, I believe. I also tried deleting previous builds and rebuilding but that didn't work and generated the linker error.

        1 Reply Last reply
        0
        • ResistorInTheDarkR Offline
          ResistorInTheDarkR Offline
          ResistorInTheDark
          wrote on last edited by
          #4

          @jsulm
          Actually, I just got it to work.
          Apparently I had to set Template = lib and Target = QtCombinedApp.
          I took your other advice and switched over to namespaces and const.

          Thanks for your help and quick reply!

          Pablo J. RoginaP 1 Reply Last reply
          1
          • ResistorInTheDarkR ResistorInTheDark

            @jsulm
            Actually, I just got it to work.
            Apparently I had to set Template = lib and Target = QtCombinedApp.
            I took your other advice and switched over to namespaces and const.

            Thanks for your help and quick reply!

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @ResistorInTheDark if your issue is solved, please mark your post as such. Thanks.

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            ResistorInTheDarkR 1 Reply Last reply
            0
            • Pablo J. RoginaP Pablo J. Rogina

              @ResistorInTheDark if your issue is solved, please mark your post as such. Thanks.

              ResistorInTheDarkR Offline
              ResistorInTheDarkR Offline
              ResistorInTheDark
              wrote on last edited by
              #6

              @Pablo-J.-Rogina
              Done, thanks for the tip. :-)

              1 Reply Last reply
              1

              • Login

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