PDA

View Full Version : Problem Compiling - "`QtValidLicenseForCoreModule"?



Jimmy2775
6th August 2007, 01:36
Hello - I'm trying an exercise using 4.3.0, Open Source, on WinXP.

I've downloaded the Qt code, ran configure and accepted the license. Still, when I try and compile the application I get the following output:

mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/projects/primecalc'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_
THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\Qt\4.3.0\include\QtCore" -I"..\..\Qt\4.3.0\include\QtCore" -I"..\..\Qt\4.3.0\in
clude\QtGui" -I"..\..\Qt\4.3.0\include\QtGui" -I"..\..\Qt\4.3.0\include" -I"." -I"..\..\Qt\4.3.0\include\ActiveQt" -I"de
bug" -I"." -I"..\..\Qt\4.3.0\mkspecs\win32-g++" -o debug\main.o main.cpp
In file included from ../../Qt/4.3.0/include/QtCore/qcoreevent.h:1,
from ../../Qt/4.3.0/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:28,
from ../../Qt/4.3.0/include/QtCore/qcoreapplication.h:1,
from ../../Qt/4.3.0/include/QtGui/../../src/gui/kernel/qapplication.h:27,
from ../../Qt/4.3.0/include/QtGui/qapplication.h:1,
from ../../Qt/4.3.0/include/QtGui/QApplication:1,
from main.cpp:2:
../../Qt/4.3.0/include/QtCore/../../src/corelib/kernel/qcoreevent.h:32: error: `QtValidLicenseForCoreModule' does not na
me a type
mingw32-make[1]: *** [debug\main.o] Error 1
mingw32-make[1]: Leaving directory `C:/projects/primecalc'
mingw32-make: *** [debug] Error 2

I've Googled around to see what could be causing this but everything indicates the problem is related to not having run 'configure'. I've even checked the qconfig.h file to ensure it contains the correct definition: # define QT_EDITION QT_EDITION_OPENSOURCE and it does. Here is the code I am trying to compile - perhaps I've done something wrong...

main.cpp

#include "primedialog.h"
#include <QApplication>

int main( int argc, char* argv[] )
{
QApplication app( argc, argv );
PrimeDialog view;
view.show();
return app.exec();
}

primedialog.h

#ifndef PRIMEDIALOG_H
#define PRIMEDIALOG_H

#include <QWidget>

class QLabel;
class QLineEdit;
class QProgressBar;

class PrimeDialog : public QWidget
{
Q_OBJECT
public:
PrimeDialog();
~PrimeDialog();

int getFromValue();
int getToValue();

private:
QLabel *m_FromLabel;
QLabel *m_ToLabel;
QLabel *m_AnswerLabel;
QLineEdit *m_FromLineEdit;
QLineEdit *m_ToLineEdit;
QLineEdit *m_AnswerLineEdit;
QProgressBar *m_ProgressBar;

public slots:
void disableLineEdits();
void enableLineEdits();
void setAnswerLabelValue( QString newValue );
void updateProgressBar( int percentage );

}

#endif

primedialog.cpp


#include "primedialog.h"

#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QProgressBar>

PrimeDialog::PrimeDialog()
: QWidget()
{
m_FromLabel = new QLabel( "From", this );
m_ToLabel = new QLabel( "To", this );
m_AnswerLabel = new QLabel( "Answer", this );
m_FromLineEdit = new QLineEdit( this );
m_ToLineEdit = new QLineEdit( this );
m_AnswerLineEdit = new QLineEdit( this );
m_ProgressBar = new QProgressBar( this );

QHBoxLayout *fromLayout = new QHBoxLayout;
QHBoxLayout *toLayout = new QHBoxLayout;
QHBoxLayout *answerLayout = new QHBoxLayout;
QHBoxLayout *progressLayout = new QHBoxLayout;

fromLayout->addWidget( m_FromLabel );
fromLayout->addWidget( m_FromLineEdit );
toLayout->addWidget( m_ToLabel );
toLayout->addWidget( m_ToLineEdit );
answerLayout->addWidget( m_AnswerLabel );
answerLayout->addWidget( m_AnswerLineEdit );
progressLayout->addWidget( m_ProgressBar );

QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout( fromLayout );
mainLayout->addLayout( toLayout );
mainLayout->addLayout( answerLayout );
mainLayout->addLayout( progressLayout );

setLayout( mainLayout );
setWindowTitle( "Enter info here" );
setFixedHeight( sizeHint().height() );
}

int PrimeDialog::getFromValue()
{
return m_FromLineEdit->text().toInt();
}

int PrimeDialog::getToValue()
{
return m_ToLineEdit->text().toInt();
}

void PrimeDialog::disableLineEdits()
{
m_FromLineEdit->setReadOnly( true );
m_ToLineEdit->setReadOnly( true );
}

void PrimeDialog::enableLineEdits()
{
m_FromLineEdit->setReadOnly( false );
m_ToLineEdit->setReadOnly( false );
}

void PrimeDialog::setAnswerLabelValue( QString newValue )
{
m_AnswerLineEdit->setText( newValue );
}

void PrimeDialog::updateProgressBar( int percentage )
{
//TODO:
}

As always, any suggestions as to how I could resolve this are greatly appreciated. I have compiled the Qt source (main and debug) without issue, and have even compiled another small application without a problem. I'm hoping I've missed something here.

Jimmy

marcel
6th August 2007, 01:42
It is the include order from main.cpp.
QApplication.h has to be first always( even before precompiled headers ).

Regards

Jimmy2775
6th August 2007, 04:19
Not the most intuitive error message, I must say, but that has resolved that particular issue. Thanks Marcel.

I've put the QApplication include at the top of main.cpp, but now I get the following compiler error:

mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/projects/primecalc'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_
THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\Qt\4.3.0\include\QtCore" -I"..\..\Qt\4.3.0\include\QtCore" -I"..\..\Qt\4.3.0\in
clude\QtGui" -I"..\..\Qt\4.3.0\include\QtGui" -I"..\..\Qt\4.3.0\include" -I"." -I"..\..\Qt\4.3.0\include\ActiveQt" -I"de
bug" -I"." -I"..\..\Qt\4.3.0\mkspecs\win32-g++" -o debug\main.o main.cpp
main.cpp:5: error: new types may not be defined in a return type
main.cpp:5: error: extraneous `int' ignored
main.cpp: In function `PrimeDialog qMain(int, char**)':
main.cpp:9: error: conversion from `int' to non-scalar type `PrimeDialog' requested
mingw32-make[1]: *** [debug\main.o] Error 1
mingw32-make[1]: Leaving directory `C:/projects/primecalc'
mingw32-make: *** [debug] Error 2

Once again, any ideas are appreciated. I don't see how I'm trying to convert an int to my PrimeDialog class.

Jimmy

Jimmy2775
6th August 2007, 05:09
Ahhh yes - forgot the ; at the end of the header file.