hModule := DllCall("LoadLibrary", "str","libgsl.dll")
MsgBox %ErrorLevel% ; shows 0 (OK)
c := dllcall("libgsl\gsl_hypot", "double",3.0, "double",4.0, "double")
MsgBox %ErrorLevel% ; shows -3 (The specified DllFile could not be accessed)
LIBGSL.DLL cannot be accessed
#1
Posted 13 July 2007 - 09:35 PM
#2
Posted 14 July 2007 - 02:10 AM
It looks like depend on libgslcblas.dll, so this file should be present too.The GNU Scientific Library is available as a Windows dll from http://gnuwin32.sour...ackages/gsl.htm, but AHK cannot access it.
#3
Posted 14 July 2007 - 02:19 AM
However, more informative error information would be very helpful. AHK says that "The specified DllFile could not be accessed", what is not true. In this case another, dependent dll file could not be accessed. If I knew it, I could have found the missing dll file.
This is how it works:
h_liblas := DllCall("LoadLibrary", "str","C:\Program Files\GnuWin32\bin\libgslcblas.dll") ; dependent dll 1st
h_libgsl := DllCall("LoadLibrary", "str","C:\Program Files\GnuWin32\bin\libgsl.dll") ; main library 2nd
c := dllcall("libgsl\gsl_hypot", "double",3, "double",4, "cdecl double")
MsgBox %c%`n%ErrorLevel%
#4
Posted 14 July 2007 - 03:02 PM
#5
Posted 14 July 2007 - 03:27 PM
#6
Posted 14 July 2007 - 04:08 PM
if AutoHotkey is denied access if the dll's dependencies haven't been met (although, I agree, not very clear in this case). If I run a smaller version of your sample script without the second dll present:-3: The specified DllFile could not be accessed. If no explicit path was specified for DllFile, the file must exist in the system's PATH or A_WorkingDir. This error might also occur if the user lacks permission to access the file.
c := dllcall("libgsl\gsl_hypot", "double",3, "double",4, "cdecl double")
MsgBox %c%`n%ErrorLevel% I get the following error message in a msgbox before the -3 AutoHotkey msgbox output. This application has failed to start because libgslcblas.dll was not found. Re-installing the application may fix this problem.
For comparison, I created a couple of simple dlls for testing where one dll calls a function in the other dll and if I remove or rename the second dll I get 0xc0000005, not -3.
#7
Posted 09 August 2007 - 02:26 AM
gsl_sf_polar_to_rect (double r, double theta, gsl_sf_result * x, gsl_sf_result * y); and the vice-versa function gsl_sf_rect_to_polar
I always get 0x0000005 -3 whatever I do and I don't have any idea how I couls make it work.
I also would like to use Foxes Team Xnumbers.dll from <!-- m -->http://digilander.li...areDownload.htm<!-- m -->
Well this dll is written for excel but as far I know a normal dll and I'm looking how to use it in AutoHotKey?
Thanks in advance
#8
Posted 09 August 2007 - 02:31 AM
#9
Posted 09 August 2007 - 06:04 AM
h_liblas := DllCall("LoadLibrary", "str","C:\Program Files\GnuWin32\bin\libgslcblas.dll") ; dependent dll 1st
h_libgsl := DllCall("LoadLibrary", "str","C:\Program Files\GnuWin32\bin\libgsl.dll") ; main library 2nd
c := dllcall("libgsl\gsl_sf_polar_to_rect","double",4,"double",5,"double",x,"double",y,"cdecl")
MsgBox, %c%`n,%ErrorLevel%, x = %x%, y = %y%
return
#10
Posted 09 August 2007 - 12:45 PM
VarSetCapacity(x,16), VarSetCapacity(y,16)
dllcall("libgsl\gsl_sf_polar_to_rect","double",sqrt(8),"double",-atan(1),"uint",&x,"uint",&y,"cdecl")
MsgBox % "x = " NumGet(x,0,"double") " y = " NumGet(y,0,"double")Edit 20070820: The return values are structures of two doubles: {value, error}
#11
Posted 09 August 2007 - 01:07 PM
dllcall("libgsl\gsl_sf_polar_to_rect","double",sqrt(8),"double",-atan(1),"double*",x,"double*",y,"cdecl")
MsgBox % "x = " . x . " y = " . yBut the results are structures, and so the values of x and y stay unchanged! It could even crash AHK.Edit 20070820: return values are structs!
#12
Posted 10 August 2007 - 01:32 AM
I'd like to hear about the opinion of Chris on this, as I encountered a similar situation recently:According to the AHK help file, the following should work, too
dllcall("libgsl\gsl_sf_polar_to_rect","double",sqrt(8),"double",-atan(1),"double*",x,"double*",y,"cdecl") MsgBox % "x = " . x . " y = " . yBut it does not. The values of x and y stay unchanged!
<!-- m -->http://www.autohotke...topic20701.html<!-- m -->
There, I used the following
VarSetCapacity(str,8,0) DllCall(NumGet(NumGet(1*psf)+44), "Uint", psf, "Uint", pidl, "Uint", 1, "Uint", &str)instead of
DllCall(NumGet(NumGet(1*psf)+44), "Uint", psf, "Uint", pidl, "Uint", 1, "int64P", str)If using the second one instead, it crashed AHK (:the var name str didn't matter).
OTOH, exactly the same function worked flawlessly in the second form, in other (:unpublished) script.
The difference between the two situations is that some indirection, the so-called marshalling, is involved in the first situation.
So, I'm currently assuming that this symptom would happen, although not always, if the ByRef parameters were updated via other one/thread than the called function itself.
#13
Posted 10 August 2007 - 04:01 AM
- allocate memory for a "type" temporary variable
- write the parameter in binary format there
- pass its address to the dll function
- upon return, convert the binary value (changed by the dll function) to its AHK representation, and store it in the AHK variable table.
In many cases it works. What could go wrong, when it does not? Maybe AHK does not see the temporary variable changed, but this is unlikely. Or, this variable is allocated on the local stack, and when the parameter has to be passed on to another, internally called function, the stack frame changes, and the secondary function updates the wrong memory. (It explains the crash.) When we use the address of an explicit AHK variable (UInt,&x), x resides in the heap (globally allocated), and changing the stack frame does not affect its accessibility.
If it was the case, it would be easy to fix: don't use the stack for the temporary variable.
Edit 20070820: The results are in structures, which explains why "double*" does not work. AHK is innocent!
#14
Posted 10 August 2007 - 05:05 AM
VarSetCapacity(x,8), VarSetCapacity(y,8)
dllcall("libgsl\gsl_sf_polar_to_rect","double",sqrt(8),"double",-atan(1),"uint",&x,"uint",&y,"cdecl")
VarSetCapacity(x, -1)
VarSetCapacity(y, -1)
MsgBox % "x = " NumGet(x,0,"double") " y = " NumGet(y,0,"double")
Return
; In v1.0.44.03+, specify -1 for RequestedCapacity to update the variable's internally-stored length
; to the length of its current contents. This is useful in cases where the variable has been altered
; indirectly, such as by passing its address via DllCall(). In this mode, VarSetCapacity() returns
; the length rather than the capacity.
#15
Posted 10 August 2007 - 06:43 AM
Now Laszlos script together with yours look like this and it really works perfect:
VarSetCapacity(x,8), VarSetCapacity(y,8)
h_liblas := DllCall("LoadLibrary", "str","C:\Program Files\GnuWin32\bin\libgslcblas.dll") ; dependent dll 1st
h_libgsl := DllCall("LoadLibrary", "str","C:\Program Files\GnuWin32\bin\libgsl.dll") ; main library 2nd
dllcall("libgsl\gsl_sf_polar_to_rect","double",sqrt(8),"double",-atan(3),"uint",&x,"uint",&y,"cdecl")
VarSetCapacity(x, -1)
VarSetCapacity(y, -1)
MsgBox % "x = " NumGet(x,0,"double") " y = " NumGet(y,0,"double")
Return
; In v1.0.44.03+, specify -1 for RequestedCapacity to update the variable's internally-stored length
; to the length of its current contents. This is useful in cases where the variable has been altered
; indirectly, such as by passing its address via DllCall(). In this mode, VarSetCapacity() returns
; the length rather than the capacity.
This Open Source math library is very usefull for sure not only for me. And I know how hard it is to get reliable help and information. That's why I would like to suggest making this math library working together with AutoHotKey and providing more info to all AutoHotKey users. Above we have a good start and I hope to see more questions. THANKS TO ALL AGAIN!!




