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

Sputnik

  • Guest
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.

Sputnik

  • Guest
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.

Sputnik

  • Guest
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.

Sputnik

  • Guest
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: 4315
    • 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...

Sputnik

  • Guest
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: 4315
    • 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...

Sputnik

  • Guest
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 can’t find “#include <QtGui>” because it can’t 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 can’t find “#include <QtGui>” because it can’t 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.

Offline Code Medic

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: Error compiling QT application
« Reply #15 on: June 16, 2006, 07:17:53 pm »
is there a better support for Qt4 Open Source edition in the latest nightly build?
has it been solved? bcoz, i'm facing the same situation.

about the "#include <QtGui>" directive, isnt that a standard directive??
like "#include <vector>" ..??

cheerio
« Last Edit: June 16, 2006, 07:19:53 pm by codemedic »

JuTs

  • Guest
Re: Error compiling QT application
« Reply #16 on: July 02, 2006, 01:26:49 pm »
I'm not sure, but I didn't notice any problem with this kind of include.

But I have problems with the Makefile.
I tried to add
Code
qmake -project
qmake

to the pre-build steps but that doesn't work. The Makefile is generated correctly but it doesn'e seem to be used. I get error of this kind

Quote
.objs/cannonfield.o : In the function "CannonField::setAngle(int)":cannonfield.cpp:(.text+0x11c): undefined reference to « CannonField::angleChanged(int)   »



lfm

  • Guest
Re: Error compiling QT application
« Reply #17 on: July 03, 2006, 02:55:34 pm »

CJ

  • Guest
Re: Error compiling QT application
« Reply #18 on: August 03, 2006, 12:59:59 pm »
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...

Are there any news regarding this problem?

CU
CJ

sethjackson

  • Guest
Re: Error compiling QT application
« Reply #19 on: August 03, 2006, 05:54:49 pm »
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...

Are there any news regarding this problem?

CU
CJ

Yes. You will need a recent nightly build.

CJ

  • Guest
Re: Error compiling QT application
« Reply #20 on: August 03, 2006, 10:14:55 pm »
Yes. You will need a recent nightly build.

The Unicode build won't start, complaining about a missing dll point, the ANSI build starts and seems to be configured right but I get the same

undefined reference to `vtable for LCDRange'

errors like in the 1.0 RC2 on the Qt tutorial examples unless I manualy invoke the moc.

CU
CJ

sethjackson

  • Guest
Re: Error compiling QT application
« Reply #21 on: August 04, 2006, 03:31:11 am »
Yes. You will need a recent nightly build.

The Unicode build won't start, complaining about a missing dll point, the ANSI build starts and seems to be configured right but I get the same

undefined reference to `vtable for LCDRange'

errors like in the 1.0 RC2 on the Qt tutorial examples unless I manualy invoke the moc.

CU
CJ

Right this is expected (AFAIK). Search the forum for the QtWorkBench plugin. ;)
« Last Edit: August 04, 2006, 03:42:23 am by sethjackson »

CJ

  • Guest
Re: Error compiling QT application
« Reply #22 on: August 04, 2006, 10:23:42 am »
Right this is expected (AFAIK). Search the forum for the QtWorkBench plugin. ;)

Already did so yesterday but the plugin isn't on the web page, the attachements in the forum are deleted and the thread only mentions frequently that a new version is uploaded but no URL as far as I can see.

Thanks for your help!

CU
CJ

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Error compiling QT application
« Reply #23 on: August 04, 2006, 11:50:53 am »
Already did so yesterday but the plugin isn't on the web page, the attachements in the forum are deleted and the thread only mentions frequently that a new version is uploaded but no URL as far as I can see.

Yop (the author) has sent me the files again and I will host them in a permanent place. I 'll make an announcement when it's ready.
Be patient!
This bug will be fixed soon...

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Error compiling QT application
« Reply #24 on: August 04, 2006, 12:02:09 pm »
Right this is expected (AFAIK). Search the forum for the QtWorkBench plugin. ;)
... the plugin isn't on the web page, the attachements in the forum are deleted and the thread only mentions frequently that a new version is uploaded but no URL as far as I can see.

in the meanwhile you can download the plugin sources from here
http://tiwag.cb.googlepages.com/qtworkbench-0.4.2.alpha.zip

you have to build it yourself, create a folder in the CB source tree,
for example, i have it set up in : CB/trunk/src/plugins/_other/
and copy all files and subdirectories there, so that you have the following tree
CB/trunk/src/plugins/_other/QtWorkbench
CB/trunk/src/plugins/_other/QtWorkbench/res
CB/trunk/src/plugins/_other/QtWorkbench/src

then open CB/trunk/src/plugins/_other/QtWorkbench/qtworkbench.cbp
with CodeBlocks and build it. it will be built in CB/trunk/src/devel/share/CodeBlocks/plugins

after you run the CB/trunk/src/update.bat (on Windows) it will be copied to
the CB working version tree CB/trunk/src/output

i tested it with Qt 4.1.2 and generally it works fine.





CJ

  • Guest
Re: Error compiling QT application
« Reply #25 on: August 04, 2006, 12:02:29 pm »
Yop (the author) has sent me the files again and I will host them in a permanent place. I 'll make an announcement when it's ready.

Thanks :)

CU
CJ