[r235]: trunk / Cm / Documentation / GettingStarted / Main.tex  Maximize  Restore  History

Download this file

378 lines (302 with data), 14.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
\documentclass[a4paper,oneside,11pt]{article}
\begin{document}
\title{Getting Started Guide 1.2}
\author{Seppo Laakko}
\date{\today}
\maketitle
\section{Installation}
\subsection{Installation in Windows}
\begin{itemize}
\item Download and run \textbf{cmajor-0.5.0-win-x86-setup.exe}
(for 32-bit and 64-bit Windows) or
\textbf{cmajor-0.5.0-win-x64-setup.exe} (for 64-bit Windows).
\item Cmajor is installed by default to
\verb|C:\Program Files\Cmajor-0.5.0| directory (32-bit version) or to
\verb|C:\Program Files (x86)\Cmajor-0.5.0| directory
(32-bit and 64-bit versions under 64-bit Windows)
Note: The x64 version is also installed by default under\\
\verb|C:\Program Files (x86)| directory although the programs are genuingly 64-bit versions).
This is due to restrictions of InstallShield Limited Edition.
You may want to change the install location under
\verb|C:\Program Files| directory in this case.
\item The setup adds \verb|C:\Program Files\Cmajor-0.5.0\bin| directory (or whereever you installed it) to your systems \verb|PATH| environment variable, so the Cmajor programs can be executed from any directory from the command prompt without specifying full paths.
\item The setup also adds a \verb|CM_LIBRARY_PATH| environment variable and sets it to contain a path to the Cmajor System Library directory that is
\verb|%APPDATA%\Cmajor-0.5.0\system|.
If you need to modify the \verb|CM_LIBRARY_PATH| environment variable, you can find it from the \emph{Advanced System Settings} pane in the \emph{System} Control Panel.
In my computer the \verb|%APPDATA%| points actually to the\\
\verb|C:\Users\Seppo\AppData\Roaming\| directory.
The \verb|AppData| folder is hidden by default.
To see it you will have to modify the settings in the \emph{Folder Options} Control Panel.
\end{itemize}
\subsection{Installation in Linux}
\begin{itemize}
\item Download and install boost.
The required libraries are: chrono, date\_time, filesystem, system and thread.
\item Download \textbf{cmajor-0.5.0-src.tar.gz} and extract it to some directory
here called \verb|<cmajor>|:
\begin{verbatim}
seppo@raid:~/Programming$ tar -xzf cmajor-0.5.0.tar.gz
\end{verbatim}
\item Change to \verb|<cmajor>| directory and run \verb|make| from the there:
\begin{verbatim}
seppo@raid:~/Programming$ cd cmajor-0.5.0
seppo@raid:~/Programming/cmajor-0.5.0$ make
...
\end{verbatim}
\item Run then \verb|make install prefix=/where/to/install|, or\\
\verb|sudo make install prefix=/where/to/install| if you have not enough rights
to the directory where you want to install.
The \verb|prefix| is optional and by default it is \verb|/usr|.
\begin{verbatim}
seppo@raid:~/Programming/cmajor-0.5.0$ sudo make install
[sudo] password for seppo:
mkdir -p /usr/bin
cp bin/* /usr/bin
\end{verbatim}
\item Optionally you may want to get rid of object and library files by running \verb|make clean|
\item Add a \verb|CM_LIBRARY_PATH| environment variable and set it to contain (at least) a path
to the Cmajor System Library directory, that is \verb|<cmajor>/Cm/system|.
This can be done by issuing command\\
\verb|export CM_LIBRARY_PATH=<cmajor>/Cm/system| from the shell.
Optionally add the export to your shell script:
For example my \verb|.bashrc| file contains a line:
\begin{verbatim}
export CM_LIBRARY_PATH=~/Programming/cmajor-0.5.0/Cm/system:${CM_LIBRARY_PATH}|
\end{verbatim}
\end{itemize}
For now we issue this command from the shell:
\begin{verbatim}
seppo@raid:~/Programming/cmajor-0.5.0$
export CM_LIBRARY_PATH=~/Programming/cmajor-0.5.0/system
\end{verbatim}
\section{Examples}
\subsection{Example Projects}
\begin{itemize}
\item Hello, World
\verb|<example_dir> = 000_Hello|\\
\verb|<example_project> = hello|
A classical "Hello, World!" program
\item Print Program Arguments
\verb|<example_dir> = 001_PrintArgs|\\
\verb|<example_project> = printargs|
Printing command line arguments given to a program.
\item Calculating Fibonacci Numbers
\verb|<example_dir> = 002_Fibonacci|\\
\verb|<example_project> = fibonacci|
Computing Fibonacci numbers.
\item Printing Call Stack
\verb|<example_dir> = 003_PrintCallStack|\\
\verb|<example_project> = printcallstack|
Printing the call stack in trace builds.
Note: Build the project using command:\\
\verb|cmc -config=trace -b printcallstack.cmp| and
change to the "trace" subdirectory instead of "debug".
\item Calculator Tutorial Program
\verb|<example_dir> = 004_Calculator|\\
\verb|<example_project> = calculator|
A four-function calculator tutorial example.
\item Counting Words
\verb|<example_dir> = 005_WordCount|\\
\verb|<example_project> = wc|
Counts the number of lines, words and characters in one or more files.
\item Copying a File
\verb|<example_dir> = 006_CopyFile|\\
\verb|<example_project> = cp|
Copies a file.
\end{itemize}
\subsection{Building and Running the Examples in Windows}
\begin{itemize}
\item Open Command Prompt for example by clicking Start Menu, writing "cmd" and pressing ENTER.
\item Change to the example directory by issuing command\\
\verb|cd %APPDATA%\Cmajor-0.5.0\examples\<example_dir>|
\item Build the example by running command \verb|cmc -b <example_project>.cmp|
\item Run the example by changing to the \verb|debug| subdirectory and running command \verb|cmx <example_project>.cmx| from there.
\end{itemize}
For example building and running the Hello world program:
\begin{verbatim}
C:\Users\Seppo\AppData\Roaming\Cmajor-0.5.0\examples\000_Hello>cmc -b hello.cmp
Cmajor Compiler version 0.5.0.0 (x64)
Building project 'Hello' using debug configuration...
Target is program.
Parsing libraries...
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/debug/system.cml
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/debug/os.cml
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/debug/support.cml
Loading libraries...
<- os
<- support
<- system
Parsing sources...
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/examples/000_Hello/hello.cm
Type checking signatures...
Type checking bodies...
Generating code...
=> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/examples/000_Hello/debug/hello.cma
-> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/examples/000_Hello/debug/hello.cdi
Assembling...
<= C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/debug/init.cma
<= C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/examples/000_Hello/debug/hello.cma
=> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/examples/000_Hello/debug/hello.cmx
Project 'Hello' built successfully.
C:\Users\Seppo\AppData\Roaming\Cmajor-0.5.0\examples\000_Hello>cd debug
C:\Users\Seppo\AppData\Roaming\Cmajor-0.5.0\examples\000_Hello\debug>cmx hello.cmx
Hello, World!
\end{verbatim}
\subsection{Building and Running the Examples in Linux}
\begin{itemize}
\item Change to the example directory by issuing command\\
\verb|cd <cmajor>/Cm/Examples/<example_dir>|
\item Build the example by running command \verb|cmc -b <example_project>.cmp|
\item Run the example by changing to the \verb|debug| subdirectory and running command \verb|cmx <example_project>.cmx| from there.
\begin{verbatim}
seppo@raid:~/Programming/cmajor-0.5.0$ cd Cm/Examples/000_Hello/
seppo@raid:~/Programming/cmajor-0.5.0/Cm/Examples/000_Hello$ cmc -b hello.cmp
Cmajor Compiler version 0.5.0.0 (x64)
Building project 'Hello' using debug configuration...
Target is program.
Parsing libraries...
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/debug/system.cml
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/debug/os.cml
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/debug/support.cml
Loading libraries...
<- os
<- support
<- system
Parsing sources...
> /home/seppo/Programming/cmajor-0.5.0/Cm/Examples/000_Hello/hello.cm
Type checking signatures...
Type checking bodies...
Generating code...
=> /home/seppo/Programming/cmajor-0.5.0/Cm/Examples/000_Hello/debug/hello.cma
-> /home/seppo/Programming/cmajor-0.5.0/Cm/Examples/000_Hello/debug/hello.cdi
Assembling...
<= /home/seppo/Programming/cmajor-0.5.0/Cm/system/debug/init.cma
<= /home/seppo/Programming/cmajor-0.5.0/Cm/Examples/000_Hello/debug/hello.cma
=> /home/seppo/Programming/cmajor-0.5.0/Cm/Examples/000_Hello/debug/hello.cmx
Project 'Hello' built successfully.
seppo@raid:~/Programming/cmajor-0.5.0/Cm/Examples/000_Hello$ cd debug
seppo@raid:~/Programming/cmajor-0.5.0/Cm/Examples/000_Hello/debug$
cmx hello.cmx
Hello, World!
seppo@raid:~/Programming/cmajor-0.5.0/Cm/Examples/000_Hello/debug$
\end{verbatim}
\end{itemize}
\section{Cmajor System Library}
The Cmajor System Library comes pre-built, but if you need to change or experiment with it, here are the instructions how to rebuild it.
\subsection{Rebuilding the Cmajor System Library in Windows}
\begin{itemize}
\item Open Command Prompt for example by clicking the Start Menu, writing "cmd" and pressing ENTER.
\item Change to the Cmajor system directory by running command\\
\verb|cd %APPDATA%\Cmajor-0.5.0\system"|.
\item Run command \verb|cmc -R system.cmp:|.
\begin{verbatim}
C:\Users\Seppo\AppData\Roaming\Cmajor-0.5.0\system>cmc -R system.cmp
Cmajor Compiler version 0.5.0.0 (x64)
Building project 'system' using debug configuration...
Target is library.
Parsing libraries...
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/debug/os.cml
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/debug/support.cml
Loading libraries...
<- os
<- support
Parsing sources...
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/algorithm.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/bitset.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/charclass.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/concept.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/console.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/convert.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/diagnostics.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/exception.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/filestream.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/function.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/hashmap.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/hashset.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/hashtable.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/iterator.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/linkedlist.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/list.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/map.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/math.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/pair.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/ptr.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/queue.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/redblacktree.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/set.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/stack.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/stream.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/string.cm
> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/utility.cm
Type checking signatures...
Type checking bodies...
Generating code...
=> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/debug/system.cma
=> C:/Users/Seppo/AppData/Roaming/Cmajor-0.5.0/system/debug/system.cml
Project 'system' built successfully.
\end{verbatim}
\end{itemize}
To rebuild the library for release configuration run command:
\begin{verbatim}
cmc -config=release -R system.cmp
\end{verbatim}
Accordingly for trace configuration:
\begin{verbatim}
cmc -config=trace -R system.cmp
\end{verbatim}
\subsection{Rebuilding the Cmajor System Library in Linux}
Change to the \verb|<cmajor>/Cm/system| subdirectory and run
command \verb|cmc -R system.cmp| from there:
\begin{verbatim}
seppo@raid:~$ cd Programming/
seppo@raid:~/Programming$ cd cmajor-0.5.0/Cm/system/
seppo@raid:~/Programming/cmajor-0.5.0/Cm/system$ cmc -R system.cmp
Cmajor Compiler version 0.5.0.0 (x64)
Building project 'system' using debug configuration...
Target is library.
Parsing libraries...
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/debug/os.cml
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/debug/support.cml
Loading libraries...
<- os
<- support
Parsing sources...
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/algorithm.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/bitset.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/charclass.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/concept.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/console.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/convert.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/diagnostics.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/exception.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/filestream.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/function.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/hashmap.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/hashset.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/hashtable.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/iterator.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/linkedlist.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/list.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/map.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/math.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/pair.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/ptr.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/queue.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/redblacktree.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/set.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/stack.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/stream.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/string.cm
> /home/seppo/Programming/cmajor-0.5.0/Cm/system/utility.cm
Type checking signatures...
Type checking bodies...
Generating code...
=> /home/seppo/Programming/cmajor-0.5.0/Cm/system/debug/system.cma
=> /home/seppo/Programming/cmajor-0.5.0/Cm/system/debug/system.cml
Project 'system' built successfully.
\end{verbatim}
To rebuild the library for release configuration, issue a command\\
\verb|cmc -config=release -R system.cmp|
Accordingly for trace configuration:
\verb|cmc -config=trace -R system.cmp|
\end{document}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks