Creating a simple application using CMT

You have seen many packages, and now you want to create your own simple application that uses CMT to handle the compilation.  What do you do?

Here is a simple example, where our application is so simple - it does not even use Gaudi.

Windows

  1. In VCMT, click the new button to create a new package.
    You will have to fill in a name for the new package and assign a version.  v0 is the typical choice.  Finally, choose a directory in which to create this new package.  For this example, we will call the new package, myNewPackage.
  2. The new package name, myNewPackage, should appear in the package list.  Highlight myNewPackage in the package list.
  3. Now click the requirements button to view the empty requirements file.
  4. Fill in the requirements file, here is an example:
    package myNewPackage
    version v0
    # We use GlastPolicy to set up the appropriate compiler settings.
    use GlastPolicy
    ignore_pattern RuleChecker
    application myTestApp myMain.cxx
  5. Our application is named, myTestApp, and has just one source file, myMain.cxx, which contains our main program.  Note that by default, all source files are assumed to be in the myNewPackage/v0/src directory.  If you desire to store your some or all files elsewhere, you must provide a path to locate it.
  6. Create the myMain.cxx file, if you does not exist already.  Here is a simple example:
    #include <iostream>
    int main( int argn, char** argc) {
      std::cout << "We are in the main!" << std::endl;
      return 0;
    }
  7. Back in VCMT, click the setup button.
  8. Now choose the myTestApp in the project drop-down list.
  9. Click build.
  10. Now you can run your application by clicking the run button.

Linux

  1. Use CMT to create a new package.  Within one of your glastpack created directories do:
    cmt create myNewPackage v0
  2. Now edit the myNewPackage/v0/cmt/requirements file.  Here is an example:
    package myNewPackage
    version v0
    # We use GlastPolicy to set up the appropriate compiler settings.
    use GlastPolicy
    ignore_pattern RuleChecker
    application myTestApp myMain.cxx
  3. The above requirements file creates an application called myTestApp which uses just one source file called myMain.cxx.  Note that CMT assumes all source files are located in the myNewPackage/v0/src directory.  If you desire to have some or all files located elsewhere, you will have to supply a full path along with the file names.
  4. Now create the myMain.cxx file, here is a simple example:
    #include <iostream>
    int main( int argn, char** argc) {
      std::cout << "We are in the main!" << std::endl;
      return 0;
    }
  5. Now you can use glastpack to compile the new package as you would any other package.
    glastpack.pl login
    glastpack.pl build myNewPackage v0
    glastpack.pl run myNewPackage v0 myTestApp.exe

 

Back to SAS How To

H. Kelly Last Modified:  2004-08-04 15:39:16 -0700