PDA

View Full Version : DLL export problem



hrcariaga
11th February 2008, 07:31
hi to all!

i've created a simple program with export(i'm not sure if my export code is right) and compile it as .dll..

then i'm trying to access the .dll using delphi.. but the problem is i can't acces the function in my .dll.. please help..

heres my code:

//in .h

class q_decl_export dialogimpl : public qdialog, public ui.html#Dialog
{
Q_OBJECT
public:
DialogImpl;
#endif" class="bbcodeurl">#ifndef DIALOGIMPL_H
#define DIALOGIMPL_H
#include <QDialog>
#include "ui_dialog.h"

class Q_DECL_EXPORT DialogImpl : public QDialog, public Ui::Dialog
{
Q_OBJECT
public:
DialogImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
void ShowMessage();
private slots:
};
Q_DECL_EXPORT void ShowMessage();
#endif
//in .cpp

#include

//
q_decl_export dialogimpl.html#DialogImpl;
}" class="bbcodeurl">#include "dialogimpl.h"
#include <QMessageBox>

//
Q_DECL_EXPORT DialogImpl::DialogImpl( QWidget * parent, Qt::WFlags f)
: QDialog(parent, f)
{
setupUi(this);
ShowMessage();
}

Q_DECL_EXPORT void DialogImpl::ShowMessage()
{
QMessageBox::information(this, tr("DLL"),"DLL exported!");
}

jpn
11th February 2008, 08:50
Unfortunately it's not correct. You can't hardcode Q_DECL_EXPORT like that. You must use Q_DECL_EXPORT when building the library and Q_DECL_IMPORT when using the library. For more details, see this thread: Q_DECL_EXPORT and Q_DECL_IMPORT (http://www.qtcentre.org/forum/f-general-programming-9/t-q-decl-export-and-q-decl-import-7923.html).

hrcariaga
11th February 2008, 10:05
Unfortunately it's not correct. You can't hardcode Q_DECL_EXPORT like that. You must use Q_DECL_EXPORT when building the library and Q_DECL_IMPORT when using the library. For more details, see this thread: Q_DECL_EXPORT and Q_DECL_IMPORT (http://www.qtcentre.org/forum/f-general-programming-9/t-q-decl-export-and-q-decl-import-7923.html).


i've changed my first code to this:

in .h



#ifndef DIALOGIMPL_H
#define DIALOGIMPL_H
#include <QDialog>
#include "ui_dialog.h"

#ifndef _DLL_BUILD_
#if (defined(QT_DLL) || defined(QT_SHARED)) && !defined(QT_PLUGIN)
#define EXPORT Q_DECL_EXPORT
#else
#define EXPORT
#endif
#else
#define EXPORT Q_DECL_IMPORT
#endif


class EXPORT DialogImpl : public QDialog, public Ui::Dialog
{
Q_OBJECT
public:
DialogImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
void ShowMessage();
private slots:
};

EXPORT void ShowMessage();
#endif



in .cpp



#include "dialogimpl.h"
#include <QMessageBox>

EXPORT DialogImpl::DialogImpl( QWidget * parent, Qt::WFlags f)
: QDialog(parent, f)
{
setupUi(this);
ShowMessage();
}

EXPORT void DialogImpl::ShowMessage()
{
QMessageBox::information(this, tr("DLL"),"DLL exported!");
}



i have build the program without error but still the .dll can't be access by delphi..

hmm, is there any suggestion on how i can solve my problem?

thanks..:confused:

ChristianEhrlicher
11th February 2008, 12:53
Why do you think you can access C++ code from Delphi? A Qt-Window will never run without a proper QApplication...

hrcariaga
12th February 2008, 01:51
I think any program compiled into a .dll can be access/imported by any programming language provided that it is properly exported..

my problem is, I can't find the right code to export my dll..

is there any suggestion on how I can make this?

thanks..

ChristianEhrlicher
12th February 2008, 07:26
Did you read my post?

You can't access a QWidget from Delphi (or whatever) because you need a QMainApplication. Also you can't access a C++ class from Delphi at all (imho).