Nested IDL problem

5 posts / 0 new
Last post
Offline
Last seen: 6 years 4 months ago
Joined: 10/18/2017
Posts: 13
Nested IDL problem

Hi everyone!

I'm new with RTI and DDS and I'm trying to generate code from 2 IDL files and compile it.

I'm trying with the Foo/Bar example, so the foo.idl file is:  

#ifndef FOO_IDL

#define FOO_IDL

struct Foo { long data; };

#endif

the bar.idl code is:

#ifndef BAR_IDL

#define BAR_IDL

#include "foo.idl"

struct Bar { Foo foo; };

#endif

I use the following commands to generate the code from RTI:

rtiddsgen -language C++11 -example x64Win64VS2015 <foo.idl path>\foo.idl

it works fine and the build in VS2015 works too.

Now I try the same with the bar.idl file but adding a specification to the foo.idl path:

rtiddsgen -language C++11 -example x64Win64VS2015 -I <foo.idl path> <bar.idl path>\bar.idl

this time the code generation works but when i try to build the solution in VS2015 I got some errors with Code C1083: "Cannot open include file foolmpl.h: No such file or directory"

Anyone knows why this happens?

 

What I need is to have different IDL files and to create a nested structure, I know it is possible to do it writing everything in the same IDL file but it is not my case.

Thanks

Francisco Porcel's picture
Offline
Last seen: 2 days 12 hours ago
Joined: 11/07/2016
Posts: 24

Hi Luigi,

It looks like Visual Studio is not able to find foolmpl.h. It seems that the location of foolmpl.h is not in the "include directories" section of the Visual Studio project. I think that you may find the information in this article very useful, since it seems that it is the same use-case you are trying to create: https://community.rti.com/kb/how-generate-code-base-and-derived-idl-separate-dll-files

Please, let me know if it helped.

-Fran

Offline
Last seen: 6 years 4 months ago
Joined: 10/18/2017
Posts: 13

Hi Francisco,

I tried to follow your guide with the base-derived example but I have encountered a problem when I try to run the .exe files because the derived publisher/subscriber does not find the base publisher/subscriber.exe.

What I want to do is to create a .lib file with only the header files as it is suggested in this topic---> https://community.rti.com/comment/2356#comment-2356

Do you know where is it the error? Do you have other tips?

Thanks,

Luigi

Francisco Porcel's picture
Offline
Last seen: 2 days 12 hours ago
Joined: 11/07/2016
Posts: 24

Hi Luigi,

I just reproduced your issue. I guess that your bar application is linked dynamically. Then, when you launch bar_publisher.exe, it will try to take foo_publisher.exe as if it was a DLL file. If you add to your PATH variable the location of foo_publisher.exe, running bar_publisher.exe should work. If you follow bullet point 2 from "How to compile a derived project in C++/CLI" on the article that I provided, you will see how to change that .exe to .dll.

If you link your application statically, you will need to add the foo_publisher.lib file as explained in bullet point 4 of "How to compile a derived project in C/C++".

-Fran

Offline
Last seen: 6 years 4 months ago
Joined: 10/18/2017
Posts: 13

Hi Fran,

I'm trying to follow your tips, this is what I have done (using the base/derived example):

  1. Generated code for base.idl file and before compiling I forced the creation of .dll library and put Linker->General->Output File to <inherit from parent or project defaults> for both base_publisher and base_subscriber projects (as it is suggested in your article).
  2. Defined NDDS_USER_DLL_EXPORT_BASE in the preprocessor properties of every base project and built them.
  3. Generated code for derived.idl file and, for each derived <publisher/subscriber> project, I added in Linker->Input->Additional Dependencies the complete path to base_<publisher/subscriber>.lib
  4. For each derived <publisher/subscriber> project I tried to add references to the <publisher/subscriber> base .dll libraries but they are not showed in the Add References menu and I do not see a Browse command. If I add to the same solution all the projects (2 base and 2 derived) in Add References I can only choose to add the <base_publisher/base_subscriber>.vcxproj file.
  5. Built the derived projects.

I think there is someting missing since I cannot follow the step 4 correctly. In fact when I try to run derived_publisher.exe I get an error message telling me that it does not find the base_publisher.dll file as I was expecting...

 

EDIT:

I found out that the problem was that I was running the derived project from a random folder, if I go in the base\obj\<architecture> folder (where the base .dll files are) and I run the derived pub\sub it works.

Do you know if there is a way to make it easier?

Thanks,

Luigi