Need a few clarifications
-
hi,
i am quite new to qt.i have done a exhaustive search but was not able to completely understand all the parameters in the code below. can anyone clarify what exactly a symbol .is it the name of a function present in a dll or is it smthin else. i have got the below from the qt documentation for QLibrary (http://doc.qt.nokia.com/4.7/qlibrary.html) but was not able to ubderstand completely.@void * QLibrary::resolve ( const char * symbol )@
-
You have the right idea. The symbol is the name of a function present in the library (DLL) specified in an earlier call to setFileName() and brought in with the load() method. The result is either a function pointer that can be used to call the specified function or (if resolve() failed) a null pointer.
-
hi,
ty for ur reply N3Roster.
i found this program in the documentation. now here i understand in the below program that "avg" is the name of the function in the library but i am not able to understand what is "AvgFunction". is it any random function pointer or a specific interface name in the dll.
thanks in advance.@typedef int (*AvgFunction)(int, int);
AvgFunction avg = (AvgFunction) library->resolve("avg");
if (avg)
return avg(5, 8);
else
return -1;@ -
QLibrary::resolve(), as seen in its prototype, returns a void pointer. The first line provides a function pointer type that specifies the return type and argument types which should match the function you want to call through that pointer. In the second line, AvgFunction is the pointer type for the avg variable the pointer is assigned to while (AvgFunction) to the right of the assignment casts the pointer returned from resolve() to that type. There's nothing special about that name and it could be whatever makes sense in your application.
-
hi,
thankyou N3Roaster for the reply.i really appreciate it.
i wrote a small snippet to access a function from the Apogee.dll file.Here is the code.
@#include <QtCore/QCoreApplication>
#include<stdio.h>
#include<QLibrary.h>
int main(int argc, char *argv[])
{ QCoreApplication a(argc, argv);
QLibrary asd("Apogee");
typedef bool (*ICamera2)(bool);
ICamera2 d=(ICamera2) Apogee->resolve("ShowIODialog");
bool ab;
ab=asd.load();
if(asd.isLoaded()==true)
{ printf("Loaded properly");
if(d(true))
{
d(true);
}
else
{
printf("not possible");
}
}
else
{
printf("not loaded");
}
return a.exec();
} @
but when i try to build my project it gives me an error '"Apogee" not declared in this scope' .thanks in advance. -
You have an error
@
typedef bool (*ICamera2)(bool);
ICamera2 d=(ICamera2) Apogee->resolve("ShowIODialog");
@maybe you want
@
typedef bool (*ICamera2)(bool);
ICamera2 d=(ICamera2) asd->resolve("ShowIODialog");
@
[quote author="sriharsha" date="1298361645"]hi,
thankyou N3Roaster for the reply.i really appreciate it.
i wrote a small snippet to access a function from the Apogee.dll file.Here is the code.
@#include <QtCore/QCoreApplication>
#include<stdio.h>
#include<QLibrary.h>
int main(int argc, char *argv[])
{ QCoreApplication a(argc, argv);
QLibrary asd("Apogee");
typedef bool (*ICamera2)(bool);
ICamera2 d=(ICamera2) Apogee->resolve("ShowIODialog");
bool ab;
ab=asd.load();
if(asd.isLoaded()==true)
{ printf("Loaded properly");
if(d(true))
{
d(true);
}
else
{
printf("not possible");
}
}
else
{
printf("not loaded");
}
return a.exec();
} @
but when i try to build my project it gives me an error '"Apogee" not declared in this scope' .thanks in advance.[/quote] -
hi,
Stuk and N3Roaster, thankyou for your replies.i am able to compile my program properly thanks to you.but wen i run i get an error message . being quite new to this i have no idea whats wrong with my coding.i am attaching a snapshot of the error.
!http://c:/error.png(error snapshot)!
if the snapshot is not seen then i will repost it. -
Nothing seen.
[quote author="sriharsha" date="1298368473"]hi,
Stuk and N3Roaster, thankyou for your replies.i am able to compile my program properly thanks to you.but wen i run i get an error message . being quite new to this i have no idea whats wrong with my coding.i am attaching a snapshot of the error.
!http://c:/error.png(error snapshot)!
if the snapshot is not seen then i will repost it.[/quote] -
hi,
sory about that . i have attached again . it wil be available this time.
!http://i.imgur.com/XdQ3K.png(Error Snapshot)! -
A similar problem with Apogee was discusssed "here":http://developer.qt.nokia.com/forums/viewthread/3922.
Short story: You cannot resolve C++ symbols with QLibrary, only C symbols.
Longer story: you do not want to use QLibrary, but link to the DLL and use the header files provided for the DLL.