IBM Support What's New?

How to include Rational Rhapsody external source files into configuration MakeFile

Technote (FAQ)


How can you configure the default setting of IBM Rational Rhapsody Developer Edition for C++ (RiC++) in order to include external source files into MakeFile?


In some cases, you want to import legacy source files into Rhapsody models as external elements. For those externally imported elements (classes and files), Rhapsody doesn't generate code, hence you can preserve legacy code as part of your existing model. However, by default, Rhapsody excludes those external elements from the build even though you turn CG::File::AddToMakefile property on.


For general information regarding code generation for external elements, see "Code generation for external elements" topic in Rhapsody Info Center. This technote will provide 3 solutions to allow the inclusion of external elements into the build.

Solution 1 - Use Component File element

    This method is the most traditional way to include external model elements in the build. For details, you will refer to " Add source file to the build" topic in Rhapsody Info Center.

Solution 2 - Use File/Class element

    Comparing to Solution 1, this method will give you a more granular control by letting you control which individual elements (either Class and/or File) to include in MakeFile. However, this method requires more manual works as compared to other presented solutions.

    Note: The "File" used in this solution refers to ordinary RiC++ File to be created at package level. A "File" created at component level is commonly referred as "File (component)"

    To apply this solution, follow instructions below:
    1. Add a Class/File element to map the external source code into the model.
    2. Set property CG::Class::UseAsExternal as "checked" for the added element.
    3. Set property CG::File::AddToMakefile as "checked".
    4. Set the path to the external file in property CG::Class:FileName to make Rhapsody aware the location of the external source code. The path info would be used in MakeFile generated by Rhapsody.

      Note: Both absolute and relative path are supported.
    5. Right click the model element, from context menu, click Add New > SourceArtifact.

      Note: In order to include this external model element into MakeFile, SourceArtifact is required for the external model element. To enable the display of SourceArtifact, make sure Top Menu > View > Browser Display Options > Show Source Artifacts is checked.
    6. Make sure the type of added SourceArtifact is set either "Logical" or "Implementation" (DO NOT choose "Specification").
    7. Rename SourceArtifact with the name of the external source code (e.g. rename the element to "hoo", if the external file name is "hoo.cpp").
    8. Click [Elements] tab of the SourceArtifact to make sure the model element is correctly mapped in SourceArtifact. In case of Class, the mapping will be done automatically. For File, manually add its parent element to [Elements] tab as below:

      IMPORTANT: You might occasionally find the behavior of File is not consistent with Class. This is because File element is designed to be used as external element only, and not supposed to be built from Rhapsody. You are encouraged to use external Class element in RiC++ model to avoid any confusion you might experience.
    9. Generate MakeFile to make sure the external source file (e.g. hoo.obj) file is being added in the build.

Solution 3 - Use Additional Sources setting

    This method is the simplest way. All you need to do is to add the path to external source files directly into [Additional Sources] field on [Settings] tab of the model configuration.

    You can add multiple external source files by separating with comma.

Related information

Code generation for external elements
Add source file to the biuld

Document information

More support for: Rational Rhapsody
General Information

Software version: 7.5,, 7.5.1,, 7.5.2,, 7.5.3,,,, 7.6,, 7.6.1,,,, 8.0, 8.0.1

Operating system(s): Linux, Windows

Reference #: 1621937

Modified date: 2013-02-01