Version 19 (modified by 19 years ago) (diff) | ,
---|
How do i begin playing with CMT ?
by V.Garonne
Date: 05.4.2005
Version : 0.1
A package creation: The classic Hello world example
We do here the classic "Hello World" example with CMT. First we create the cmt package called "test" with version 1:
> cmt create test v1 ------------------------------------------ Configuring environment for package test version v1. CMT version v1r18p20050501. Root set to /users/dsksi/garonne. System is Linux-i686 ------------------------------------------ Installing the package directory Installing the version directory Installing the cmt directory Installing the src directory Creating setup scripts. Creating cleanup scripts. > cd test/v1 > ls cmt src
We see here that a directory tree has been created. We now create and writte our small "C++" program (main.cxx, hello.h and hello.cxx).
We have:
> more src/hello.h ////////////////////////////////////////////////// // author: vincent garonne // // date: 4/5/2005 // // description: hello world description file // ////////////////////////////////////////////////// #ifndef __HELLO_WORLD__ #define __HELLO_WORLD__ class hello { public: // constructor hello () {} // desctructor ~hello (){} // function example void print (); }; #endif // __HELLO_WORLD__ > more src/hello.cxx ////////////////////////////////////////////////// // author: vincent garonne // // date: 4/5/2005 // // description: hello world body // ////////////////////////////////////////////////// using namespace std; #include <iostream> #include "hello.h" void hello::print () { cout<<"Hello le world !!!"<<endl; } > more src/main.cxx ////////////////////////////////////////////////// // author: vincent garonne // // date: 4/5/2005 // // description: main program // ////////////////////////////////////////////////// #include "hello.h" int main () { hello object; object.print(); return 0; }
Then to construct the executable, we need to specify within the "requirements" file in the cmt directory :
> cd cmt > more requirements package test author Vincent Garonne <garonne@lal.in2p3.fr> application test hello.cxx main.cxx
Now we can compil and execute:
> cmt make ... > source setup.csh > ../Linux-i686/test.exe Hello le world !!!
By default the executable has been put in the Linux-i687 directory.
The library creation
To create the hello library, it need to specify one more line in the requirements file.
> more requirements package test author Vincent Garonne <garonne@lal.in2p3.fr> application test hello.cxx main.cxx library hello hello.cxx > cmt make ... > ls ../Linux-i686/libhello.* ../Linux-i686/libhello.a ../Linux-i686/libhello.so
Two libraries has been built.