Jump to content

import of "waveform"-dll fails


Recommended Posts

Dear collegues,

together with a programmer I try to implement a dll (in C) into my LabVIEW-code, that converts waveforms (or arrays of waveforms) into a fileformat, we use regularly. We studied the dataformats of LabVIEW --> no problem; he built a dll that uses a waveform as argument --> problem, we are not able to import this, it is also not possible to configure the usage of this dll manually. If I do so: "Error loading "C:\Programme\National Instruments\LabVIEW 2009\user.lib\...\*.dll". Diese Anwendung konnte nicht gestartet werden, weil die Anwendungskonfiguration nicht korrekt ist. Zur Problembehandlung sollten Sie die Anwendung neu insta" Interesting: My WinXP's language is german, my LabVIEW is english. The german part of the message is about: "The application could not be started, because the application's configuration is not correct. For troubleshooting the application should be reinstalled"

Error list:

Call Library Function Node '...*:...': Library not found or failed to load

Why?

It seems, that there apear no problems when we use standard C-datatypes (in test dlls), but the waveform ... this is strange (or we are just beginners)

So, where can I find an example of importing or using a dll for waveforms? And is there probabely a sourcecode available of a very, very simple "waveform-dll"?

I think, I made one mistake: I imported the dll three times, so I have three "import-projects" in the import-assistant. How is it possible to delete these entries? It is not enough to delete the folder in th user.lib.

Thank you for your ideas,

Martin

Link to comment

OK, this is a code snippet of our test-dll.

Comment from my collegue:

The first function using native data types as fct arguments is working without any problems,

the second function which is taking clusters as arguments generates import errors.

///////////////// HEADER FILE FOR LABVIEW IMPORT //////////////////////#include "extcode.h"#pragma pack(push)#pragma pack(1)typedef struct {      float lvDouble;      float lvDouble2;} LVCluster;#pragma pack(pop)int __cdecl createTestFile(const char * fn, const char * str);int __cdecl saveDebugInfoTxt (LVCluster * cluster1, LVCluster * cluster2);////////////////// SOURCE FILE OF DLL /////////////////////////////////#include "stdafx.h"#include "aplbase.h"#include "writeVceDll.h" // standard definitions for afx-dlls#pragma pack (1)typedef struct {      float lvDouble;      float lvDouble2;} LVCluster;#pragma pack()extern "C" __declspec(dllexport) int createTestFile(const char * fn, const char * str);extern "C" __declspec(dllexport) int saveDebugInfoTxt (LVCluster * cluster1, LVCluster * cluster1);__declspec(dllexport) int createTestFile(const char * fn, const char * str){    // create test file 'fn', write 'str' into file.    return 0;}__declspec(dllexport) int saveDebugInfoTxt (LVCluster * cluster1, LVCluster * cluster1){    // get data from clusters and save into ascii file.    return 0;}// this is left as included by VS. we do not write any message handlers// CwriteVceDllAppBEGIN_MESSAGE_MAP(CwriteVceDllApp, CWinApp)END_MESSAGE_MAP()// CwriteVceDllApp-ErstellungCwriteVceDllApp::CwriteVceDllApp(){}// Das einzige CwriteVceDllApp-ObjektCwriteVceDllApp theApp;// CwriteVceDllApp-InitialisierungBOOL CwriteVceDllApp::InitInstance(){    CWinApp::InitInstance();    return TRUE;}

If more information is necessary, I can deliver this. So please do not hesitate to ask for it!

Martin

Link to comment

Dear collegues,

together with a programmer I try to implement a dll (in C) into my LabVIEW-code, that converts waveforms (or arrays of waveforms) into a fileformat, we use regularly. We studied the dataformats of LabVIEW --> no problem; he built a dll that uses a waveform as argument --> problem, we are not able to import this, it is also not possible to configure the usage of this dll manually. If I do so: "Error loading "C:\Programme\National Instruments\LabVIEW 2009\user.lib\...\*.dll". Diese Anwendung konnte nicht gestartet werden, weil die Anwendungskonfiguration nicht korrekt ist. Zur Problembehandlung sollten Sie die Anwendung neu insta" Interesting: My WinXP's language is german, my LabVIEW is english. The german part of the message is about: "The application could not be started, because the application's configuration is not correct. For troubleshooting the application should be reinstalled"

Error list:

Call Library Function Node '...*:...': Library not found or failed to load

Why?

It seems, that there apear no problems when we use standard C-datatypes (in test dlls), but the waveform ... this is strange (or we are just beginners)

So, where can I find an example of importing or using a dll for waveforms? And is there probabely a sourcecode available of a very, very simple "waveform-dll"?

I think, I made one mistake: I imported the dll three times, so I have three "import-projects" in the import-assistant. How is it possible to delete these entries? It is not enough to delete the folder in th user.lib.

Thank you for your ideas,

Martin

Most likely you have the classical problem of C runtime library support. You are developing your DLL in some Visual C version such as 2007 and then distribute the DLL and your LabVIEW code to another computer than where you created it. Since Visual C defaults to link with the multithreaded DLL runtime library your DLL load will fail on a computer that has not installed the according Visual C runtime library.

You can either use an older Visual C compiler that uses runtime libraries that are guaranteed to be available on all modern computers (I use for instance still often VC 6 for that reason, which creates DLLs that would even run on Win95 with any IE version installed. Another solution is to distribute the VC runtime distributables that come with your VC installation on all computers where you want to run this DLL on and the last solution is to change the compile time settings to use the static (non-DLL) version of the runtime libraries. This last one will blow up the size of your DLL a bit but will avoid exactly this problem once and for all.

Not sure about your Waveform. You say there is no problem if you do not use waveforms but I would guess this has more to do about using specific runtime functions in the case when you use waveforms. Also the LVCluster datatype you show in your code example is not really aLabVIEW Waveform but simply a data structure. The native LabVIEW Waveform data type is as far as I know not document since it is a special form of LabVIEW variants which are nowhere documented in terms of their C interface.

Rolf Kalbermatter

  • Like 1
Link to comment

Thank you for your comments. In the meantime I was not lazy and also tried to solve this problem. I got support by NI and they told me, what Rolf's last paragraph says:

The datatype "waveform" is "proprietary" and not documented. It is not a simple cluster.

Therefore we splitted the array of waveforms into it's waveforms and into their components (is this what we call a "workaround" or usual style of working:unsure:?)

Martin

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.