See Post #9 if you are impatiant
Hi All
1st Post... We are attempting to migrate Qt4 work to Code::Blocks IDE.
Up until now we have worked in Qtcreator and or Codelite.
Really like the extra features of CodeBlocks and would like to use it for our QT4 projects.
We can't seem to create a working QT4 template from the Wizard.
We have attempted to effect the (qt4) Global variable in Settings.
Experimented with Base of /usr, /usr/share/qt4
Using both of those as base then choose the appropriate sub dir for include and lib
We even tried creating a link in /usr/share/qt4 for /usr/lib
The variable appears in the Wizard as $(#qt4)
So, we then manually typed /usr which does work but leads me wondering that w/o the variable can the include and lib dirs be located.
Once we choose /usr as the Base the Q4 Template will be made.
However if we try to build the Simple Hello World I get errors that point to the fact the #include Headers can't be located by the compiler.
Note if I was to just perform a Console project using C++ headers such as <iostream> etc not problem.
The compiler finding the QT4 libraries seem to be the problem...
BTW:
A base QT GUI project works in Codelite
..and of course as per it's design QTcreator works.
We searched here and otherwise can't find a solution that works..
though we have found a number of non working suggestions...
App Test Code:
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.resize(200, 100);
hello.show();
return app.exec();
}
Some Build errors below..
/home/sqlpython/.codeblocks/Projects/HelloAgain/CodeBlockHello/main.cpp|1|error: QApplication: No such file or directory|
/home/sqlpython/.codeblocks/Projects/HelloAgain/CodeBlockHello/main.cpp|2|error: QPushButton: No such file or directory|
/home/sqlpython/.codeblocks/Projects/HelloAgain/CodeBlockHello/main.cpp||In function ‘int main(int, char**)’:|
/home/sqlpython/.codeblocks/Projects/HelloAgain/CodeBlockHello/main.cpp|6|error: ‘QApplication’ was not declared in this scope|
/home/sqlpython/.codeblocks/Projects/HelloAgain/CodeBlockHello/main.cpp|6|error: expected ‘;’ before ‘app’|
/home/sqlpython/.codeblocks/Projects/HelloAgain/CodeBlockHello/main.cpp|8|error: ‘QPushButton’ was not declared in this scope|
/home/sqlpython/.codeblocks/Projects/HelloAgain/CodeBlockHello/main.cpp|8|error: expected ‘;’ before ‘hello’|
/home/sqlpython/.codeblocks/Projects/HelloAgain/CodeBlockHello/main.cpp|9|error: ‘hello’ was not declared in this scope|
/home/sqlpython/.codeblocks/Projects/HelloAgain/CodeBlockHello/main.cpp|12|error: ‘app’ was not declared in this scope|
||=== Build finished: 8 errors, 0 warnings ===|
Well *Solved with an asterick....
This solution requires that some SEARCH modifications be made to the Compiler Debugger Search setting
Solution:
Anyway my solution turned out to be to start CodeBlocks and go to Menus
Settings -> Compiler Debugger Settings -> Global Compiler Settings -> [Search Dir] Tab -> [Compiler] subTab
.......And ADD the following dir to search
although the last 18 are sub dir of the 1st the must each be listed manually for this to work
/usr/share/qt4/include/Qt
/usr/share/qt4/include/Qt/Qt3Support
/usr/share/qt4/include/Qt/QtAssistant
.....and so on for 18 Qt subdirectories
Lastly, You must start CodeBlocks as sudo / su user
AND Voila! The Qt4 apps compile....
Just I don't like running apps as sudo...
Example, some clueless user writes an app with an rm command in it that runs without needing a sudo..
Hmmmmm....
Sorry... Posted too quickly..
THanks for the reply..
Qt4 installed in
/usr/share/qt4 per a .deb file
inside the dir is a link to
/usr/include/qt4
I have tried early on working through the Global Variable qt4 in the settings as you suggested ... However I get this log..
Which then works if I run CodeBLocks as Root user..
-------------- Build: Debug in QtFixed ---------------
g++ -Wall -g -I/usr/include -I/usr/include/QtGui -c /home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp -o obj/Debug/main.o
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:1:24: error: QApplication: No such file or directory
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:2:17: error: QFont: No such file or directory
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:3:23: error: QPushButton: No such file or directory
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp: In function ‘int main(int, char**)’:
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:7: error: ‘QApplication’ was not declared in this scope
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:7: error: expected ‘;’ before ‘app’
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:9: error: ‘QPushButton’ was not declared in this scope
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:9: error: expected ‘;’ before ‘quit’
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:11: error: ‘quit’ was not declared in this scope
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:12: error: ‘QFont’ has not been declared
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:12: error: ‘QFont’ was not declared in this scope
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:14: error: ‘QObject’ has not been declared
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:14: error: ‘clicked’ was not declared in this scope
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:14: error: ‘SIGNAL’ was not declared in this scope
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:14: error: ‘app’ was not declared in this scope
/home/sqlpython/.codeblocks/Projects/QtFixed/QtFixed/main.cpp:14: error: ‘SLOT’ was not declared in this scope
Process terminated with status 1 (0 minutes, 0 seconds)
15 errors, 0 warnings
Thanks for your input....
This is a bit frustrating...Please be aware that I am an IDE user since 1985 beginning with my Days using Borland products..
I have never to my memory ever had problems installing compiler dir lib location in Windows nor Linux.
....Currently I can run the same code in QtCreator as well as Codelite without issue..
Also I can convert the code with pyuic and then run against the same lib with PyQt in Eric and Spyder IDEs w/o issue..
.....only Code::Blocks rejects the paths...and or libs as User yet works as Root/Super user..
Anyhow, I completely uninstalled Code::BLocks cleaned out dirs and Reinstalled Code::Blocks.....
Once again entered my References to the Compiler directive for the $(#qt) variable...
as above the same directories...
So I started the Default QT project via the Wizard..
All went well until the compile...
Code::Blocks now throws up errors by opening up the config file in the Qt lib sub dir...
It reads the file in the QtGui /include/QtGui/ dir
This runs an if clause which runs through the dir contents as Check of contents to present the libs to compiler inquiries..
It begins like so.... and goes on to run through the contents of the dir...
There are 18 Qt sub dir and each one has one of these ref files
#ifndef QT_QTGUI_MODULE_H
#define QT_QTGUI_MODULE_H
#include <QtCore/QtCore>
#include "qabstractitemdelegate.h"
#include "qabstractitemview.h"
#include "qabstractproxymodel.h"
This file is then opened on the editor next to main.cpp..
and an error is throw on the 3rd line not finding <QtCore/QTCore> as a dir so I tried <QtCore> as the second item is a file not a dir... But no help then drills into the qcoreapplication.h and disagrees with some contents there.... [out of breath]
I am about read to accept that Code::Blocks is not Qt4 compatible.. I have searched the forums here and I see Qt4 setup issues going back to at least 2006 without any satisfactory solution..
Here is my dir tree if it gives you any ideas...
Thanks for patience...
sqlpython@debian7:/usr/share/qt4$ ls
bin include phrasebooks q3porting.xml translations
doc mkspecs plugins QtCore
sqlpython@debian7:/usr/share/qt4$ tree -d /usr/share/qt4/include
/usr/share/qt4/include
├── Qt
├── Qt3Support
├── QtCore
├── QtDBus
├── QtDeclarative
├── QtDesigner
├── QtGui
├── QtHelp
├── QtNetwork
├── QtOpenGL
├── QtScript
├── QtScriptTools
├── QtSql
├── QtSvg
├── QtTest
├── QtUiTools
├── QtWebKit
├── QtXml
└── QtXmlPatterns
19 directories
sqlpython@debian7:/usr/share/qt4$ tree -d /usr/include/qt4
/usr/include/qt4
├── Qt
├── Qt3Support
├── QtCore
├── QtDBus
├── QtDeclarative
├── QtDesigner
├── QtGui
├── QtHelp
├── QtNetwork
├── QtOpenGL
├── QtScript
├── QtScriptTools
├── QtSql
├── QtSvg
├── QtTest
├── QtUiTools
├── QtWebKit
├── QtXml
└── QtXmlPatterns