LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call a dll for Labview: Function not found in library

Solved!
Go to solution

Hello,

I am trying to call a very simple .dll form Labview. I compiled the .dll for x64 using Visual Studio 2010, because I am using Labview(64-bit). I did everything exactly the way I read it in several Tutorials. But the "Call Library Function Node" doesn't create a popup menu with the avalible functions like it is supposed to do. The Import Wizard doesn't find any functions neither. What is wrong with my .dll?

 

I added a block marked 'extern "C" ' into my source file, but it still won't work.

 

Thanks

 

Matthias

0 Kudos
Message 1 of 5
(3,782 Views)

You need to define an entry point to the DLL

 

BOOL APIENTRY DllMain( HANDLE hModule,
                        DWORD  ul_reason_for_call,
                        LPVOID lpReserved )
{
    return TRUE;
}

 

Also add extern "C" __declspec(dllexport) to your functions

 

More details here: http://www.ni.com/white-paper/3056/en


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 2 of 5
(3,779 Views)

I read this article before, but I don't understand it. Where do I add the entry? In the *.cpp or in the *.h? If I simply copy it I get several syntax errors. I added the extern "C" already to the source file. If I add it to the header-file I get another error.

 

They should have added the source files so it would be a lot easier to understand.

 

Thanks

 

Matthias

0 Kudos
Message 3 of 5
(3,773 Views)
Solution
Accepted by topic author steinhagelvoll

You did not read the article correctly. Re-read Step 3. In the .cpp file you add "__declspec(dllexport)" before the function's body. In the header file you add extern "C" at the beginning of the prototype. This is to deal with the name-decorating that C++ compilers do.

Message 4 of 5
(3,765 Views)

@.aCe. wrote:

 

More details here: http://www.ni.com/white-paper/3056/en


This Tutorial is a little outdated. Visual Studio creates a file called 'dllmain.cpp' which contains the BOOL APIENTRY DllMain function. Therefore I did not need to add it to my source file. The solution was to add an ' extern "C" __declspec(dllexport)' before the declaration and "__declspec(dllexport)" before the definition of the function.

 

Thank you very much

 

Matthias

 

0 Kudos
Message 5 of 5
(3,720 Views)