Problem using C generated files in C++ app

4 posts / 0 new
Last post
Offline
Last seen: 10 years 3 months ago
Joined: 05/28/2014
Posts: 8
Problem using C generated files in C++ app

A little background..what I ultimately want to have is a C DLL used by a C++ app. I started running into some problems, and was able to duplicate the issue using the CPP/Hello_idl example.

To duplicate:

1) Open the CPP/Hello_idl example (I'm using i86Win32VS2010)

2) Delete the generated files from the project and disk (the ones in "Type Plugin Files")

3) In the Custom Build Step for "HelloWorld.idl", change the command line option to generate C code instead of CPP ("-language C++" becomes "-language C")

4) In the Outputs section of the Custom Build Stop, change the ".cxx" extensions to ".c"

4) Compile "HelloWorld.idl"

5) Add the ".c" and ".h" generated files to the project

6) Build the project

I get unresolved externals for HelloWorldTypeSupport::register_type, get_type_name, and quite a few others.

I'm sure I'm missing a preprocessor directive or option to rtiddsgen, but so far I haven't been able to figure it out.

Any help is greatly appreciated!

 

 

Gerardo Pardo's picture
Offline
Last seen: 1 week 2 days ago
Joined: 06/02/2010
Posts: 602

Hi,

What you are trying to do is certainluy possible.

If I understood correctly you started with the Hello_idl example found in the examples/CPP/Hello_idl directory, and then modified it to try to build C instead of C++. Is this corrrect?

Rather than doing this I would suggest you start from examples/C/Hello_idl  which already has a project prepared to build in C. Or alternatively you can start directly from any IDL file and use:

 rtiddsgen -language C -example i86Win32VS2010   IDLFILENAME.idl   

This should generate the correct visual studio project and the supporting files.

Most likely what is happening if you indeed started from a C++ VS project is that there are some macros remaning in your (originally C++) visual studio project that are not correctly defined so it still thinks it is using a C++ API to DDS in some places and hence the undefined symbols.

Gerardo

Offline
Last seen: 10 years 3 months ago
Joined: 05/28/2014
Posts: 8

Thanks for the response!

A little more background on what I am trying to do might help...I need a library of IDL messages that I can distribute to other developers that they would then integrate into their existing applications. Those applications are written in C++, java, and python. My thinking is that developing my library as a C DLL would be the most flexible way to go. Java and python integration has not been a problem, only C++.

So, what I really need to figure out is how to link a C++ application with a DLL that contains C files generated by rtiddsgen. When I started encountering problems doing this I kept working backwards to the simplest way to duplicate the problem, which is in my original post.

Thanks again for any help.

Offline
Last seen: 7 years 6 months ago
Joined: 06/06/2017
Posts: 1

C++ app is really cool. You can get the latest version of C++ app from tutu app store. You can get the tutu app from this official website. All latest paid applications are available on this app for free.