NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Cross-compiling a C++ code that uses openssl libraries for cRIO 9068

Solved!
Go to solution

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:

2014-11-25 16_34_00-Classtest8-eclipse14-inherited.vi Block Diagram on SharedTest.lvproj_myRIO _.png

Parameter configurations for createBaz:

2014-11-25 16_38_03-Call Library Function.png

Parameter configurations for deleteBaz:

2014-11-25 16_40_11-Call Library Function.png

When I hit run in Labview I get follwing Windows and it doesn't go further.

2014-11-25 16_41_29-Deployment Progress.png

When I click Cancel I get this message:

2014-11-25 16_41_46-.png

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?

0 Kudos
Message 21 of 24
(1,186 Views)

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

Message 22 of 24
(1,186 Views)

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.

Message 23 of 24
(1,186 Views)

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!

0 Kudos
Message 24 of 24
(1,186 Views)