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. Compiling one program on Linux and Windows (MingGW) with only one .pro file?
Forum Updated to NodeBB v4.3 + New Features

Compiling one program on Linux and Windows (MingGW) with only one .pro file?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 18.3k 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.
  • M Offline
    M Offline
    medvedm
    wrote on last edited by
    #1

    I have a GUI program that I build and run on Linux, on Eclipse with the (now no longer supported) Eclipse plug in.

    Can I, on a Windows machine, using Eclipse/Qt Plugin/MinGW compile the exact same .pro file? I understand about setting TARGET and DESTDIR, those are easy. But the makefiles generated on linux have all kind of directories /usr/.... that obviously don't exist on Windows, and it points to the wrong mkspec.

    I know that on QtCreator there is a feature called shadow builds that do what I want, but QtCreator is not an option for me. Can I do what I'm asking? Or do I need to make a whole seperate Eclipse Qt Project that references the other one's code?

    Thanks,
    M

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      [quote author="medvedm" date="1362604944"]Can I, on a Windows machine, using Eclipse/Qt Plugin/MinGW compile the exact same .pro file? [/quote]

      Maybe, maybe not. qmake will generate a suitable Makefile for the platform it is on. You only need to worry about paths and platform dependencies you have built into your PRO file.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Serenity
        wrote on last edited by
        #3

        Don't worry: If your .pro-file is "OS independent", than you can use it also in window as in Unix.

        For example I use this pro file for a windows and linux build:
        @TARGET = target
        TEMPLATE = app
        INCLUDEPATH +=
        MOC_DIR = .moc
        OBJECTS_DIR = .obj
        unix {
        LIBS += -L/usr/lib/i386-linux-gnu/ -lSerialPort
        }
        win32 {
        INCLUDEPATH += "C:\Serial-Lib"
        LIBS += -L"C:\Serial-Lib" -lSerialPort1
        }

        Input@

        So as you can see, you have to make only your .pro file independent of any OS. In this case, I used another library, which I include for windows and linux. Qt or better qmake creates the Makefile from your pro file and set the right dependencies with the right path. So don't worry :)

        I also only commit .pro file with code and never the Makefile :)

        1 Reply Last reply
        0
        • M Offline
          M Offline
          medvedm
          wrote on last edited by
          #4

          Ahh... so when you build with qmake, because you don't commit the .pro file, it regenerates them on windows or linux or whatever.

          Lets say I wanted to keep the makefiles in the source control, then what to do?

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

            No you have to commit your .pro file! Don't keep the Makefile. qmake generates the Makefile from your .pro file!

            1 Reply Last reply
            0
            • M Offline
              M Offline
              medvedm
              wrote on last edited by
              #6

              Yeah, I get that and my .pro file is in SVN. I just was curious if there was a way to CM the makefiles as well.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                medvedm
                wrote on last edited by
                #7

                BTW, this does work and work very well. I had to make some very minor updates to my .pro file (to put the execs in different directories), remove the makefiles from CM, and tidy up some shared code that did some OS specific stuff, but after that, I can compile the same software on Windows and Linux with no code changes!

                Boo yah.

                BTW, I get that this is what is advertised by Qt. It is just cool to see it work so well! Now, if only QtCreator was a better IDE...

                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