c++ - call to another function in a dll causes access violation -
okay i'm starting realize dll arn't simplest of things understand, i'm trying make dll vc6 compatible, got code working in vs2010 in trying work out how code work vc6 project i've found following issue:
my call dll looks this
mydll::connect();
when try , run program uses function, starts out fine gets function call i.e.
void connect() { hello(); //0xc0000005: access violation } void hello() { int = 1; }
the disassembly looks this:
-> 00000000 ??? 00000001 ??? 00000002 ??? 00000003 ??? 00000004 ??? 00000005 ??? 00000006 ??? 00000007 ??? 00000008 ??? 00000009 ??? etc...
you didn't exported function .....a program not permitted access function in dll unless function registered exported function. should prototype this
to export function inside class function should 1- public member. 2- static member
class mydll{ public: static void connect(); } //then redeclare #ifdef _cplusplus extern "c"{ #endif __declspec(dllexport) void mydll::connect(){ //todo } #ifdef _cplusplus } #endif
do class member function want export
this example
Comments
Post a Comment