Author Topic: Error compiling QT application  (Read 48447 times)

Offline Sputnik

  • Single posting newcomer
  • *
  • Posts: 6
Error compiling QT application
« on: July 28, 2005, 05:33:39 pm »
Hi, I'm triying to compile a QT 4 application, but the compiler is returning the following error:

QtGui: No such file or directory

the line that throws that error is a simple include:

#include <QtGui>

I've read in the trolltech site that the including methodology has changed for the latest QT version, but I'm lost... of course, the file I'm trying to include exists... Maybe I have to configure something in code::blocks?

Thanks in advance

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Error compiling QT application
« Reply #1 on: July 28, 2005, 05:46:35 pm »
Make sure that you added the QT include directory to your compiler directories.

Offline Sputnik

  • Single posting newcomer
  • *
  • Posts: 6
Re: Error compiling QT application
« Reply #2 on: July 28, 2005, 06:03:54 pm »
Yes, the directories are included... if I include a normal .h file of QT it is included and the program compiles, that issue only happens with the include files without extension... I think these are new to QT4 and contains a lot of normal includes

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Error compiling QT application
« Reply #3 on: July 28, 2005, 06:31:32 pm »
Um... I'm not sure why this happens... try making sure the case of the included files is correct. In your include statement, there are some uppercase characters. Who knows? It might just work.

Wait! I have an idea to test. Instead of compiling, generate a makefile and try to run the makefile from outside codeblocks. I think that this isn't a codeblocks problem, but a compiler / config issue.

Offline Sputnik

  • Single posting newcomer
  • *
  • Posts: 6
Re: Error compiling QT application
« Reply #4 on: July 28, 2005, 07:06:34 pm »
mmmm... if I do it outside codeblocks, using make in the command line, the program compiles and runs correctly... any ideas of what's happening and what should I do?

Thx for your efforts! they're really appreciatted :)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Error compiling QT application
« Reply #5 on: July 28, 2005, 07:24:52 pm »
OK. Now, inside codeblocks, in the compiler options (don't remember exactly where), you must use the "compile using makefiles" option (dig around, it should be in there somewhere). Try recompiling and post the result here.

This is VERY important! We need your feedback on this issue to confirm the bug.
Thanks.

Offline Sputnik

  • Single posting newcomer
  • *
  • Posts: 6
Re: Error compiling QT application
« Reply #6 on: July 28, 2005, 07:34:32 pm »
Well, I think the option you're talking about is called "build method"; located in settings->compiler->others, so I selected "work with makefiles"... and the same errors happened.
I forgot... I'm working on WinXP Pro.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Error compiling QT application
« Reply #7 on: July 28, 2005, 07:57:59 pm »
So, if you build inside codeblocks, errors happen, but outside it's fine?

Please create a small test case (hello world?) and submit the bug report at sourceforge (of course, including the code for your test case!).

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Error compiling QT application
« Reply #8 on: July 28, 2005, 09:11:18 pm »
Does the new QT project template build and run correctly?

Yiannis.
Be patient!
This bug will be fixed soon...

Offline Sputnik

  • Single posting newcomer
  • *
  • Posts: 6
Re: Error compiling QT application
« Reply #9 on: July 29, 2005, 10:21:50 am »
Yes, it does. As I said before, it seems to have trouble with those special header files without extension (i.e. <qtGui>)
Reading the QT documentation, I found that you have to follow these steps to compile an app:

qmake -project    ->This creates a project file (.pro)
qmake                ->Creates a platform-specific makefile based on the project file
make

So I went to project configuration and typed all in project properties->project's build options->commands, into pre-build steps text area, and also selected "make" as the build method in global compiler options->other; then I tried to build the project and, after a while without response, I stopped the process, receiving an "unspecified error" alert. After that, I'm unable to try to compile again because that option remains disabled.

Hope this helps to find what's happening...

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Error compiling QT application
« Reply #10 on: July 29, 2005, 11:09:35 am »
If you will be generating the makefile yourself (through qmake), you will also need to do two more things:

1) Set build method to "make" in global compiler options (you did that).
2) Go to "Project->Properties" and set the Makefile to be the generated makefile's name (relative to the project .cbp file) and check "This is a custom makefile" so C::B will use it as-is.

Yiannis.
Be patient!
This bug will be fixed soon...

Offline Sputnik

  • Single posting newcomer
  • *
  • Posts: 6
Re: Error compiling QT application
« Reply #11 on: July 29, 2005, 01:52:05 pm »
Well, I think I finally found the bug... it seems that the pre-build steps are only executed if you have "invoke compiler directly" as the build method; if not, these steps are simply ignored so the makefile is not created.
So, the process to build a QT app with makefiles is nowadays as follows (using Code::blocks QT project template):

1 - Go to QT app properties and check the "this is a custom makefile" checkbox.
     Now click on project's build options button, select the default brach at left and, in commands area, type the following into pre-build-steps:

     qmake -project
     qmake

2 - Make sure you have selected "invoke compiler directly" as the build method in settings->compiler->other.

3 - Compile the project; if you have includes of type "#include <QtGui>" those won't be found, returning errors. The makefile is now created.

4 - Change again the build method, now it must be "Work with makefiles" and try to compile again; it must work now.

One final thing: QT creates two additional directories where it puts debug and release builds. In order to use the "run" button in Code::blocks to execute the built app, you have to change the directory where the executable is in "properties->targets->output filename".

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Error compiling QT application
« Reply #12 on: August 03, 2005, 07:18:14 pm »
So, the pre and post build steps don't work with makefiles? That sounds like a bug. Please report it at sourceforge.

Thanks :)

e-axis

  • Guest
Re: Error compiling QT application
« Reply #13 on: August 16, 2005, 12:49:29 am »
Good time.

I had the same problem and particularly solve it.

Compiler cant find #include <QtGui> because it cant find standard path to included file. In my case Qt Application set path $QTDIR/include/Qt/QtGui (look at Project->Build Option -/ Directories -/ Compiler) and the real path was $QTDIR/include/QtGui. And so for all.

The REAL problem is a linking.
Qt uses *.moc files, but how can I tell compiler to generate them, compile and link?  :(

All hopes is to use Makefiles.

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Error compiling QT application
« Reply #14 on: August 28, 2005, 05:09:07 pm »
I I've used Codeblocks up to 1.0 beta 7 and then stuck to that version. Now I downloaded the RC 1-1 and wow!!! support for qt 4 open source edition. Since you see the post in this thread you realize that I have the same problems.

1 - Go to QT app properties and check the "this is a custom makefile" checkbox.
     Now click on project's build options button, select the default brach at left and, in commands area, type the following into pre-build-steps:
     qmake -project
     qmake
2 - Make sure you have selected "invoke compiler directly" as the build method in settings->compiler->other.
3 - Compile the project; if you have includes of type "#include <QtGui>" those won't be found, returning errors. The makefile is now created.
4 - Change again the build method, now it must be "Work with makefiles" and try to compile again; it must work now.

I have solved the above issue by creating two tool entries in code blocks:
First:
Name : generate .pro file
Executable: C:\Qt\4.0.0\bin\qmake.exe (note must be full path)
Parameters: -project
Working Directory: ${PROJECT_DIR}
Second:
Same as above changing parameters field to -makefile and name to generate makefile.
The build method, should  be "Work with makefiles" and in QT app properties the "this is a custom makefile" checkbox should be checked as quoted above. When you first build your project you should run the tools once (first the generate .pro file then generate makefile) and work as usual, you will only need to run the tools again if you for instance add new files etc.
The thing now is that doing the above we totally override CodeBlocks (we just use it as a fancy editor) and its a pity not being able to take advantage of all the features it provides.

Compiler cant find #include <QtGui> because it cant find standard path to included file. In my case Qt Application set path $QTDIR/include/Qt/QtGui (look at Project->Build Option -/ Directories -/ Compiler) and the real path was $QTDIR/include/QtGui. And so for all.
The REAL problem is a linking.
Qt uses *.moc files, but how can I tell compiler to generate them, compile and link?  :(
All hopes is to use Makefiles.

e-axis you are 100% right. Firstly to the code::blocks team this problem with the folders should be looked into. Secondly qt generates "intermediate" files source files using the moc (meta object compiler). And if you are looking for the real qt experience you must also use the designer thus support .ui files etc. etc. I am navigating through the options I am given and I'll get back to you. In the mean time I will email to the qt mailing list I' m subscribed to,  to suggest this beautiful IDE, believe it or not it's the only one to support Qt open source edition.
I will get back with this issue, as this IDE is a neccessesity to me...
Life would be so much easier if we could just look at the source code.