Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling Qt project into Eclipse using Cygwin compiler

I have downloaded Eclipse with the plug-in to work with C/C++ over Windows. I downloaded Cygwin (base and devel mostly) and works ok for a hello world application.

Now I want to work with Qt. Instead of downloading the framework, I downloaded the libraries "Qt libraries 4.8.0 for Windows (minGW 4.4, 354 MB)", since the other option was the same thing for Visual Studio. I know this could be part of the problem, since it looks to be made only for minGW compiler. If I need to do things in a different way, please tell.

Then I restarted computer, opened Eclipse, wrote this Qt hello world for a new C++ application with Cygwin compiler:

#include <qapplication.h>
#include <qpushbutton.h>

using namespace std;

int main( int argc, char * args[] )
{
    cout << "Here goes!" << endl;

    QApplication app( argc, args );
    QPushButton hello( "Hello World!", 0 );
    hello.resize( 100, 50 );
    app.setMainWidget( &hello );
    hello.show();
    return app.exec();
}

And compiler doesn't find the .h files included. Could it need me to add Qt\bin path to the enviroment variables?

Maybe I should stick to the Qt framework, as it looks like a compiler itself (I really don't know how that works, since yesterday I thought Qt was just a library).

Please tell me what I'm doing wrong (I hope answer to this is not "EVERYTHING" hehe) and how can I make this work.

like image 955
Roman Rdgz Avatar asked Nov 05 '22 03:11

Roman Rdgz


1 Answers

The QT framework implements a meta-language over the top of C++ which QT uses to create its event handling framework (google qt slots and signals for more information). Standard compilers such as G++ don't understand this meta-language so it has to be translated first. You can do this through eclipse by maintaining your own makefile and running QT's Meta-Object-Compiler over the top of the code before you compile it (see this page for more details).

My approach would be to use the QTCreator toolkit to do your compilation, even if you don't use it as your IDE. Also consider using Eclipse and qmake, which if I remember correctly, automatically uses the MOC translater as part of its process.

Good luck!

like image 164
James Ravenscroft Avatar answered Nov 09 '22 06:11

James Ravenscroft