hello,
Is it possible to create an executable for Linux and windows using the same QT code in Linux with Eclipse integration or is it necessary to install QT Creator in my Linux machine?
Waiting for reply
Thanks in advance
vincat.
hello,
Is it possible to create an executable for Linux and windows using the same QT code in Linux with Eclipse integration or is it necessary to install QT Creator in my Linux machine?
Waiting for reply
Thanks in advance
vincat.
Of course, it is possible to install Qt Creator in Linux. The same Qt code can be used to compile in Linux/Win32/Mac. However, you should be using platform specific code only within:
#ifdef Q_OS_WIN32
qDebug() << "Executable files end in .exe";
#endif
There are other defines for other operating systems. If you do so, you are safe and you can bet it is cross-platform code. :-)
Please refer http://www.qtsoftware.com/downloads and download the Qt SDK for Linux/X11. It contains Qt Creator, Assistant, Designer, et cetera.
For Eclipse, there's an official plugin.
Qt Eclipse Integration for C++
The Eclipse plugin can be used to create programs using any Qt version since 4.1.0.
Some time ago I was trying to do this, and I found resources about cross-compiling here: http://silmor.de/29. Finally I compiled win32 version under Windows, because of lack of time, but it should be possible.
If you want to build a windows binary on linux you need to cross-compile. This means you need to have a windows cross-compiler installed plus the libraries you are linking with built with the cross compiler. For a basic Qt program this means you need at least a cross-compiled Qt.
Cross-compiling has nothing to do with Eclipse or Qt Creator. I don't think both support cross compiling out of the box but I guess you could make them to do so.
executable in windows does not work in linux and vice versa. you can do this:
#ifdef Q_WS_X11
QString *OS=new QString("Linux");
std::cout << OS->toStdString() << std::endl;
#endif
#ifdef Q_WS_WIN
QString *OS=new QString("Windows");
std::cout << OS->toStdString() << std::endl;
#endif
#ifdef Q_WS_MACX
QString *OS=new QString("Mac");
std::cout << OS->toStdString() << std::endl;
#endif
Been lookiing at this myself and found this article http://www.ce3c.be/152-cross-compiling-qt-c-for-windows-on-linux/