7

是否可以使用与 Eclipse 相同的 Qt 代码在 Linux 上为 Linux 和 Windows 创建可执行文件?或者是否有必要在我的 Linux 机器上安装 Qt Creator?

4

5 回答 5

3

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.

于 2009-06-08T07:52:09.060 回答
0

前段时间我试图这样做,我在这里找到了有关交叉编译的资源:http: //silmor.de/qtstuff.cross.php。最后我在windows下编译了win32版本,因为时间不够,不过应该是可以的。

于 2009-06-08T07:25:16.667 回答
0

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.

于 2009-06-08T06:30:50.457 回答
-1

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.

于 2009-06-08T06:39:09.160 回答
-3

Windows 中的可执行文件在 linux 中不起作用,反之亦然。你可以这样做:

#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
于 2010-06-03T07:02:57.007 回答