Author Topic: Help setting up Code::BLocks with QT4  (Read 10687 times)

drake1983

  • Guest
Help setting up Code::BLocks with QT4
« on: February 09, 2007, 05:29:05 am »
Hi everybody, I have used C::B in Microsoft Windows XP to develop small projects and I think it's a wonderful IDE, but now I have to make a big project in Linux, using QT4 and C++, so I have downloaded and installed C::B for Ubuntu ( my distro ), I also have installed QT4 and other IDE ( KDevelop ), but I want to use C::B but I can't make it work with the Project Wizard for QT4, it ask for the global variable qt and I don't know how to setup and configure all the enviroment ( including compiler) to use QT4 libs and qmake. I have read a lot of posts in this forum but I didn't find the solution, some people says that QT wizard have troubles with QT4, other people recommends to use QTWorkbrench ( a pluging ).

I will be very grateful if somebody with Linux and C::B teach me step by step How to setup the global variable QT for C::B , configure the compiler to use qmake ( I have heard that is necessary ) to make QT4 Projects.

And please forgive my English I'm currently learning the language, my native language is Spanish, but don't be afraid to answer my questions in English, I'll understand.
Thanks!!!

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Help setting up Code::BLocks with QT4
« Reply #1 on: February 09, 2007, 09:51:47 am »
If I remember correctly, the qt wizard supports only windows for the moment.
But fear not. In linux things are easier than in windows. Just create a new console project, go to "Project->Build options", select the project node in the tree at the left, add `qt-config --cxxflags` in "Other compiler options" and `qt-config --libs` in "Other linker options" (notice the backticks). This should do the trick.

Just keep in mind that I don't use qt so the commands I gave you above might even be wrong. If that happens, someone with more qt knowledge than me will step up and correct me (hopefully) :).
Be patient!
This bug will be fixed soon...

drake1983

  • Guest
Re: Help setting up Code::BLocks with QT4
« Reply #2 on: February 09, 2007, 07:15:11 pm »
Thanks for your answer, I have made what you say, and I tried  to compile and run this Hello World sample program, but it doesn't work, this is the ouput of C::B:
Code
-------------- Build: Debug in aaa ---------------
Compiling: main.cpp
g++: qt-config: No existe el fichero ó directorio
g++: qt-config: No existe el fichero ó directorio
cc1plus: error: no se reconoce la opción de línea de comando "-fcxxflags"
cc1plus: error: no se reconoce la opción de línea de comando "-fcxxflags"
Process terminated with status 1 (0 minutes, 1 seconds)
0 errors, 0 warnings

Anyways, thanks so much for your answer and nice job with the IDE, it's something beautiful, really.
I'll keep in touch waiting for help.

« Last Edit: February 09, 2007, 07:20:11 pm by drake1983 »

drake1983

  • Guest
Re: Help setting up Code::BLocks with QT4
« Reply #3 on: February 17, 2007, 06:56:33 am »
Hi people,  I have found and added the include directories of qt  in Codeblocks, so I can compile the main.cpp  withouth  problems, but I can't run the program, I have the following errors:

Code
-------------- Build: Debug in qt4 ---------------
g++ -L/usr/lib  -o ./qt4 obj/Debug/main.o   `qt-config --libs` 
/bin/sh: qt-config: orden no encontrada
obj/Debug/main.o: En funcion `main':/home/rferrer/Codeblocks/qt4/main.cpp:7: referencia a `QApplication::QApplication(int&, char**)' sin definir
:/home/rferrer/Codeblocks/qt4/main.cpp:8: referencia a `QPushButton::QPushButton(QString const&, QWidget*)' sin definir
:/home/rferrer/Codeblocks/qt4/main.cpp:12: referencia a `QApplication::exec()' sin definir
:/home/rferrer/Codeblocks/qt4/main.cpp:12: referencia a `QPushButton::~QPushButton()' sin definir
:/home/rferrer/Codeblocks/qt4/main.cpp:12: referencia a `QPushButton::~QPushButton()' sin definir
:/home/rferrer/Codeblocks/qt4/main.cpp:12: referencia a `QApplication::~QApplication()' sin definir
:/home/rferrer/Codeblocks/qt4/main.cpp:12: referencia a `QApplication::~QApplication()' sin definir
obj/Debug/main.o: En funciñon `~QString':/usr/include/qt4/QtCore/qstring.h:687: referencia a `QString::free(QString::Data*)' sin definir
obj/Debug/main.o: En funciñon `QString':/usr/include/qt4/QtCore/qstring.h:304: referencia a `QString::shared_null' sin definir
:/usr/include/qt4/QtCore/qstring.h:305: referencia a `QString::fromAscii(char const*, int)' sin definir
:/usr/include/qt4/QtCore/qstring.h:305: referencia a `QString::operator=(QString const&)' sin definir
obj/Debug/main.o: En funciñon `QWidget::resize(int, int)':/usr/include/qt4/QtGui/qwidget.h:846: referencia a `QWidget::resize(QSize const&)' sin definir
collect2: ld devolvió el estado de salida 1
Process terminated with status 1 (0 minutes, 1 seconds)
12 errors, 0 warnings

I have added the  `qt-config --cxxflags` in "Other compiler options" and `qt-config --libs` in "Other linker options", but it doesn't work. I had the same problems with GTK but I solved it adding the directories and `pkg-config --cflags gtk+-2.0` under "Project" -> "Build Options" -> "Compiler" -> "Other Options" , and  `pkg-config --libs gtk+-2.0`  under "Project" -> "Build Options" -> "Linker" -> "Other linker options", but what can I do with qt?


Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Help setting up Code::BLocks with QT4
« Reply #4 on: February 17, 2007, 05:14:32 pm »
qtconfig (not qt-config) is for setting common look and feel properties to all your Qt programs. It has nothing to do with the flags / libpaths / libs that you should add to your project. Just add -QtCore -lQtGui -lQt<whatever else you are using> to your project libraries and you 're good to go. The Qt libraries are under /usr/lib for Qt4.x and under /usr/share/qt3/lib for Qt3.x but this doesn't affect you as the will always be in your libpath under linux.
Life would be so much easier if we could just look at the source code.

Offline zak

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Help setting up Code::BLocks with QT4
« Reply #5 on: November 27, 2010, 09:59:13 am »
Hi,

cmake help us to solve the problem, both on windows and linux.

1) read some info about cmake here
     http://www.cmake.org/cmake/help/examples.html
     
2) create a cmakelist.txt for a QT4 project following this
     http://www.qtcentre.org/wiki/index.php?title=Compiling_Qt4_apps_with_CMake

3) run cmake in the directory where cmakelist.txt is using the commans:
      $> cmake ./ -G "CodeBlocks - MinGW Makefiles"
    in order to produce the cache for cmake and the C:B project

4) run the file .cbp project produced by cmake and.. it will works!

5) only for windows users: in order to avoid linking problems
    start a QT command prompt (start->programs->Qt->Qt command prompt)
    navigate the directory until your project is and run the .cbp file:

Good Work!