LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[Urgent!] DLL call problem because of "The specified module could not be found(ERROR 126)"

Solved!
Go to solution

Hi all,

 

I create a "A.dll" in Visual Studio 2015, another "B.dll" is loaded explicitly in "A.dll". I also make a test program in Visual Studio 2015, it called "A.dll" implicitly(statically) and "B.dll" can be loaded by "A.dll" normally. All of them look great. After that I integrate the "A.dll" into LabView and also put "B.dll" in the same folder.

 

But it always fails in the LabView when A.dll loads "B.dll". I add some debug information and find the error code is 126(The specified module could not be found).

 

I have tried to add the path of "B.dll" into the VI search Path of LabView, and I also put "B.dll" into /windows/system32 folder, the problem cannot be resolved. 

 

Could you please tell me the reason and how to resolve it?

Thanks a lot!

 

Best regards,

David 

 

----------------------------------------------------------------------------------------------------------

PS:

1. The code segment of A.dll is shown as below:

-----------------------------------------------------

hwinIoDll = LoadLibrary(L"B.dll"); 

return GetLastError();  // debug information to find the error code.

-----------------------------------------------------

 

2. The test program segment is shown as below: (Successfully executed in Visual Studio2015)

---------------------------------------------------

int main()
{
    int ret_val = 0;

 

    ret_val = initFunc();   //The initial function of A.dll, it will execute LoadLibrary(L"B.dll").

    if (ret_val == 0)
    {
        cout << "Load successfully!" << endl;
    }
    else
    {
        cout << "Load failed, error id is:" << ret_val << endl;
    }

    .....

}

---------------------------------------------------

 

3. I convert the initFunc() into LabView. (Always failed while loading B.dll)

 temp.jpg

 

0 Kudos
Message 1 of 3
(3,797 Views)
Solution
Accepted by topic author David_ww

LabVIEW does not resolve the loading of dependent DLLs. That does Windows. But Windows does not know about the LabVIEW search path or anything. Instead Windows looks in a few specific locations:

 

1) first if the DLL with that name is already loaded in memory.

2) Then in the directory the executable for the current process is located. This is the directory where LabVIEW.exe is located when you run it in the IDE and yourapp.exe when you build an application with the executable name yourapp.

3) The current directory. Forget this one, it's a command line feature from old DOS days and various things in Windows GUI apps can change that arbitrarily, so it is not reliable.

4) The Windows System directory. Please note that this is System32 on a 32 bit Windows system (your DLL needs to be compiled as 32 bit DLL), but SysWOW64 on a 64 bit system if you use LabVIEW 32 bit (your DLL needs to be compiled as 32 bit DLL too), and System32 on a 64 bit Windows system if you run LabVIEW 64 bit (your DLL needs to be compiled as a 64 bit DLL too).

5) The Windows directory

6) The directories listed in the PATH environment variables.

 

And that's it. So you have to put your B.dll in one of these places.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 3
(3,755 Views)

Hi Rolf,

 

As you mentioned, the problem is resolved. Thank you very much!

 

Best regards,

David

0 Kudos
Message 3 of 3
(3,740 Views)