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. Avoiding name clashes with Qmake if two files in project have the same name.
QtWS25 Last Chance

Avoiding name clashes with Qmake if two files in project have the same name.

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 568 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
    sandro4912
    wrote on last edited by
    #1

    I have the following folder structure:

    /linux

    • Process.h

    Process.h

    So in the folder Linux and before it there is a Process.cpp. Now when I try to compile this I run in trouble because it looks like QMake threats this like if the file Process.h shows up 2 times.

    From the code Both classes in the files are separated by a namespace. One is simply

    class Process.

    The otherone with a namespace:

    class Linux::Process

    I had similar expediences with Visual Studio. There you could tell the build system to build with the paths your project is organized to not have this clash.

    Any chance I can also solve that issue in qmake? Or do I really have to rename one file?

    jsulmJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @sandro4912 said in Avoiding name clashes with Qmake if two files in project have the same name.:

      Or do I really have to rename one file?

      Rename the file to not get into trouble sooner or later with whatever build system you use (and by yourself).

      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
      3
      • S Offline
        S Offline
        sandro4912
        wrote on last edited by
        #3

        I thought with the folder system and the namespace I can avoid long names. Is there really no way?

        Why have namespaces when they are not usefull.

        1 Reply Last reply
        0
        • S sandro4912

          I have the following folder structure:

          /linux

          • Process.h

          Process.h

          So in the folder Linux and before it there is a Process.cpp. Now when I try to compile this I run in trouble because it looks like QMake threats this like if the file Process.h shows up 2 times.

          From the code Both classes in the files are separated by a namespace. One is simply

          class Process.

          The otherone with a namespace:

          class Linux::Process

          I had similar expediences with Visual Studio. There you could tell the build system to build with the paths your project is organized to not have this clash.

          Any chance I can also solve that issue in qmake? Or do I really have to rename one file?

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

          @sandro4912 said in Avoiding name clashes with Qmake if two files in project have the same name.:

          Now when I try to compile this I run in trouble because it looks like QMake threats this like if the file Process.h shows up 2 times.

          Shows up where?
          What exactly is the problem?

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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sandro4912
            wrote on last edited by
            #5

            The error states that Process.o already exists when he trys to generate the second Process.o

            mrjjM 1 Reply Last reply
            0
            • S sandro4912

              The error states that Process.o already exists when he trys to generate the second Process.o

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @sandro4912
              hi
              yes since all output goes to the same folder, having files with the same names will overwrite each other .o file.
              So basically its just a bad idea that will come back and hurt you. :)

              • Why have namespaces when they are not usefull.

              They are used to avoid name clash for types internally.
              Not to protect from name clash on files.

              at one point in time one could do

              CONFIG += object_parallel_to_source
              or
              CONFIG += object_with_source

              https://stackoverflow.com/questions/9450225/why-does-qmake-put-all-object-o-files-to-one-directory

              But Moc dont understand this so if Qt based classes, its a no go.

              • I thought with the folder system and the namespace I can avoid long names. Is there really no way?
                What long names ?
              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