You are on page 1of 3

Compiling, Linking, and Running Simulation Models with Psim3 and C++ Note: the Psim3 library was

ompiled using the !N" ompilers #Linu$ and %indows&' (' "sing a Command %indow on Mi roso)t %indows
*n an appropriate dire tory #)or e$ample, +models,&, pla e the C++ programs, the header )iles, the Psim3 library ompiled with the C++ !N" ompiler )or %indows, +libpsim'a,' -o ompile, link, and reate an e$e utable )ile on the .*S prompt, use the +psim3'bat, bat h )ile /or e$ample to ompile and link the )ile +batmio' pp,, type the )ollowing ommand: C:\models> psim3 batmio.cpp -o e$e ute the program and run the orresponding simulation model, type the name o) the de)ault e$e utable )ile: C:\models> a.exe -o redire t the output to a )ile +simul't$t,:

C:\models> a.exe > simu1.txt

0' "sing CS3 Linu$ Ser1er


(t 2ennesaw State "ni1ersity #2S"&, .epartment o) Computer S ien e and 3n)ormation Systems, we mainly use the CS3 ser1er that runs under Linu$ #Red 4at Linu$ 5nterprise 6'7&' *n CS3, the Psim3 library, the header )iles, and the simulation models are stored in the )older: +8home89garrido8psim3,' -he ompiler used to reate the Psim3 library is the !N" C++ ompiler'

-o onne t to CS3, use Se ure Shell instead o) :telnet:' Conne t to + s3'kennesaw'edu,' %hen you are onne ted to CS3, type your user name, then your password' %hen using a similar system with Linu$, arry out the )ollowing hanges to the spe i)ied )iles supplied on the C.' -he s ript )ile to ompile and link a C++ program with the Psim3 and Pthreads libraries is +psim3;linu$,' -his )ile should be renamed to +psim3,' -he library +libpsim3;linu$, should be renamed to +libpsim3'a,' *n the Linu$ *perating System, the <bash< shell, is the de)ault shell )or Linu$' ()ter you login, Linu$ types a dollar sign #=& as the system prompt' -his indi ates that the *S is waiting )or a ommand' 3t is re ommended that you reate a working dire tory )or your )iles under your root dire tory' >ou an use the :mkdir: ommand to make a new dire tory under the urrent dire tory, then hange to the new dire tory with the : d: ommand' Copy the appropriate )iles: the :psim3: s ript )ile and the )iles that implement the desired simulation model' /or e$ample: <bat h' pp<, and <bats9)' pp<' 3n "ni$, the dot #'& indi ates the urrently working dire tory' -o opy the rele1ant )iles )rom the :8usr8psim3: system publi dire tory #on CS3&, type the )ollowing ommands

$ cp /home/jgarrido/psim3/batch.cpp . $ cp /home/jgarrido/psim3/batsjf.cpp . $ cp /home/jgarrido/psim3/psim3 .

C' "sing Linu$ "buntu


-he Psim3, library, header )iles, and C++ programs are stored on ar hi1e )ile +psim3;Linu$;ub'tg?,, whi h an be downloaded )rom the Psim3 web page' Copy, and e$tra t the )iles using @tarA ommand'

.' "sing the Simulation So)tware Pa kage


-o edit a te$t )ile #C++ sour e )ile&, use the +nano, editor on the Linu$ ser1er #CS3&, type the )ollowing ommand:

$ nano batch.cpp
-o ompile, link, and reate the e$e utable )ile Ba'outC with the +bat h' pp, )ile, type the )ollowing ommand:

$ ./psim3 batch.cpp

-he two hara ters :'8: must be in luded be)ore any ommand #e$e utable or s ript )ile& that are stored in your working dire tory' -he abo1e ommand ompiles the C++ sour e )ile and links to the Psim library' -his produ es an e$e utable )ile alled :a'out:, by de)ault' -o rename the e$e utable )ile +a'out, to <bat h<, type this ommand:

$ mv a.out batch
-o run the e$e utable program produ ed abo1e:

$ ./a.out
-o redire t the output to a )ile :simul't$t:: $ ./a.out > simu1.txt -o read the +simu7't$t, )ile, whi h is your programAs output, use this ommand:

$ more simu1.txt -o trans)er the output )ile )rom the CS3 ser1er to your PC, use a )ile trans)er utility program, su h as SS4 Se ure /ile trans)er'

You might also like