User forums > Help

[Solved *Really] CodeBlock can't find QT4 libs

(1/3) > >>

sqlpython:
   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:

--- 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();
 }

--- End code ---
Some Build errors below..

--- Code: ---/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 ===|

--- End code ---

MortenMacFly:
I don't know where and how you "installed" QT into, but all you have to do is to adjust the QT4 global variable, that the .include tag points to where your QT's base folder for header files is (/usr/include, or /usr/local/include for example) and the .lib tag points to where the linker can find the library files (/usr/lib, or /usr/local/lib for example). As QT has changed the base folders for its libraries from major version to major version you have to understand that the (hard-coded) settings of the wizard might not match your configuration.
Another solution would be if you compile the app on the command line and then "transfer" the settings to the IDE.
That's all I can tell - again: It depends on where / how you installed QT into.

Next time please also post your full compiler log which helps to analyse what's going wrong (see my sig how to enable that).

sqlpython:
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

--- Code: ---/usr/share/qt4/include/Qt 
/usr/share/qt4/include/Qt/Qt3Support
/usr/share/qt4/include/Qt/QtAssistant
--- End code ---
.....and so on for 18 Qt subdirectories

 Lastly, You must start CodeBlocks as sudo / su user

--- Code: ---gksudo codeblocks
--- End code ---

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

sqlpython:
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..



--- Code: ----------------- 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
 

--- End code ---

sqlpython:
Ok... Thank You..
I believe you have now pointed me in the correct direction which allows me (based on all the above info) to have the compiler find the QT4 libs running Code::Blocks as my User and not root user.

I just had to find the correct combination of dirs referenced by variable qt4

In the Code::Blocks Settings -> Globalvariables
Choosing to effect in the pop up window the variable qt4
I list the dirs this way...which compiles and works
the dirs are added this way including quotes  " "
  Remember all that read this my qt4 deb installed to   /usr/share/qt4/

base  "/usr"

nclude "/usr/share/qt4/include"

lib  "/usr/lib"

obj  "/usr/bin"

Navigation

[0] Message Index

[#] Next page

Go to full version