Is it possible to create an executable on Linux for both Linux and Windows using the same Qt code with Eclipse? Or is it necessary to install Qt Creator on my Linux machine?
是否可以在Linux上使用与Eclipse相同的Qt代码在Linux和Windows上创建可执行文件?或者是否有必要在我的Linux机器上安装Qt Creator?
5 个解决方案
#1
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.
如果你想在linux上构建一个windows二进制文件,你需要交叉编译。这意味着您需要安装Windows交叉编译器以及使用交叉编译器构建的链接库。对于基本的Qt程序,这意味着您至少需要一个交叉编译的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.
交叉编译与Eclipse或Qt Creator无关。我不认为两者都支持交叉编译开箱即用,但我想你可以让它们这样做。
#2
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:
当然,可以在Linux中安装Qt Creator。可以使用相同的Qt代码在Linux / Win32 / Mac中进行编译。但是,您应该仅在以下范围内使用特定于平台的代码:
#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.
请参考http://www.qtsoftware.com/downloads并下载适用于Linux / X11的Qt SDK。它包含Qt Creator,Assistant,Designer等。
#3
0
Some time ago I was trying to do this, and I found resources about cross-compiling here: http://silmor.de/qtstuff.cross.php. Finally I compiled win32 version under Windows, because of lack of time, but it should be possible.
前段时间我试图这样做,我在这里找到了有关交叉编译的资源:http://silmor.de/qtstuff.cross.php。最后我在Windows下编译了win32版本,因为时间不够,但它应该是可能的。
#4
-1
For Eclipse, there's an official plugin.
对于Eclipse,有一个官方插件。
Qt Eclipse Integration for C++
Qt Eclipse Integration for C ++
The Eclipse plugin can be used to create programs using any Qt version since 4.1.0.
Eclipse插件可用于从4.1.0开始使用任何Qt版本创建程序。
#5
-3
executable in windows does not work in linux and vice versa. you can do this:
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
#1
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.
如果你想在linux上构建一个windows二进制文件,你需要交叉编译。这意味着您需要安装Windows交叉编译器以及使用交叉编译器构建的链接库。对于基本的Qt程序,这意味着您至少需要一个交叉编译的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.
交叉编译与Eclipse或Qt Creator无关。我不认为两者都支持交叉编译开箱即用,但我想你可以让它们这样做。
#2
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:
当然,可以在Linux中安装Qt Creator。可以使用相同的Qt代码在Linux / Win32 / Mac中进行编译。但是,您应该仅在以下范围内使用特定于平台的代码:
#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.
请参考http://www.qtsoftware.com/downloads并下载适用于Linux / X11的Qt SDK。它包含Qt Creator,Assistant,Designer等。
#3
0
Some time ago I was trying to do this, and I found resources about cross-compiling here: http://silmor.de/qtstuff.cross.php. Finally I compiled win32 version under Windows, because of lack of time, but it should be possible.
前段时间我试图这样做,我在这里找到了有关交叉编译的资源:http://silmor.de/qtstuff.cross.php。最后我在Windows下编译了win32版本,因为时间不够,但它应该是可能的。
#4
-1
For Eclipse, there's an official plugin.
对于Eclipse,有一个官方插件。
Qt Eclipse Integration for C++
Qt Eclipse Integration for C ++
The Eclipse plugin can be used to create programs using any Qt version since 4.1.0.
Eclipse插件可用于从4.1.0开始使用任何Qt版本创建程序。
#5
-3
executable in windows does not work in linux and vice versa. you can do this:
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