prayami Posted January 16, 2007 Report Share Posted January 16, 2007 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.. Quote Link to comment
Rolf Kalbermatter Posted January 16, 2007 Report Share Posted January 16, 2007 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 Quote Link to comment
prayami Posted January 17, 2007 Author Report Share Posted January 17, 2007 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, Quote Link to comment
Rolf Kalbermatter Posted January 18, 2007 Report Share Posted January 18, 2007 Thanks for Reply Rolf KalbermatterSorry 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.