Jump to content

DllCall function behaving differently on 2 computers


Go to solution Solved by mistersquirrle,

Recommended Posts

On one computer, the script works as intended. The second computer gives an error: "Failed loading DLLs.Failed loading DLLs."

Func _cvLoadImage($filename, $iscolor = 1)
    If $filename = "" Then Return SetError(1)
    $_aResult = DllCall($_opencv_highgui, "int:cdecl", "cvLoadImage", "str", $filename, "int", $iscolor)
    MsgBox($MB_SYSTEMMODAL, "2", $_aResult) ; comment: our problem is $_aResult of this line^ it shows as 0 on the second computer (so its not an array)
                                            ; comment: while on the working computer it shows nothing which I assume is because an array won't show up on                                             ; comment: MsgBox
    If @error Then ConsoleWrite("File not loading")
    If Not IsArray($_aResult) Then
        MsgBox(16, "Error", "Failed loading DLLs.Failed loading DLLs.")
        _OpenCV_Shutdown()
        Exit
    EndIf
    Return $_aResult[0]
EndFunc   ;==>_cvLoadImage

My problem is $_aResult. It shows as 0 on the second computer (so it's not an array causing the error to flag) while on the first computer it shows nothing (which I assume is because an array won't show up on MsgBox)

I tried compiling x64, x86, and copy pasting the folder with the script to the second computer and running from there, but there was no difference. 

I changed the resolution of both computers to be the same, no difference. 

 

OpenCV-Match_UDF.au3

Link to comment
Share on other sites

The biggest thing that I would recommend looking at first is, is one computer running 32-bit and the other 64-bit, and they're running the scripts at different platform levels? Also, is one running elevated and the other isn't?

Beyond that, are there any dependencies that are required and missing (like dot net runtimes)? Python, or other Visual Studio related things maybe? Try running this on the two systems and show the output for each, mentioning which one is working and which isn't:

#include <Array.au3>
#include <Debug.au3>
Global $aSysInfo[] = [@AutoItX64, @AutoItVersion, IsAdmin(), @CPUArch, @OSArch, @OSBuild, @OSType, @OSVersion]
_ArrayTranspose($aSysInfo)
_DebugArrayDisplay($aSysInfo, 'SysInfo', '', 0, Default, _
        'Script is 64-bit|AutoIt Version|IsAdmin|CPU Arch|OS Arch|OS Build|OS Type|OS Version')

You should get a DebugArrayDisplay which you can copy the data from, or take a screenshot, but it should look something like:

Row|Script is 64-bit|AutoIt Version|IsAdmin|CPU Arch|OS Arch|OS Build|OS Type |OS Version
# 0|1               |3.3.16.1      |1      |X64     |X64    |19044   |WIN32_NT|WIN_10

 As I mentioned, first things first, if the script is 32-bit on one and 64-bit on the other, that's the first thing to correct (using #AutoIt3Wrapper_UseX64=y or =n). Next up would be IsAdmin, which you can fix with #RequireAdmin. Outside of those, look into dependencies. Working on one and not on the other suggests its the environment, not the code (to me).

Edited by mistersquirrle

We ought not to misbehave, but we should look as though we could.

Link to comment
Share on other sites

@Danp2 Great suggestion, i'll look more into why the call to DllOpen is not working for $_opencv_highgui. 

 

@mistersquirrle I ran the debug code on both systems and here are the results of it:

On the working system:

image.png.63d967894ec1c6bbe97cdcec2d0dc6ea.png

Row|Script is 64-bit|AutoIt Version|IsAdmin|CPU Arch|OS Arch|OS Build|OS Type|OS Version
Row 0|0|3.3.14.5|1|X64|X64|19043|WIN32_NT|WIN_10

 

On the problematic workstation:

Capture.PNG.90516e1e37682bdd71d95eed4ed57418.PNG

Row|Script is 64-bit|AutoIt Version|IsAdmin|CPU Arch|OS Arch|OS Build|OS Type|OS Version
Row 0|0|3.3.14.5|1|X64|X64|19041|WIN32_NT|WIN_10

 

I also compile the script as .exe on the working system before running it on both systems, should that take care of the dependencies?

 

Link to comment
Share on other sites

  • Solution

Are you sure that the DLL that you're opening is in the same location on both computers? Just compiling as EXE will take care of anything AutoIt related, so any #include files and all the AutoIt code/dependencies, but it will do nothing for any files that you're opening in the code, like your DLL. You can use FileInstall to include the DLL or other files into the EXE and that way you can carry them with the EXE.

But, is the DLL available on both computers where the program is looking for it?

And other dependencies I'm referencing are things that the DLL may rely on, such as Python or Visual Studio, which have nothing to do with AutoIt.

We ought not to misbehave, but we should look as though we could.

Link to comment
Share on other sites

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...