LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visual Studio DLL issues

I'm unable to use Visual Studio 2022 to compile a DLL and integrate it via the Call Library Function VI. 

 

When I compile a simple DLL using Visual Studio 2022 the Call Library Function reports an error "Library not found or failed to load" : "The library specified for this node cannot be found or cannot be loaded. Right-click the Call Library Function node and select Configure, then choose the correct library name or path."

 

However I have an old installation of Visual Studio 2013 on my machine, and the same source code compiled with the 2013 version produces a DLL which works. 

 

In both cases I'm using the default DLL template from Visual Studio when creating my solution. I've tried loading the DLLs into 64bit Labview 2016 and Labview 2020 - in both cases only DLLs built with VS2013 work.

 

My source code is very simple:

 

#include "pch.h"  //for 2013 this is "stdafx.h"

extern "C" __declspec(dllexport) void add(double x, double y, double* result);

__declspec(dllexport) void add(double x, double y, double* result)
{
*result = x + y;
}

 

I've tried comparing the project settings (e.g. C/C++, linker settings, etc) between VS 2022 and 2013 but there are so many. Is this a compatibility issue with the Windows SDK Version and platform toolset in VS2022?

 

What version of VS is recommended, does it depend on the target Labview version?

 

Attached built DLL files.

 

Download All
0 Kudos
Message 1 of 3
(1,121 Views)

LabVIEW 32-bit trying to access a 64-bit compiled DLL? Or vice versa?

 

Also those DLLs are both compiled as Debug version and refer to the debug runtime. They only can run on a Windows system on which you installed the full Visual Studio IDE. Debug DLLs are not for redistribution. you can't even get a seperate runtime installer for those C runtime DLLs, but even if you copy them by hand, you have legally no right to distribute them to another computer.

 

They both wouldn't load on my computer as I have neither Visual Studio 2013 nor a newer version installed.

 

If you don't try to run them on the system on which you compiled them, build a Release version instead and make sure to install the matching C Runtime Redistributable Installer for your Visual Studio version.

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

Thanks, I expect you're right. VS2013 is installed on the same machine as my labview installs whereas VS2022 is on a separate device and I didn't realize the requirement for installing the runtime redistributable. 

 

I was trying to load both 64bit DLLs with 64 bit Labview, not 32.

 

David

0 Kudos
Message 3 of 3
(1,098 Views)