compilation error

Started by moris, August 05, 2008, 02:16:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

moris

i have error in compilation:
engine\activity.cpp:115: error: 'class QStringList' has no member named 'find'

i don't know how can i resolve this problem!

Liviu Lalescu

#1
Please tell me, what medium are you using? Windows/Mac/Linux, gcc which version, g++ which version, Qt which version?

I am using gcc (g++) 4.3.1 and Qt 4.4.0 and everything is OK. Also, I could compile on gcc 4.1.3 + Qt 4.3.2 and many other mediums.

Did you try to modify the project? What modifications did you do?

To solve your problem, you can use the function "contains(QString)" instead, in all the places you get error. But please let me know your platform, I would like to fix this error in official FET.

moris

I use Windows, MinGW GCC and Qt 4.4.1.

I have create new project c++ in eclipse, i have add engine source to project and i have add all include and librerie of QT to project.

when i build the project i have this result:


**** Build of configuration Debug for project CTT ****

**** Internal Builder is used for build               ****
g++ -IC:\Qt\4.4.1\include -IC:\Qt\4.4.1\include\QtCore -IC:\Qt\4.4.1\include\QtGui -IC:\Qt\4.4.1\include\Qt -O0 -g3 -Wall -c -fmessage-length=0 -oengine\subject.o ..\engine\subject.cpp
g++ -IC:\Qt\4.4.1\include -IC:\Qt\4.4.1\include\QtCore -IC:\Qt\4.4.1\include\QtGui -IC:\Qt\4.4.1\include\Qt -O0 -g3 -Wall -c -fmessage-length=0 -oengine\spaceconstraint.o ..\engine\spaceconstraint.cpp
g++ -IC:\Qt\4.4.1\include -IC:\Qt\4.4.1\include\QtCore -IC:\Qt\4.4.1\include\QtGui -IC:\Qt\4.4.1\include\Qt -O0 -g3 -Wall -c -fmessage-length=0 -oengine\room.o ..\engine\room.cpp
g++ -IC:\Qt\4.4.1\include -IC:\Qt\4.4.1\include\QtCore -IC:\Qt\4.4.1\include\QtGui -IC:\Qt\4.4.1\include\Qt -O0 -g3 -Wall -c -fmessage-length=0 -oengine\teacher.o ..\engine\teacher.cpp
g++ -IC:\Qt\4.4.1\include -IC:\Qt\4.4.1\include\QtCore -IC:\Qt\4.4.1\include\QtGui -IC:\Qt\4.4.1\include\Qt -O0 -g3 -Wall -c -fmessage-length=0 -oengine\timetable.o ..\engine\timetable.cpp
g++ -IC:\Qt\4.4.1\include -IC:\Qt\4.4.1\include\QtCore -IC:\Qt\4.4.1\include\QtGui -IC:\Qt\4.4.1\include\Qt -O0 -g3 -Wall -c -fmessage-length=0 -oengine\activity.o ..\engine\activity.cpp
..\engine\activity.cpp: In member function `bool Activity::searchStudents(const QString&)':
..\engine\activity.cpp:115: error: 'class QStringList' has no member named 'find'
..\engine\activity.cpp: In member function `void Activity::computeInternalStructure(Rules&)':
..\engine\activity.cpp:211: error: no matching function for call to `QObject::tr(QString)'
C:/Qt/4.4.1/include/QtCore/../../src/corelib/kernel/qobject.h:117: note: candidates are: static QString QObject::tr(const char*, const char*)
C:/Qt/4.4.1/include/QtCore/../../src/corelib/kernel/qobject.h:117: note:                 static QString QObject::tr(const char*, const char*, int)
..\engine\activity.cpp:240: error: no matching function for call to `QObject::tr(QString)'
C:/Qt/4.4.1/include/QtCore/../../src/corelib/kernel/qobject.h:117: note: candidates are: static QString QObject::tr(const char*, const char*)
C:/Qt/4.4.1/include/QtCore/../../src/corelib/kernel/qobject.h:117: note:                 static QString QObject::tr(const char*, const char*, int)
..\engine\activity.cpp:272: error: no matching function for call to `QObject::tr(QString)'
C:/Qt/4.4.1/include/QtCore/../../src/corelib/kernel/qobject.h:117: note: candidates are: static QString QObject::tr(const char*, const char*)
C:/Qt/4.4.1/include/QtCore/../../src/corelib/kernel/qobject.h:117: note:                 static QString QObject::tr(const char*, const char*, int)
Build error occurred, build is stopped
Time consumed: 12860  ms.  

Liviu Lalescu

You are right, these are small mistakes of mine.

To solve them: for instance in activity.cpp, replace for instance:

return this->teachersNames.find(teacherName)!=this->teachersNames.end();

by

return this->teachersNames(contains(teacherName));

To solve the QObject::tr(QString) thing:

replace

s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting...")).arg(this->id);

by

s=QObject::tr("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting...").arg(this->id);

Why I don't solve these by myself: I don't get any warnings on them and don't know exactly where they are. This is not the main reason. The main reason is that any change must be carefully tested, and I have no human testers to help me.

I think you will get some more errors, different from these 2. I think the reason is that you have not enabled Qt3 support. I have written code like that with Qt3, which was accepted, and now you have to allow Qt3 code. See last lines in src/interface/interface.pro.

I advise you to keep the skeleton of current fet and only remove the interface which you don't need (I think you will need the file fet.cpp from interface and maybe timetableview*.cpp, or some variables defined globally here).

Maybe you could try to install KDevelop, if they have a version for Windows. It manages Qt projects.

Please try to see the structure of src/interface/interface.pro and fet.pro and src/src.pro files. Maybe you can work with that.

I will be here and I'll try to help you some more, if you have more questions.

The command is simple to compile using mingw, just run qmake and make. So, why cannot you keep the current structure, using qt make? You can open/modify files in any editor, and add them in interface.pro.

Liviu Lalescu

I just saw now, the function "find" for QStringList is a a Qt3Support4 function. So you need to enable support for Qt3 to be able to compile such code. Probably the same with QObject::tr(QString) thing.

The Qt3 support is enabled in the last lines in file src/interface/interface.pro. I don't know how to do it manually. Probably they have a #define somewhere.

moris

i have used Qt Eclipse and i have succeed the compilation of FET (original source), but when i delete forms from project i have problems with reference:

C:/fet-5.6.0/src/interface/../engine/timetableexport.cpp:133: undefined reference to `students_schedule_ready'
./..\..\tmp\timetableexport.o(.text+0x76273):C:/fet-5.6.0/src/interface/../engine/timetableexport.cpp:133: undefined reference to `teachers_schedule_ready'
./..\..\tmp\timetableexport.o(.text+0x76280):C:/fet-5.6.0/src/interface/../engine/timetableexport.cpp:133: undefined reference to `rooms_schedule_ready'
./..\..\tmp\timetableexport.o(.text+0x76984):C:/fet-5.6.0/src/interface/../engine/timetableexport.cpp:169: undefined reference to `best_solution'
C:/fet-5.6.0/src/interface/../engine/import.cpp:575: undefined reference to `centerWidgetOnScreen(QWidget*)'
./..\..\tmp\import.o(.text+0x137f5): In function `ZN6Import21importCSVActivityTagsEv':
C:/fet-5.6.0/src/interface/../engine/import.cpp:1082: undefined reference to `centerWidgetOnScreen(QWidget*)'

the source list is:

SOURCES += fet.cpp \
   ../engine/activity.cpp \
   ../engine/solution.cpp \
   ../engine/timetable.cpp \
   ../engine/rules.cpp \
   ../engine/import.cpp \
   ../engine/export.cpp \
   ../engine/generate_pre.cpp \
   ../engine/timeconstraint.cpp \
   ../engine/spaceconstraint.cpp \
   ../engine/studentsset.cpp \
   ../engine/teacher.cpp \
   ../engine/subject.cpp \
   ../engine/activitytag.cpp \
   ../engine/room.cpp \
   ../engine/building.cpp \
   ../engine/timetable_defs.cpp \
   ../engine/generate.cpp \
   ../engine/timetableexport.cpp



how can i resolve this problem!

Liviu Lalescu

#6
For the teachers_schedule_ready & others, please define them somewhere as boolean variables. When they need to be known, in a cpp file, write "extern bool t..._s..._r...".

For center widget on screen, use the routine from src/interface/centerwidgetonscreen.cpp, or make it a dummy routine (this routine simply takes a widget and centers it on the screen, so you can simply write empty code instead).

Amelk

Hello Liviu! I have an error in
engine\generate.cpp:2270: error: 'time' was not declared in this scope


Liviu Lalescu

QuoteHello Liviu! I have an error in
engine\generate.cpp:2270: error: 'time' was not declared in this scope


Please add this at the beginning of the file: "#include <ctime>" (without quotes, after line 28).

Where are you compiling, on what platform? Official 5.11.0? Or a modified version? Windows, Linux, Mac? What compiler?

It seems it is a minor mistake of mine, I added now the include to necessary files.

Please tell me if you are getting this message in other files (write all of them here) and add the same fix to them. Now you can compile OK?

Amelk

I am compiling Official 5.11.0 , using Qt 4.5.2 (2009.03)  on Windows XP SP3

Amelk

I have error: /timetablegeneratemultipleform.cpp:79: error: 'time' was not declared in this scope

Liviu Lalescu

#11
What compiler? The MinGW that comes with Qt?

Also tell me, the fix I wrote is OK? In what other files besides generate.cpp do you also need to apply the fix?

Apply the fix also to timetablegeneratemultiple.cpp, then.

Amelk

Compiler: MinGW
I am fixed error, and next compilation without errors.
Thanks.

Liviu Lalescu

Thank you for bug report!

I want to ask you this: could you please compile latest snapshot and tell me if it compiles OK? Just compile, don't use it yet, it is untested.

The address (for now): http://lalescu.ro/liviu/Backup-fet/fet-5.12.0-snapshot-4-dec-2009-18_24.tar.bz2

Amelk

I compile latest snapshot (5.12.0) without errors.