PDA

View Full Version : Best/easiest way to port a MSVS-created Qt application to Linux



Robbie75
5th August 2014, 14:21
Hello,

We have hired an external guy (Visual Studio-user with no Linux experience whatsoever) to program an Qt application which I (Linux user with no Visual Studio experience whatsoever) now have to deploy on Linux.

AFAIK he used Qt designer and some "official" plugin for Visual Studio, so I guess he did the Qt app the "normal" and usual way. Probably "Notepad" is the default name which he also didn't bother to change.

The source code is organized like this, which I assume is normal for Visual Studio:

./Notepad.sdf
./Notepad
./Notepad/GeneratedFiles
./Notepad/GeneratedFiles/ui_notepad.h
./Notepad/GeneratedFiles/qrc_notepad.cpp
./Notepad/GeneratedFiles/Debug
./Notepad/GeneratedFiles/Debug/moc_notepad.cpp
./Notepad/GeneratedFiles/Release
./Notepad/Notepad.vcxproj
./Notepad/notepad.ui
./Notepad/notepad.cpp
./Notepad/notepad.h
./Notepad/Resources
./Notepad/Debug
./Notepad/Debug/notepad.obj
./Notepad/Debug/qrc_notepad.obj
./Notepad/Debug/Notepad.log
./Notepad/Debug/main.obj
./Notepad/Debug/Notepad.tlog
./Notepad/Debug/Notepad.tlog/custombuild.command.1.tlog
./Notepad/Debug/Notepad.tlog/link.command.1.tlog
./Notepad/Debug/Notepad.tlog/CL.read.1.tlog
./Notepad/Debug/Notepad.tlog/link.write.1.tlog
./Notepad/Debug/Notepad.tlog/cl.command.1.tlog
./Notepad/Debug/Notepad.tlog/CL.write.1.tlog
./Notepad/Debug/Notepad.tlog/link.read.1.tlog
./Notepad/Debug/Notepad.tlog/custombuild.write.1.tlog
./Notepad/Debug/Notepad.tlog/Notepad.lastbuildstate
./Notepad/Debug/Notepad.tlog/custombuild.read.1.tlog
./Notepad/Debug/vc120.pdb
./Notepad/Debug/moc_notepad.obj
./Notepad/main.cpp
./Notepad/notepad.qrc
./Notepad/Notepad.vcxproj.filters
./Notepad/Notepad.vcxproj.user
./Win32
./Win32/Debug
./Win32/Debug/Notepad.ilk
./Win32/Debug/Notepad.pdb
./Win32/Debug/Notepad.exe
./Notepad.sln
./Notepad.v12.suo

no Makefile, no build-script, no nothing.

The application does nothing special (display a GUI and read/write a file and that was it) - is there an easy way to create/get a Makefile to compile it on Linux?
Probably I could easily adapt a Makefile from any Qt application that also uses this MSVS directory structure.

Thanks a lot

aamer4yu
5th August 2014, 15:07
This seem to be a simple single directory application.

If you are familiar with Qt apps on Linux, you should face no problem porting it.

You can proceed with 2 approaches -
1) Clean all the MSVC files.. keep only the source files. Then do
qmake -project
This will generate a .pro file which you can use in Qt Creator

2) Make a new project in Qt Creator ( choose the one which is close to your app, or start with empty project)
Keep adding the source, header, resources files to the project.

I hope this helps :)

Robbie75
5th August 2014, 17:59
This seem to be a simple single directory application.

If you are familiar with Qt apps on Linux, you should face no problem porting it.

To my shame, I am (no longer) familiar with Qt apps - it has been quite a while...



You can proceed with 2 approaches -
1) Clean all the MSVC files.. keep only the source files. Then do
qmake -project
This will generate a .pro file which you can use in Qt Creator

2) Make a new project in Qt Creator ( choose the one which is close to your app, or start with empty project)
Keep adding the source, header, resources files to the project.

I hope this helps :)

Unfortunately not (yet) because I need to find a solution that can be automated (i.e. developer sends us zip-file which gets unpacked and compiled automatically).

I went to the ./Notepad directory and ran qmake -project which executed fine, then I generated a makefile by just running qmake, but when I try to build it cannot find all headers. (it cannot find qlabel.h which is in the QtWidgets subdirectory)

qmake --help seems to know the answer:


Mode:
-project Put qmake into project file generation mode
In this mode qmake interprets files as files to
be built,
defaults to *; *; *; *.ts; *.xlf; *.qrc
Note: The created .pro file probably will
need to be edited. For example add the QT variable to
specify what modules are required.


I guess I need to specify the QtWidgets module.

Naive as I am, I tried

echo "QT += QtWidgets" >> Notepad.pro
but that only gets me:


Project ERROR: Unknown module(s) in QT: QtWidgets

After reading:
https://qt-project.org/wiki/Spelling_Module_Names_in_Qt_Documentation

I also tried it with just "Widgets" instead of "QtWidgets" but that didn't work either.

Added after 6 minutes:

OK, it worked with "widgets" (all lowercase), thanks a lot!

stampede
5th August 2014, 19:30
(...)
./Notepad/GeneratedFiles/ui_notepad.h
./Notepad/GeneratedFiles/qrc_notepad.cpp
./Notepad/GeneratedFiles/Debug
./Notepad/GeneratedFiles/Debug/moc_notepad.cpp
./Notepad/GeneratedFiles/Release
(...)
Ugh, he could at least do "make clean" before giving you the sources... Shame on him:mad:

aamer4yu
7th August 2014, 10:56
OK, it worked with "widgets" (all lowercase), thanks a lot!
I guess you are now compiling with Qt 5.x while ur MSVC code was with Qt 4.x ;)