Author Topic: Code::Blocks + Qt 4.5 Error  (Read 5307 times)

Offline Giacomo

  • Single posting newcomer
  • *
  • Posts: 4
Code::Blocks + Qt 4.5 Error
« on: April 28, 2009, 06:47:09 pm »
Hi all I'm new here.
I have installed Code::Blocks and Qt 4.5.0; I have setup Global variables and the top level folders of mingw compiler and qt libraries. Now I'm ready to do new Project-->Qt4project but i have some problems:

1) If I build my code (whichever it be) I obtain this error: "QtCore4.dll not found"... the only way I found To solve this issue is to copy the QtCore4.dll on C:\Windows\System32... Is there another way?

2) If I try to build the tutorial example GUI:
addressbook.h file:
Code
#ifndef ADDRESSBOOK_H
#define ADDRESSBOOK_H
#include <QWidget>

 class QLabel;
 class QLineEdit;
 class QTextEdit;

 class AddressBook : public QWidget
 {
     Q_OBJECT

 public:
     AddressBook(QWidget *parent = 0);

 private:
     QLineEdit *nameLine;
     QTextEdit *addressText;
 };

 #endif
addressbook.cpp file:
Code
#include <QtGui>
#include "addressbook.h"

 AddressBook::AddressBook(QWidget *parent) : QWidget(parent)
 {
     QLabel *nameLabel = new QLabel(tr("Name:"));
     nameLine = new QLineEdit;

     QLabel *addressLabel = new QLabel(tr("Address:"));
     addressText = new QTextEdit;

     QGridLayout *mainLayout = new QGridLayout;
     mainLayout->addWidget(nameLabel, 0, 0);
     mainLayout->addWidget(nameLine, 0, 1);
     mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
     mainLayout->addWidget(addressText, 1, 1);

     setLayout(mainLayout);
     setWindowTitle(tr("Simple Address Book"));
 }
main.cpp file:
Code
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QtGui>
#include <QWidget>
#include "addressbook.h"

int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);

     AddressBook *addressBook = new AddressBook;
     addressBook->show();

     return app.exec();
 }
I Obtain "Undefined reference to 'AddressBook::AddressBook(QWidget*)'....
Can someone help me???

Thanks

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code::Blocks + Qt 4.5 Error
« Reply #1 on: April 28, 2009, 07:56:55 pm »
1) If I build my code (whichever it be) I obtain this error: "QtCore4.dll not found"... the only way I found To solve this issue is to copy the QtCore4.dll on C:\Windows\System32... Is there another way?
Yes... Either:
- copy the DLL to your app directory
- set the execution working directory to where the DLL is
- link statically (requires different project setup and QT import libs)

Question 2) is not related to C::B.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Giacomo

  • Single posting newcomer
  • *
  • Posts: 4
Re: Code::Blocks + Qt 4.5 Error
« Reply #2 on: April 28, 2009, 08:49:46 pm »
1) ''set the execution working directory to where DLL is.'' What do you mean? Can you make me an example?

2) Are you sure?? I don't think there are errors on that example code... Somebody have any idea to how solve this issue?

Thanks a lot 
« Last Edit: April 28, 2009, 08:55:53 pm by Giacomo »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code::Blocks + Qt 4.5 Error
« Reply #3 on: April 28, 2009, 09:24:54 pm »
1) ''set the execution working directory to where DLL is.'' What do you mean?
Look into the project (target) options -> there is a textbox where you can setup a directory named like that accordingly.

2) Are you sure?? I don't think there are errors on that example code... Somebody have any idea to how solve this issue?
Yes.
Search with Google for "undefined reference", understand your problem, then fix your project.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Giacomo

  • Single posting newcomer
  • *
  • Posts: 4
Re: Code::Blocks + Qt 4.5 Error
« Reply #4 on: April 28, 2009, 10:08:36 pm »
''Yes.
Search with Google for "undefined reference", understand your problem, then fix your project.''

Brilliant idea... this is the way to solve the problem in 2020...

Offline Giacomo

  • Single posting newcomer
  • *
  • Posts: 4
Re: Code::Blocks + Qt 4.5 Error
« Reply #5 on: April 28, 2009, 10:29:30 pm »
Ok sorry for the joke!
I search with google and I found a few article correlate to my problem. This speaks about a custom MakeFile (or something like that), because the makefile autogenerated with code::blocks seems not working. Someone speaks about generate the make file through command line (by the command qmake) and after that compile the project with code::Bloacks..

Anyway, I don't have a .pro file on my project, I have to create it?? How can I create it?

P.S. Can you suggest another IDE for c++??