Results 1 to 8 of 8

Thread: Best way porting linux software written in C Gtk Ecplipse to C++ Qt Qt Creator?

  1. #1
    Join Date
    Feb 2016
    Posts
    4
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Question Best way porting linux software written in C Gtk Ecplipse to C++ Qt Qt Creator?

    Hi,
    I need to give new life to an old huge and complex software written in C and Gtk+2.0 library on ide Eclipse. The software must be installed on a PC with a custom linux distribution. Software is composed of two projects that works with the logic server-client. I thought that the best choice would be to port the projects in C++, Qt library on Qt Crerator even if I'm quite newbie in C++ and Qt
    I have a lot of work to do because the whole gui was written without a designer and I want to use the Creator Designer to recreate it, very much code will be translated in c++ also to improve the readability, much code are difficult to understand ecc...the problem is to choose the best way to start! I tryed to use the import function of Creator to import the project from Eclipse to try to reuse all the possible old code and minimize the new code but QT Creator only work as editor...so it is not useful. I'm starting to create a new project in Creator for the GUi, as first step, and to write all code from the begin looking the old code as a trace but the huge code to port make me look for another easier and specially faster way to do this job.
    Can anyone suggest me how to proceed to speed this work?
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Best way porting linux software written in C Gtk Ecplipse to C++ Qt Qt Creator?

    It should be possible to import a makefile base project into QtCreator, but also to use Eclipse for the Qt version.

    One migration technique when coming from a different UI technologie is to
    - first remove the old library from the build system, in your case GTK
    - then #ifdef everything that does not compile anymore
    - then work from main() down, porting each #ifdef'ed part as you encounter it

    Rewriting from scratch has the risk that you could miss things that the old applications was able to do or make mistakes when implementing processing logic.
    Especially since this is, as you write, a complex application.

    Cheers,
    _

    If this is something that a company needs to have done, I would even suggest to at least get an offer from one of the Qt service providers who have many years of experience with these kind of migrations.
    Some of them even do such estimates for free.

  3. The following user says thank you to anda_skoa for this useful post:

    Grumpy (5th February 2016)

  4. #3
    Join Date
    Feb 2016
    Posts
    4
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Best way porting linux software written in C Gtk Ecplipse to C++ Qt Qt Creator?

    Thanks for the tips, I was inspired!
    During my experiments i was able to create a project in Qt Creator with both Qt and Gtk+ library included. The next job is to port step by step the old source files trying to build the entire old projet in Qt Creator. Then I'll replace the gkt code with Qt trying to use the Qt designer.
    If this procedure fails I'll do what you suggested

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Best way porting linux software written in C Gtk Ecplipse to C++ Qt Qt Creator?

    During my experiments i was able to create a project in Qt Creator with both Qt and Gtk+ library included.
    Right. Qt Creator is just an IDE, like Eclipse or Visual Studio. You can develop any kind of C++ project in Qt Creator, even though it is especially tuned for working on Qt projects. You mainly need to get your project set up in the kit so it includes all of the right include paths and libraries.

    So you are on the right track. If you like Qt Creator and are more familiar with it than Eclipse, then use it. The Qt Designer integration will certainly be useful when you start replacing GUI components.

  6. The following user says thank you to d_stranz for this useful post:

    Grumpy (8th February 2016)

  7. #5
    Join Date
    Feb 2016
    Posts
    4
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Best way porting linux software written in C Gtk Ecplipse to C++ Qt Qt Creator?

    Hi...I have some bad news!
    Now I have the old project C with gtk that works correctly in a Qt Creator project but...if a try to use Qt (For example any #include of Qt to add a Qt form or function) i receive a lot of build error. Adding the only row #include <QtCore> I receive:
    In file included from ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobjectdefs.h:41:0,
    from ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobject.h:40,
    from ../../../Qt5.5.1/5.5/gcc/include/QtCore/qabstractanimation.h:37,
    from ../../../Qt5.5.1/5.5/gcc/include/QtCore/QtCore:4,
    from ../vgp02/main.c:36:
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qnamespace.h:47:1: error: unknown type name 'QMetaObject'
    const QMetaObject *qt_getQtMetaObject() Q_DECL_NOEXCEPT; // defined in qobject.h (which can't be included here)
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qnamespace.h:58:1: error: unknown type name 'namespace'
    namespace
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qnamespace.h:62:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    Qt {
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qnamespace.h:1715:33: error: expected ')' before ':' token
    Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MouseButtons)
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qnamespace.h:1740:1: warning: data definition has no type or storage class [enabled by default]
    class Q_CORE_EXPORT QInternal {
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qnamespace.h:1740:1: warning: type defaults to 'int' in declaration of 'class' [enabled by default]
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qnamespace.h:1740:21: error: expected ',' or ';' before 'QInternal'
    class Q_CORE_EXPORT QInternal {
    ^
    In file included from ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobjectdefs.h:43:0,
    from ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobject.h:40,
    from ../../../Qt5.5.1/5.5/gcc/include/QtCore/qabstractanimation.h:37,
    from ../../../Qt5.5.1/5.5/gcc/include/QtCore/QtCore:4,
    from ../vgp02/main.c:36:
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobjectdefs_impl.h:50:1: error: unknown type name 'namespace'
    namespace QtPrivate {
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobjectdefs_impl.h:50:21: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    namespace QtPrivate {
    ^
    In file included from ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobject.h:40:0,
    from ../../../Qt5.5.1/5.5/gcc/include/QtCore/qabstractanimation.h:37,
    from ../../../Qt5.5.1/5.5/gcc/include/QtCore/QtCore:4,
    from ../vgp02/main.c:36:
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobjectdefs.h:48:1: error: unknown type name 'class'
    class QByteArray;
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobjectdefs.h:50:1: error: unknown type name 'QArrayData'
    typedef QArrayData QByteArrayData;
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobjectdefs.h:52:1: error: unknown type name 'class'
    class QString;
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobjectdefs.h:131:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    template <typename T>
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobjectdefs.h:134:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    template <typename T1, typename T2>
    ^
    ../../../Qt5.5.1/5.5/gcc/include/QtCore/qobjectdefs.h:247:1: error: unknown type name 'class'
    ...
    ...
    ...
    ... and more and more

    If I only add to the project a Qt designer form class the building is ok, the editor found the Qt library correctly but really... I can't use it.
    So...how can I use Qt in my project????
    Last edited by Grumpy; 4th March 2016 at 12:52.

  8. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Best way porting linux software written in C Gtk Ecplipse to C++ Qt Qt Creator?

    Quote Originally Posted by Grumpy View Post
    Hi...I have some bad news!
    Now I have the old project C with gtk that works correctly in a Qt Creator project but...if a try to use Qt (For example any #include of Qt to add a Qt form or function) i receive a lot of build error. Adding the only row #include <QtCore> I receive:
    In general, adding a module header is not a good idea unless you are making a quick&dirty prototype.

    Did you include that before or after project specific includes?
    What does the compiler call look like?

    Cheers,
    _

  9. #7
    Join Date
    Feb 2016
    Posts
    4
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Best way porting linux software written in C Gtk Ecplipse to C++ Qt Qt Creator?

    hummmm, I did some test and i figured out the problem is to try using Qt in my C files. In a Qt project with one only C files (classic Hello world) if include Qt it returns error, if a rename the file in C++ it is all ok.
    So, the ways I thought are:
    1_convert all my file C in C++...I hope no
    2_convert the main.c in main.cpp, solve the problem of conversion and call the other C file putting extern when the header is called....hoping the extern works.
    3_create a simple new main file in c++ then call all the other files with extern as above
    Best way? Other ways?

    In general, adding a module header is not a good idea unless you are making a quick&dirty prototype.
    Sorry, I don't get what you say? How should I specified the Qt library to use?

  10. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Best way porting linux software written in C Gtk Ecplipse to C++ Qt Qt Creator?

    Quote Originally Posted by Grumpy View Post
    hummmm, I did some test and i figured out the problem is to try using Qt in my C files. In a Qt project with one only C files (classic Hello world) if include Qt it returns error, if a rename the file in C++ it is all ok.
    So the problem was that the file was being compiled by the C compiler which then chocked on the C++ stuff.

    Quote Originally Posted by Grumpy View Post
    So, the ways I thought are:
    1_convert all my file C in C++...I hope no
    Only necessary if you use C++ in these files.

    Quote Originally Posted by Grumpy View Post
    2_convert the main.c in main.cpp, solve the problem of conversion and call the other C file putting extern when the header is called....hoping the extern works.
    Don't see why not, this is how C libraries get called after all

    Quote Originally Posted by Grumpy View Post
    3_create a simple new main file in c++ then call all the other files with extern as above
    I guess that also works.

    Quote Originally Posted by Grumpy View Post
    Sorry, I don't get what you say? How should I specified the Qt library to use?
    Well, an include doesn't have anything to do with a library being used, but if you meant how to use Qt classes, then the best way is to include the headers for those you actually need.

    A module header requires the compiler to read and parse all headers of the module, increasing the build time for no gain.

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 20th February 2013, 19:52
  2. How can I know what QT version a software was written on?
    By gilamran in forum Qt Programming
    Replies: 1
    Last Post: 29th October 2010, 00:15
  3. Linux to Windows Porting
    By qtprogrammer12345 in forum Qt Tools
    Replies: 1
    Last Post: 23rd May 2008, 08:28
  4. Porting Qt Application from Windows to Linux
    By rajeshs in forum Qt Programming
    Replies: 7
    Last Post: 12th July 2007, 14:30
  5. Porting Qt3 linux app to windows qt4
    By Philip_Anselmo in forum Qt Programming
    Replies: 7
    Last Post: 15th May 2006, 19:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.