PDA

View Full Version : How do I compile for linux on windows?



waitingforzion
27th December 2009, 04:03
OK, I have two questions which I am having a hard time finding the answers to.

I have the Qt SDK installed on Windows, but I do not have anything Qt related installed on Linux. (I am running Linux in an emulator). I want to know, is it possible to build a Linux application using the tools I've installed on the windows platform? If so, how can I do it?

Furthermore, I had recently sent a very simple Qt Application along with the necessary dlls in the same directory to my sister for testing. She reported to me that the program would not run. Even on my system, Qt executables always terminate with an error when the necessary dlls are not in the same directory. From my experience and from what I read, I figured all that was needed is those dlls included with the executable. Apparently that's not the case. Does this mean that for a user to run my qt apps they have to download and install the entire Qt Framework? I'm pretty sure I didn't have Qt installed before I installed Google Earth, and it ran perfectly. So clearly I'm lacking some insight. Can someone help me with this?

wysota
27th December 2009, 09:40
I have the Qt SDK installed on Windows, but I do not have anything Qt related installed on Linux. (I am running Linux in an emulator). I want to know, is it possible to build a Linux application using the tools I've installed on the windows platform? If so, how can I do it?
Not with the ones you currently have. You need a cross-compiler to be able to do that (use your favourite search engine for more details). Alternatively run Linux as a virtual machine on your Windows installation and compile there, it might prove easier than setting up a complete cross-compiling toolchain.


Furthermore, I had recently sent a very simple Qt Application along with the necessary dlls in the same directory to my sister for testing. She reported to me that the program would not run. Even on my system, Qt executables always terminate with an error when the necessary dlls are not in the same directory. From my experience and from what I read, I figured all that was needed is those dlls included with the executable. Apparently that's not the case.
Can you quote the exact error?


Does this mean that for a user to run my qt apps they have to download and install the entire Qt Framework?
No, of course not. You just need the proper libs.

ChrisW67
27th December 2009, 20:48
Not with the ones you currently have. You need a cross-compiler to be able to do that (use your favourite search engine for more details). Alternatively run Linux as a virtual machine on your Windows installation and compile there, it might prove easier than setting up a complete cross-compiling toolchain.
I'll second this. While it is possible to build a cross-compiling set of tools and libraries on Windows to target Linux, it is far more effort than it is likely to be worth unless you are trying to create some sort of build farm for a team to share (even then it may be easier to go Linux > Windows). Install Qt in your Linux virtual machine and build your source there. Place your code into a source control system to allow easy transfer of changes (and there will be some if this is your first attempt) back and forth between Windows and Linux working copies.

Tanuki-no Torigava
27th December 2009, 22:13
It doesn't worth to use cross-compile. Build it on a Linux right inside your VM. For the same project tools on both Windows and Linux you can use SVN (for common code base) and QMake/CMake utilities.

ChrisW67
28th December 2009, 07:51
Furthermore, I had recently sent a very simple Qt Application along with the necessary dlls in the same directory to my sister for testing. She reported to me that the program would not run. Even on my system, Qt executables always terminate with an error when the necessary dlls are not in the same directory.
Make sure you are bundling the correct DLLs form the Qt SDK directories. You want the DLL files from the /Qt/2009.03/Qt/bin and plugins directories (or equiv) and not the files in /Qt/2009.03/bin. The latter files are the runtime bundled with the Qt Creator and not the files your application is built against.

To compile and link application using wxWidgets library, you have to add or change the following locations in the generated project properties.
wxWidgets?

You may need to put conditional sections into your PRO file to account for path differences if you have external libraries involved (like Qwt, QCA or wwWidgets) or other differences. Something like:

# Platform specific tweaks
unix {
QWTPATH = /usr/local/qwt-5.2.0
}
win32 {
QWTPATH = C:\Qwt-5.2.0
}
INCLUDEPATH += $$QWTPATH/include
LIBS += -L$$QWTPATH/lib -lqwt