Measurement Studio for VC++

Showing results for 
Search instead for 
Did you mean: 

How to build a DLL using visual C++ 2010

Go to solution

Hello all,


I would like to build a DLL which could be called using the Call Library Function node, using Visual C++ 2010 Express. I am using LabView 2010.


The DLL would be used to read in values from another program, and pass values back from a VI, nothing too fancy.


What I've so far tried is:

in visual c++ selecting file>>new>>project. Then in the window selecting Win32 project, then selecting DLL in the application type menu, and then finish.

This creates a solution containing: stdafx.h, targetver.h, dllmain.cpp, stdafx.cpp, and text.cpp (I called the project test). I write the functions in test.cpp and compile.

I try to write a .def file to try to export the functions, but I can't seem to find a way to make visual c++ 2010 link to it. 

It compiles fine, but when I use the Call Library Function node it finds no functions. I believe this is because I'm not exporting them properly, but I can't figure out how to do it. 


I have seen very good tutorials for older versions of Visual C++, but haven't been able to make them work in the 2010 version. The standard content of the files which make up the DLL (stdafx.h, dllmain.cpp etc) seem quite different from older versions of Visual C++. 


Many thanks for your help



0 Kudos
Message 1 of 3
Accepted by topic author dr8086

This is how my typical dll exported function looks:

extern "C"	__declspec(dllexport) void __stdcall SetCancel(uintptr_t ptrTalkerIn, bool bCancel);

 I don't use a def file. You don't have to use __stdcall, you can use __cdecl, but make sure to select it correctly in LabVIEW when importing the function.



Message 2 of 3

That seems to have done the trick, many thanks. 


I went back and repeated my previous process except this time I ticked a box saying "export symbols", which I had previously left unticked, which created an example function which exports fine and uses the decorator you suggested.

Many thanks for quick reply and resolution of problem.



0 Kudos
Message 3 of 3