10-13-2012 08:17 AM
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
Solved! Go to Solution.
10-13-2012 08:31 AM - last edited on 11-14-2024 02:05 PM by Content Cleaner
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: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x1OvCAI&l=en-US
10-13-2012 08:59 AM
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
10-13-2012 10:22 AM
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.
10-15-2012 02:57 PM - last edited on 11-14-2024 02:05 PM by Content Cleaner
@.aCe. wrote:
More details here: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x1OvCAI&l=en-US
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