Jump to content

Static C data in LabVIEW


Recommended Posts

Hi,

We have a big library written in C. And we want to use that library into LabVIEW. I know that if we make DLL and call that DLL into LabVIEW, that is the best option. But

the problem is there are some static class and data defined in three files. Problem is, if we use DLL then static class will not work with DLL.

Is there any way we can use this static class and data into LabVIEW but they still be static e.g. ActiveX or Any other. I also know that we can create CIN but the

problem is we have to do quite a lot addtional work and if the user will have the different versions of LabVIEW then we have to again build CIN for that version and

distribute. And that is again not practical solution.

Any help appreciated.

Thanks..

Link to comment
Hi,

We have a big library written in C. And we want to use that library into LabVIEW. I know that if we make DLL and call that DLL into LabVIEW, that is the best option. But

the problem is there are some static class and data defined in three files. Problem is, if we use DLL then static class will not work with DLL.

Is there any way we can use this static class and data into LabVIEW but they still be static e.g. ActiveX or Any other. I also know that we can create CIN but the

problem is we have to do quite a lot addtional work and if the user will have the different versions of LabVIEW then we have to again build CIN for that version and

distribute. And that is again not practical solution.

Any help appreciated.

Thanks..

What do you mean by a static class? Standard C has to the best of my knowledge nothing with that name and it rather sounds like a static C++ class you are talking about. And the Call Libary Node can not deal with anything that is C++ related. What you probably could do however is writing standard C function wrappers to all the methods of your static class and export them from your DLL.

Rolf Kalbermatter

Link to comment
What do you mean by a static class? Standard C has to the best of my knowledge nothing with that name and it rather sounds like a static C++ class you are talking about. And the Call Libary Node can not deal with anything that is C++ related. What you probably could do however is writing standard C function wrappers to all the methods of your static class and export them from your DLL.

Rolf Kalbermatter

Thanks for Reply Rolf Kalbermatter

Sorry by static class, I meant static class instance.

e.g. For class My_Class, If I use following statement

static My_Class mc;

Will this be work ? And you said : "writing standard C function wrappers to all the methods of your static class and export them from your DLL"

Please let me know, what should I do to write standard C function wrappers? I understand export from DLL. But confuse with wrapper.

And the question is, will it make my class instance same as static. If I open different exe file and load dll file in that then it should get the same

instance (or same memory space as static) of static My_Class mc;

Thanks,

Link to comment
Thanks for Reply Rolf Kalbermatter

Sorry by static class, I meant static class instance.

e.g. For class My_Class, If I use following statement

static My_Class mc;

Will this be work ? And you said : "writing standard C function wrappers to all the methods of your static class and export them from your DLL"

Please let me know, what should I do to write standard C function wrappers? I understand export from DLL. But confuse with wrapper.

And the question is, will it make my class instance same as static. If I open different exe file and load dll file in that then it should get the same

instance (or same memory space as static) of static My_Class mc;

Thanks,

class is a C++ only thing and therefore will never work with the Call Library Node. With wrapper I meant to write a standard C function for each method you want to call in your class. Probably something like following but my C++ is very rusty and not really good.

#ifdef __cpluscplus

extern "C" {

#endif

int FirstMethod(int arg1, int arg2);

......

#ifdef __cpluscplus

}

#endif

static My_Class mc;

int FirstMethod(int arg1, int arg2)

{

return mc->FirstMethod(arg1, arg2);

}

etc......

You can do the same for dynamic classes but then you will have to pass the object pointer as extra parameter in your wrapper function and you also need to create extra functions to create and dispose the object pointer.

Rolf Kalbermatter

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.