Whats are the steps to execute a program in linux which is developed in windows?



  • I am using "Qt Creator 2.3.0 ,Based on Qt 4.7.4 (32 bit)"
    I developed a GUI program which executes correctly in windows now i want to get its executable, to run in linux. Please tell me how can i do that?



  • Install Qt SDK in Linux then compile your program's source code.



  • A Qt application is platform-independent in a way that it can be compiled everywhere, not run. This means, that you'll have to compile your application for every platform you want to support, which results in one binary for each platform (not one binary for all platforms).

    As Yasin already said just download the Qt SDK for Linux and compile it there.



  • And one more question: If I use Visual Studio and have *.sln and *.vcproj files, how can I fast export it to Qt Creator. My solution is to make new project in Qt Creator and then add all *.ccp and *.h files. So it there any conversation tools or any tricks to make it faster?



  • If your program doesn't use any specific Windows characteristic, you only have to install Qt Creator with the package manager of your Linux distribution:

    Ubuntu:

    aptitude install qtcreator

    Fedora:

    yum install qt-creator

    ...finally just compile your project.

    Bold: I mean with this, by example: lets say your program accesses a folder, a typical Windows direction would be:

    C:\Users\SomeUser

    ...the analog folder on Linux is:

    /home/SomeUser

    ...as you can see the addresses are not equal, so you have to adapt this part of your code, other wise your project will compile fine, but you will get a run time error.



  • [quote author="Anticross" date="1326869815"]And one more question: If I use Visual Studio and have *.sln and *.vcproj files, how can I fast export it to Qt Creator. My solution is to make new project in Qt Creator and then add all *.ccp and *.h files. So it there any conversation tools or any tricks to make it faster?[/quote]
    Go to your source code directory and type <code>qmake -project</code>.



  • [quote author="Anticross" date="1326869815"]And one more question: If I use Visual Studio and have *.sln and *.vcproj files, how can I fast export it to Qt Creator. My solution is to make new project in Qt Creator and then add all *.ccp and *.h files. So it there any conversation tools or any tricks to make it faster?[/quote]

    If you use the visual studio plugin, there's a menu entry to export the project to a .pro file.



  • The two biggest (well, "biggest" is too big a word) hurdles I encountered were:

    -) Source file case (Linux is case sensitive, Windows is not)

    A good approach is to use only lowercase file names.

    -) How you write #include directives (some things that work on Windows don't work on Linux)

    e.g.
    @#include <QString.h> @
    might work in Windows, it will not work in Linux.
    @#include <QString> @
    will work on both.



  • Even though window file system handles file path in-casesensitively, it keeps the case of each character.
    I believe there is no such QString.h in Qt header directory but only qstring.h(and 'QString' without extension)



  • But
    @#include <QString.h>@
    does work in Windows, using the Qt SDK.

    I know for a fact it does not work in Linux. Hence the warning.

    I have seen people, especially those working on Visual Studio, using ways of including Qt headers that do not work in Linux.
    Example:

    @#include <QtCore/qpair.h>@
    does not work in Linux

    @#include <QPair>@
    does work.



  • Of course it does work, because QString.h and qstring.h (and as well QSTRING.H or qStRiNg.H) are all the same file. On Unix/Linux these are different files. On the Mac the filesystem usually (default settings) is case-IN-sensitive either, as on Windows.

    The recommended way to include directives in C++ in general is

    @
    #include <QString>
    @

    i.e. using case (if used in the API docs) and without a trailing .h - this is expected to be portable across all platforms.

    If you do differently, you might run into troubles.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.