08-31-2016 07:41 PM
So my dummy C++ library has a class myClass which permits the setting and getting of some private variables via member functions is wrapped in some C in exactly the same way as the real vendor library and no supprises LV throws the same error (13)
The dummy library and wrapper are at: http://stackoverflow.com/questions/20792121/wrap-c-namespaced-enum-to-c-interface/39003347#39003347
On the other hand, a pure C library which has three functions int_add(int i, int j), int_subtract(int i, intj) and int_multiply(int i, int j) whose opperation is probably self explanatory works no problem when called via LV and I'm happy to report that 3 * 2 is indeed 6. So we know my setup on the target is ok and my understanding of the LV CLFN is ok too.
Not sure how I'm going to get out of this one. One possibility is to create the C++ object in the wrapper and don't pass the pointer back to LV but instead manipulate the object via C accessor functions in the wrapper. I'm not sure how I'll impliment call backs though. I'll need to figure out why it doesn't work first before trying to fix it...
08-31-2016 09:48 PM
Silly question, are you making sure to wrap the function entrypoints you want to access from LV in an extern "C" block?
09-01-2016 06:30 AM
I am afraid so...
My minimal wrapper for a similarly minimal C++ lib (which is the focus of all my attention now) is at:
http://stackoverflow.com/questions/20792121/wrap-c-namespaced-enum-to-c-interfac e/39003347#39003347
Current job is getting that to work.
James
09-01-2016 08:49 AM
Well, I just had to check to make sure. Are you using that exact example and attempting to get that working, or simply using it as a guide? Unfortunately, I'm going to be out all next week but it's beneficial for others who can help out to know where you're working from.
09-01-2016 10:26 AM
That stackoverflow page is the exact code I'm working on at the moment. Obviously it does nothing useful but it is small enough to find the errors I hope. i have noticed that in some LV documentation it shows the extern statement around the header only, I'll try that now. Also in the first of the links below it seems that one can not call a secondary library without allocating appropriate memory in the primary library. I have not done this so I'll give that a go too.
Found these:
https://zone.ni.com/reference/en-XX/help/371361M-01/lvexcodeconcepts/debug_dlls_and_dll_calls/
https://zone.ni.com/reference/en-XX/help/371361M-01/lvhowto/building_function_prototype/
May also prove useful for people reading in the future.
Have a nice holiday! (assuming it is a holiday...)
09-01-2016 06:05 PM
So, it turns out that I am a bit of a fool...
I had a working test C program that called my minimal wrapper library which in turn called the minimal C++ library. However I was very careless about how I linked the libraries. I linked both to the test C program! Of course when I use the wrapper in LV it can't find the symbols for the missing C++ library as it is not linked to the wrapper but is linked to a C program which is replaced by LV, hence the error 13.
Recompile (and link) everything properly and the minimal example works. Including passing pointers back from the C++ class into labview via the C wrapper. I'll write something proper up to demonstrate the entire process and post it in the next few days. It might be an idea to turn it into an official NI "idiots guide to wrappering C++ for LV" as there is a lot of C++ in the world and a lot of idiots like me.
03-28-2017 09:28 AM
Hello,
do you have any progress? I have MicroEpsilon TIM 400 - this should be the same as Optris as MicroEpsilon bought Optris (at least this is information I have). Anyway, to use the camera on RIO would be perfect.
Any info appreciated.
Josef