PDA

View Full Version : Load Symbian DLL or use function from DLL in Qt App



newbis60
29th September 2010, 17:16
Hi All,

This is my 2nd day with Qt development and eventually it has became tough for me to migrate from Carbide C++ to Qt for Symbian.. need your help..

I have a Symbian C++ DLL developed using Carbide C++ for sending SMS.. I want to use this DLL in a Qt App.. say a button push on Qt App triggers SendL() in DLL and sends SMS.. things I am stuck with are:

1. How do I connect to or load a Symbian DLL in to a Qt App..

LIBS += c:/Qt/4.7.0/lib/SmsDll.lib in Qt .pro or
symbian:LIBS += -lSmsDll
none of the above is working for me and I cannot connect or load SMS.. I have even tried loading an existing header file from Carbide work space which resulted in header file not found error..


HEADERS += mainwindow.h \
../../../Symbian/Carbide/WorkSpace/Dll/inc/SMS_DLL.h

where exactly in Qt that I should add any libs r dll.. i mean path in Qt..

2. Can I use the same header file which i have used in Carbide C++ in Qt as well.. reason is when I just create new header file of the Symbian LIB Header file within the Qt App.. I can only see lot of errors as I can see that Qt does't understand any of the Symbian header files or libraries or datatypes.. DO I NEED TO CREATE A NEW HEADER FILE OF THE LIB FILE in Qt..

3. How can i invoke SendL() function which eventually is in DLL from my push button or atleast from Main() of Qt.. for Dynamic loading..


void MainWindow:n_SendSmsButton_clicked()
{
QLibrary myLib("SmsDll");
typedef void (*MyPrototype)();
myLib.load();
if(myLib.isLoaded())//this succeeds
{
MyPrototype myFunction = (MyPrototype) myLib.resolve("SendL");
if (myFunction)
{
.....SendL(arguments);.............
}
}
I need to pass arguments Phone Number and Message to SendL()..

I am a bit lost.. can you plz help me with an example or suggestions of loading and using a Symbian DLL in a Qt App..

Thank you very much..

P.S. If the whole message is absolutely crap plz forgive me as this eventually is my 2nd day with Qt...

tbscope
29th September 2010, 17:35
LIBS += c:/Qt/4.7.0/lib/SmsDll.lib
No, never use full paths. If you give the code to me, I can not compile it.


symbian:LIBS += -lSmsDll
Are you coding for multiple targets? If not, just use


LIBS += -lSmsDll
Be aware that some operating systems do mind if you use small letters or capital letters.
And be sure that "SmsDll.so" exists in your path environment variable.

As for the include files:
Be sure to install them in a sane path, like /usr/include. This way it is much much easier to find the includes and share the code.

INCLUDEPATH += /where/your/libs/headers/are


Can I use the same header file which i have used in Carbide C++ in Qt as well
Header file: yes
Library: depends.


How can i invoke SendL() function which eventually is in DLL from my push button
Just include the header file and call the function.

newbis60
30th September 2010, 11:12
Thank you very much tbscope..

with your suggestions i am able to connect to my header file and set of library files resting in Carbide workspace from the Qt environment.. the problems that i am facing now are..

I want to create a instance of the Active Object of SmsHandler (defination of which is in the included header file) in my Qt C++ class so that I can create an instance of the AO and invoke SendMessage().. the errors I am getting are..

my Header file from Qt..

#include <KCHX_SMS_DLL.h>
class CKCHX_SMS_DLL;

class SmsDll
{
public:
SmsDll();
~SmsDll();
public:
void SendMessageL();
private:
CKCHX_SMS_DLL* iSmsHandler;
TBuf<128> iPhoneNum,iSmsText;
};

My Source file:

#include "smsdll.h"
#include <KCHX_SMS_DLL.h>

class CKCHX_SMS_DLL;

SmsDll::SmsDll()
{
CKCHX_SMS_DLL* iSmsHandler = CKCHX_SMS_DLL::NewL();

}
SmsDll::~SmsDll()
{
if (iSmsHandler)
{
delete iSmsHandler;
iSmsHandler = NULL;
}
}

void SmsDll::SendMessageL()
{
iSmsText.Copy(_L("Hidden Message"));
iPhoneNum.Copy(_L("+447583411245"));

iSmsHandler->SendL(iPhoneNum,iSmsText);
}

As you can see I am trying to create an instance of AO whose declaration is in KCHX_SMS_DLL.h which is the header file of my DLL and whose defination or running code is in SmsDll.lib(which i am sure i have added to Qt in .pro and is connected)

The errors are:

1. Undefined reference to CKCHX_SMS_DLL::NewL();

2. And as I am unable to create a instance of CKCHX_SMS_DLL I am unable to use iSmsHandler->SendL(iPhoneNum,iSmsText); which is throwing same undefined reference..

How can I create an instance of the AO.. can I still use NewL() imported function..?

my AO header file code for NewL()..

class CKCHX_SMS_DLL : public CActive, public MMsvSessionObserver
{
public:
// new functions
IMPORT_C
static CKCHX_SMS_DLL* NewL();IMPORT_C
static CKCHX_SMS_DLL* NewLC();
IMPORT_C ~CKCHX_SMS_DLL();

private:
// new functions
CKCHX_SMS_DLL();
void ConstructL();

public: // New functions


/**
* SendL.
* Starts the process of creating and sending an SMS message.
* @param aRecipientNumber The number of the recipent.
* @param aMessageText The message text.
* @return ETrue if successful, EFalse if not.
*/
TBool SendL( const TDesC& aRecipientNumber,
const TDesC& aMessageText );



Thanks..

DarkDante
6th October 2010, 00:50
Have u been able to solve it? Im having exactly the same problem just with another library.