PureBasic DLL Usage

Blitz3D Forums/Blitz3D Programming/PureBasic DLL Usage

Robin Hossain(Posted 2004) [#1]
I've created various DLLs in PureBasic to be used by Blitz3D. Unfortunately, Blitz3D seems to become unstable when using these DLLs.

I'm using the latest 1.87 B3D update and PureBasic 3.90.

The types of problems I am having are:

1. Sometimes - for no reason, Blitz3D will claim 'UserLibs not found' - but if I cut and paste the same code in a new file - it will work. This problem occurs on two PCs I have tested this with.

2. Calling the DLL will sometimes caused a 'Memory Access Violation Error' also - about 1 in 500 times the DLL is called.

3. Calling the DLL without opening a screen buffer (e.g. Graphics3D 640,480,16,2) will reduce the likelihood of a 'Memory Access Violation' when calling a DLL.

4. The type of code in the DLL built in PureBasic accesses the Serial COM ports (via MVCOM) and also allocates memory (RAM).

5 The same scenario occurs on Win XP Home as well as Win 98 SE.


Does anyone else have the same problems ?
Is there some incompatibility with Blitz3D and PureBasic DLLs ?


MRaven(Posted 2004) [#2]
I'm using some Pure Basic DLLs and only get an error if there is something wrong either in the pure or blitz code. I'm using Win XP Home and the newest versions of both languages too


Skitchy(Posted 2004) [#3]
If you're peeking and poking memory then you need to be careful. Sounds like you might be changing internals used by either Blitz or Pure, and they're getting confused :)


Robin Hossain(Posted 2004) [#4]
Seems like the MVCOM serial port library maybe messing with memory when closing a port. This seems to cause Blitz to lose it...

MRRaven - if your using PB - could you do a simple test that opens a port from Blitz using a PB dll via MVCOM, and another call to close the same port from Blitz. e.g.

PB Code: (compile as PBTest.dll)

ProcedureCDLL OpenPort(PortDef.s)
HCom.l = ComOpen(PortDef,0,1024,1024)
ProcedureReturn HCom
Endprocedure

ProcedureCDLL ClosePort(PortID.l)
ComClose (PortID)
ProcedureReturn 1
EndProcedure

Blitz Decls

.lib "PBTest.dll"

OpenPort%(PortID$)
ClosePort%(PortID%)


Blitz Code

PortID=OpenPort("COM2:4800,N,8,1")
Delay(1000)
ClosePort(HCom)


The 'ClosePort' command will always generate a memory access violation error for me.

Even if HCom is a Global in PB.


Mike0101(Posted 2004) [#5]
Why better a purebasic dll in Blitz3D like a Blitz function?
Is this fastest?