Compiling one program on Linux and Windows (MingGW) with only one .pro file?
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?
[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.
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
MOC_DIR = .moc
OBJECTS_DIR = .obj
LIBS += -L/usr/lib/i386-linux-gnu/ -lSerialPort
INCLUDEPATH += "C:\Serial-Lib"
LIBS += -L"C:\Serial-Lib" -lSerialPort1
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 :)
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?
No you have to commit your .pro file! Don't keep the Makefile. qmake generates the Makefile from your .pro file!
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.
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!
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...