I'm wondering if anyone has done the coding to access the U3-HV in FreeBasic? I'm running Windows x64. I just need simple A/D input, D/A output, and Dig I/O to control relays for some laboratory work. Happy to pay a bit to avoid the time and effort but I'm a cash-starved professor so free is always better and NDA's will be signed happily. :)
Thanks, Alan Fridlund
We do not provide an interface or examples for FreeBasic, but it looks like it can interface to dlls, such as our LabJackUD.dll driver, using the "#inclib", or Dylibload/Dylibsymbol/Dylibfree methods:
https://www.freebasic.net/wiki/wikka.php?wakka=ProPgSharedLibraries
Though not exactly the same usage, but could prove helpful, there are the VisualBasic6 examples for the the U3-HV:
https://labjack.com/support/software/examples/ud/visual-basic
The "#inclib" method looks similar to how we interface to LabJackUD.dll in those examples.
Thanks for the tips. Some partial success! With the help of MrSwiss on the FreeBasic forum I was able to get several U12 functions working in FreeBasic using this syntax:
Dim LJ_lib As Any Ptr
# Ifdef __FB_64BIT__
LJ_lib = DylibLoad("C:\Windows\System32\ljackuw.dll") ' FBC 64
# Else
LJ_lib = DylibLoad("C:\Windows\SysWOW64\ljackuw.dll") ' FBC 32
# EndIf
If LJ_lib = 0 Then
Print "ERROR: 'ljackuw.dll' load failed!"
Beep : Sleep : End 1
End If
So this works great. Now I'm trying to get a U3-HV library loaded the same way, but when I try this the program freezes before even loading the console screen or giving the error msg:
Dim LJ_lib As Any Ptr
# Ifdef __FB_64BIT__
LJ_lib = DylibLoad("C:\Windows\System32\LabJackUD.dll") ' FBC 64
# Else
LJ_lib = DylibLoad("C:\Windows\SysWOW64\LabJackUD.dll") ' FBC 32
# EndIf
If LJ_lib = 0 Then
Print "ERROR: 'LabJackUD.dll' load failed!"
Beep : Sleep : End 1
End If
Any idea while the U12 library DLL loads but the U3 library DLL doesn't? Now when I try to use the FB "inclib" method (under Win10 x64) as follows:
#inclib "C:\Windows\System32\labjackud.dll"
FB gives me a "file not found message." I'm stymied.
It's interesting that the PureBasic example works fine. Any help is appreciated! I thought I'd ask you in case it's a LJ issue; otherwise I'll take it to the FB forum.
Thanks,
Alan
Sorry, I uploaded msg yesterday. It turns out that when calling a DLL using Dynlibload in Freebasic, you omit the .DLL extension. So:
# Ifdef __FB_64BIT__
LJ_lib = DylibLoad("C:\Windows\System32\labjackud.dll") ' FBC 64
# Else
LJ_lib = DylibLoad("C:\Windows\SysWOW64\labjackud.dll") ' FBC 32
# EndIf
crashes, but
# Ifdef __FB_64BIT__
LJ_lib = DylibLoad("C:\Windows\System32\labjackud") ' FBC 64
# Else
LJ_lib = DylibLoad("C:\Windows\SysWOW64\labjackud") ' FBC 32
# EndIf
works fine. No need to post this or prev msgs. Very sorry ... this is an obscure detail in FB which managed to elude me.
Alan F.
Glad to hear you found the solution. I'll keep your posts as it may help others trying to load dlls with FreeBASIC.