Search code examples
windowsvisual-studio-2017taoopendds

OpenDDS - Solution builds fine, examples run, but IDL exes crash


I have successfully built OpenDDS 3.13.2 from source. Here is my environment:

  • Windows 10
  • Visual Studio 2017 (re-targeted Solution to SDK 10.0.17763.0)
  • Tried all Configuration/Platform combinations

I successfully used the configure script from the VS command prompt, built everything by opening the generated solution in the same command prompt, and finally ran the Messenger example (publisher and subscriber), and even configured it to use RTPS successfully.

However, when I try to create my own IDL and use the tao_idl, it crashes. Here's my test (using the proper environment from setenv.cmd):

> tao_idl (no args)

IDL: No input files

Second test:

> tao_idl Test.idl (crashes)

I get no error message, and am unable to locate logs or any indication of what went wrong. The same thing happens when I used opendds_idl.

What is the best approach to debug this, and/or are there pre-built binaries available for the IDL compiler(s) (both TAO and OpenDDS)?


Solution

  • After about a day of troubleshooting, I have determined a solution. Despite being able to call tao_idl and opendds_idl yourself, you should basically never do it. There are a good amount of command-line arguments needed to get both to work, and if they're not present, each exe will crash without the proper reasoning why.

    I will add my steps below to create a new basic two-exe pub/sub project using OpenDDS:

    1. Create your own IDL file.
    2. Starting with the DCPS Messenger example, modify the .mpc file, replacing Messenger.idl with your IDL file name.
    3. Create a new file called <your project>.mwc, and add the following contents:

      workspace {
        // the -relative and -include cmdlines make it so this workspace 
        // does not have to be in the $DDS_ROOT directory tree.
      
        // tell MPC to substitute our DDS_ROOT environment variables for relative paths
        cmdline += -relative DDS_ROOT=$DDS_ROOT
      
        // tell the projects where to find the DDS base projects (*.mpb)
        cmdline += -include $DDS_ROOT/MPC/config
      
      }
      
    4. Open a new VS command-line terminal and run $DDS_ROOT/setenv.cmd, or open a regular terminal if you have those environment variables set via Windows settings.

    5. Navigate to your project directory and call: mwc.pl -type vs2017, replacing "vs2017" as needed for your build tool/IDE.

    6. Open up the generated solution, and retarget it as necessary for your Windows SDK version.

    7. Build the <your project>_IDL project first. If you notice in the output window, it is invoking the tao_idl and opendds_idl commands automatically. You can view the .vcxproj files to see the full command-line arguments that were the original problem.

    8. Modify the publisher.cpp, subscriber.cpp, and DataReaderListenerImpl.cpp files to match your new IDL. Run the example as usual and ta-da!

    For completeness, the full commands for both tao_idl and opendds_idl are as follows:

    > opendds_idl -Sa -St "<your file>.idl"
    
    > tao_idl -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -Sa -St -I$(DDS_ROOT) "<your file>.idl"
    
    > tao_idl -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -Sa -St -I$(DDS_ROOT) "<your file>TypeSupport.idl"