User forums > Help

Code::Blocks + Qt 4.5 Error

(1/2) > >>

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

--- End code ---
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"));
 }

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

--- End code ---
I Obtain "Undefined reference to 'AddressBook::AddressBook(QWidget*)'....
Can someone help me???

Thanks

MortenMacFly:

--- Quote from: Giacomo on April 28, 2009, 06:47:09 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?

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

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

MortenMacFly:

--- Quote from: Giacomo on April 28, 2009, 08:49:46 pm ---1) ''set the execution working directory to where DLL is.'' What do you mean?

--- End quote ---
Look into the project (target) options -> there is a textbox where you can setup a directory named like that accordingly.


--- Quote from: Giacomo on April 28, 2009, 08:49:46 pm ---2) Are you sure?? I don't think there are errors on that example code... Somebody have any idea to how solve this issue?

--- End quote ---
Yes.
Search with Google for "undefined reference", understand your problem, then fix your project.

Giacomo:
''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...

Navigation

[0] Message Index

[#] Next page

Go to full version