Creating purelibraries in MinGW C++ possible?
-
dracflamloc
- Addict

- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
So a C++ function exposed in a DLL can be called using CallFunction after Loading the DLL?
[edit]NM, thanks for you help I got it!
[edit]NM, thanks for you help I got it!
Last edited by dracflamloc on Tue Jan 04, 2005 9:36 pm, edited 2 times in total.
-
olejr
- Enthusiast

- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
I really dont know..
But if you can do something like this it should work:
(Don't copy/paste this..
)
That is.. If You get some FunctionNames in the debugwindow...
But if you can do something like this it should work:
(Don't copy/paste this..
Code: Select all
If (lib = OpenLibrary(#PB_Any, "SomeLib.dll")) = 0
End
EndIf
If(ExamineLibraryFunctions(lib))
While(NextLibraryFunction)
Debug LibraryFunctionName()
Wend
Else
Debug "No Functions found"
EndIf-
dracflamloc
- Addict

- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
Yea I just called a simple void function I made in a DLL. Awesome!
The only thing I wonder about now is passing variables and getting returned values. But one step at a time! I'm sure I can figure it out easy enough.
The only thing I wonder about now is passing variables and getting returned values. But one step at a time! I'm sure I can figure it out easy enough.
Last edited by dracflamloc on Wed Jan 05, 2005 3:13 am, edited 1 time in total.
Code: Select all
#ifdef __cplusplus
extern "C" {
#endif
void DoAll()
{
/* [...] */
}
#ifdef __cplusplus
}
#endif
-
dracflamloc
- Addict

- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
-
dracflamloc
- Addict

- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
Crap I spoke too soon. I get loads of errors trying to read values back from the DLL call. I'm just trying to return an integer.
Here's an example:
When I try:
retval.l = i3D_Initialize3D(640,480,32,0)
it crashes when i do ProcedureReturn retval
with the error: "The instruction at 0x7blahblah has tried to read the data at 0x00000001 and caused an error: The memory could not be read."
What do I need to do to get this darn thing to work right?
Here's an example:
Code: Select all
ProcedureDLL.l i3D_Initialize3D(width.l,height.l,bits.l,isFullscreen.l)
OpenLibrary(20,".\PB_Irrlicht.dll")
If IsLibrary(20)
tmp.l=CallFunction(20,"?pb_Initialize3D@@YAHHHHH@Z",width,height,bits,isFullscreen)
ProcedureReturn tmp
Else
ProcedureReturn 0
EndIf
EndProcedure
//heres the C++ function
IRRLICHT_API int IRRCALLCONV pb_Initialize3D(int width,int height,int bits,int isFullscreen)
{
pb_device = irr::createDevice(video::EDT_OPENGL,dimension2d<s32>(width,height),bits,pb_intToBool(isFullscreen),true,false);
if (pb_device==0)
return 0;
//get video driver and scene manager and gui
pb_driver = pb_device->getVideoDriver();
pb_scene = pb_device->getSceneManager();
pb_gui = pb_device->getGUIEnvironment();
pb_scene->addCameraSceneNode(0,vector3df(0,0,0),vector3df(0,0,0));
return 1;
}
retval.l = i3D_Initialize3D(640,480,32,0)
it crashes when i do ProcedureReturn retval
with the error: "The instruction at 0x7blahblah has tried to read the data at 0x00000001 and caused an error: The memory could not be read."
What do I need to do to get this darn thing to work right?
-
FloHimself
- Enthusiast

- Posts: 229
- Joined: Wed May 14, 2003 3:38 pm
- Location: Lüneburg - Germany
Code: Select all
#define IRRLICHT_API __declspec(dllexport)-
dracflamloc
- Addict

- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
-
dracflamloc
- Addict

- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact: