11-25-2014 09:46 AM
I'm again in a very helpless situation. I tried a lot of things but it didn't work.
I'm now pretty sure that the problem is that Labview can't handle with inherited Classes. I reduced my intention to a small example. Let's say I have two Classes: Foo and Baz. Baz is inherited from Foo. I want just to create an object from Baz and want to give the pointer to this object to Labview. And delete this object afterwards.
So my main.cpp looks like this:
#include "baz.h"
extern "C"
{
void* createBaz();
void deleteBaz(void* in);
}
void* createBaz()
{
Baz* out = new Baz();
return ((void*)out);
}
void deleteBaz(void* in)
{
delete ((Baz*)in);
}
baz.h looks like this:
#include "foo.h"
class Baz : public Foo
{
public:
Baz();
~Baz();
};
and foo.h looks like this:
class Foo
{
public:
Foo();
~Foo();
};
With these source files I cross compiled a shared library (.so) with Eclipse 2014 which was offered from NI. I used this manual: http://www.ni.com/tutorial/14690/en/ After that I put the compiled .so file on myRIO(under /usr/lib/). To use it I made small VI in Labview which has only two Call Library Function Nodes and a connection wire between them. Like this:
Parameter configurations for createBaz:
Parameter configurations for deleteBaz:
When I hit run in Labview I get follwing Windows and it doesn't go further.
When I click Cancel I get this message:
I would be very happy if someone has a advice for me. When I'm trying it without inherited classes it works without problems. Is there something to change when working with inherited classes?
11-25-2014 09:58 AM
If it was me running into this issue, I would use the readelf utility that came in the cross-compile toolchain that you're using to investigate the binary. If things look fine, I would install the same utility on the target (in the binutils or binutils-symlinks package) and check that things still look good on the target
11-25-2014 11:19 AM
I agree with Brad that you need to dig into this a bit with the standard tools from the cross-compile toolchain (along with Brad's suggestions I would recommend "nm"); online references are best for that as there are many more experts in those tools in the wider internet than there are on this forum. That said, I can confirm we call C++ code from LV without issues in various components. At a quick glance one question I would have about the code pasted above is where the Foo and Baz constructors and destructors are defined, I see declarations but no definitions. They may exist somewhere but they're not in your pasted code and from the error you're getting it appears they're not compiled in.
11-26-2014 08:48 AM
Thank you BradM and ScotSalmon!
As ScotSalmon said, it was because of the constructers and destructors why my example didn't work. So I figured out that inherited classes are not the problem.
I just came to the solution. My problem was that I didn't link the external libraries properly to my created library. Now everything is working fine. Thank you for pointing me to the right direction!