ennixo
asked on
C++ DLL with Dev-CPP for use in Visual Basic 6
My Dll's export are twined and decorated
ex: For the function void __stdcall HelloWorld(void) i've got : _Z10HelloWorldv@0 and _Z10HelloWorldv
How do i get a export that i can just call HelloWorld without Alias "_Z10HelloWorldv" ?
Here's my Source :
==========================
Def.h
==========================
#include "windows.h"
#define export __declspec (dllexport)
export void __stdcall HelloWorld (void);
==========================
main.cpp
==========================
#include "Def.h"
void __stdcall HelloWorld (void)
{
MessageBox(NULL,"Hello !","Message",MB_OK);
}
ex: For the function void __stdcall HelloWorld(void) i've got : _Z10HelloWorldv@0 and _Z10HelloWorldv
How do i get a export that i can just call HelloWorld without Alias "_Z10HelloWorldv" ?
Here's my Source :
==========================
Def.h
==========================
#include "windows.h"
#define export __declspec (dllexport)
export void __stdcall HelloWorld (void);
==========================
main.cpp
==========================
#include "Def.h"
void __stdcall HelloWorld (void)
{
MessageBox(NULL,"Hello !","Message",MB_OK);
}
ASKER
thanx a lot ! no more decoration !
but my exports are still twins :
HelloWorld
HelloWorld@0
can't i get only HelloWorld alone ?
but my exports are still twins :
HelloWorld
HelloWorld@0
can't i get only HelloWorld alone ?
extern "C"
{
export void __cdecl HelloWorld();
}
extern "C"
{
void __cdecl HelloWorld()
{
// something
}
}
Either that, or use the /EXPORT and .def file approach.
HTH
{
export void __cdecl HelloWorld();
}
extern "C"
{
void __cdecl HelloWorld()
{
// something
}
}
Either that, or use the /EXPORT and .def file approach.
HTH
ASKER
well i tried with __cdecl, it works but then the function cannont be called from VB6...
and i tried with a .def file but i think i don't write the good code because nothing changes :
here is what i tried in testlib.def
LIBRARY testlib
EXPORTS
HelloWorld @1
i tried a few things in the .def file but no result...
what should i write ?
and i tried with a .def file but i think i don't write the good code because nothing changes :
here is what i tried in testlib.def
LIBRARY testlib
EXPORTS
HelloWorld @1
i tried a few things in the .def file but no result...
what should i write ?
If you use __stdcall or __cdecl, VB will know how to find it's way into the correct entrypoint.
Did you get any error when calling from VB6 ? (i tried it with both conventions, and both worked)
On any case, if you really need the entrypoint undecorated:
cl mylib.cpp /EXPORT:HelloWorld
or
cl mylib.cpp /LINK /DEF:mylib.def
where mylib.def is:
LIBRARY mylib
EXPORTS
HelloWorld @1
HTH
Did you get any error when calling from VB6 ? (i tried it with both conventions, and both worked)
On any case, if you really need the entrypoint undecorated:
cl mylib.cpp /EXPORT:HelloWorld
or
cl mylib.cpp /LINK /DEF:mylib.def
where mylib.def is:
LIBRARY mylib
EXPORTS
HelloWorld @1
HTH
ASKER
sorry i thought i said i am a newnewnewbie to C++ and its compilation...
cl mylib.cpp /LINK /DEF:mylib.def
where do i put this ???
__stdcall works perfectly, my vb calls HelloWorld and it works but there are still 2 exports
__cdecl there is only "HelloWorld" export but my VB didn't find the entry point...
cl mylib.cpp /LINK /DEF:mylib.def
where do i put this ???
__stdcall works perfectly, my vb calls HelloWorld and it works but there are still 2 exports
__cdecl there is only "HelloWorld" export but my VB didn't find the entry point...
Sorry :)
Which version of VC++ are you using ?
Can you also share the Declares you're using in VB6 ?
Assuming VC7.1 (2003), you should:
Menu Project
Properties
Linker
Input
Module Definition File -> set this to the .def file you've just added into your project
Let me know if this works for you.
HTH
Which version of VC++ are you using ?
Can you also share the Declares you're using in VB6 ?
Assuming VC7.1 (2003), you should:
Menu Project
Properties
Linker
Input
Module Definition File -> set this to the .def file you've just added into your project
Let me know if this works for you.
HTH
ASKER
i don't have VC++, only Dev-C++ (http://www.bloodsheld.com) :-/
but i found --no-export-all-symbols --add-stdcall-alias in the linker (Project > Properties > Linker)
i tried to add myfile.def, it changed a little the compilation but nothing changed in the dll...
but i found --no-export-all-symbols --add-stdcall-alias in the linker (Project > Properties > Linker)
i tried to add myfile.def, it changed a little the compilation but nothing changed in the dll...
Listening
Hi, i'll have to download the compiler and play with it.
(downloading as we speak)
(downloading as we speak)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, thanx a lot !!!!
i learned that i must have HelloWorld and HelloWorld@0 because of stdCall
and stdCall is absolutely needed for my functions to be called by VB... (CDecl really doesn't work with VB)
i think you can ear more points from me with this question :
https://www.experts-exchange.com/questions/20806513/Passing-a-dynamic-array-from-VB-to-a-C-DLL-as-parameter.html
i learned that i must have HelloWorld and HelloWorld@0 because of stdCall
and stdCall is absolutely needed for my functions to be called by VB... (CDecl really doesn't work with VB)
i think you can ear more points from me with this question :
https://www.experts-exchange.com/questions/20806513/Passing-a-dynamic-array-from-VB-to-a-C-DLL-as-parameter.html
ASKER
* earn, not ear !!
How C DLL's can be created from ordinary .c file and how it can be called from an VB6.0 application.
{
export void __stdcall HelloWorld();
}
extern "C"
{
void __stdcall HelloWorld()
{
// something
}
}
HTH