|
Lines 44-53
Link Here
|
| 44 |
<para>FreeBSD offers an excellent development environment. |
44 |
<para>FreeBSD offers an excellent development environment. |
| 45 |
Compilers for C, C++, and Fortran and an assembler come with the |
45 |
Compilers for C, C++, and Fortran and an assembler come with the |
| 46 |
basic system, not to mention a Perl interpreter and classic Unix |
46 |
basic system, not to mention a Perl interpreter and classic Unix |
| 47 |
tools such as <command>sed</> and <command>awk</>. If that is |
47 |
tools such as <command>sed</command> and <command>awk</command>. If that is |
| 48 |
not enough, there are many more compilers and interpreters in |
48 |
not enough, there are many more compilers and interpreters in |
| 49 |
the Ports collection. FreeBSD is very compatible with standards |
49 |
the Ports collection. FreeBSD is very compatible with standards |
| 50 |
such as <acronym>POSIX</> and <acronym>ANSI</> C, as well with |
50 |
such as <acronym>POSIX</acronym> and <acronym>ANSI</acronym> C, as well with |
| 51 |
its own BSD heritage, so it is possible to write applications |
51 |
its own BSD heritage, so it is possible to write applications |
| 52 |
that will compile and run with little or no modification on a |
52 |
that will compile and run with little or no modification on a |
| 53 |
wide range of platforms.</para> |
53 |
wide range of platforms.</para> |
|
Lines 73-80
Link Here
|
| 73 |
instruction. This section gives an overview of the two main |
73 |
instruction. This section gives an overview of the two main |
| 74 |
ways in which you can give these instructions, or |
74 |
ways in which you can give these instructions, or |
| 75 |
<quote>commands</quote> as they are usually called. One way |
75 |
<quote>commands</quote> as they are usually called. One way |
| 76 |
uses an <firstterm>interpreter</>, the other a |
76 |
uses an <firstterm>interpreter</firstterm>, the other a |
| 77 |
<firstterm>compiler</>. As human languages are too difficult for |
77 |
<firstterm>compiler</firstterm>. As human languages are too difficult for |
| 78 |
a computer to understand in an unambiguous way, commands are |
78 |
a computer to understand in an unambiguous way, commands are |
| 79 |
usually written in one or other languages specially designed for |
79 |
usually written in one or other languages specially designed for |
| 80 |
the purpose.</para> |
80 |
the purpose.</para> |
|
Lines 105-114
Link Here
|
| 105 |
start if you have not done any programming before. This kind |
105 |
start if you have not done any programming before. This kind |
| 106 |
of environment is typically found with languages like Lisp, |
106 |
of environment is typically found with languages like Lisp, |
| 107 |
Smalltalk, Perl and Basic. It could also be argued that the |
107 |
Smalltalk, Perl and Basic. It could also be argued that the |
| 108 |
Unix shell (<command>sh</>, <command>csh</>) is itself an |
108 |
Unix shell (<command>sh</command>, <command>csh</command>) is itself an |
| 109 |
interpreter, and many people do in fact write shell |
109 |
interpreter, and many people do in fact write shell |
| 110 |
<quote>scripts</quote> to help with various |
110 |
<quote>scripts</quote> to help with various |
| 111 |
<quote>housekeeping</> tasks on their machine. Indeed, part |
111 |
<quote>housekeeping</quote> tasks on their machine. Indeed, part |
| 112 |
of the original Unix philosophy was to provide lots of small |
112 |
of the original Unix philosophy was to provide lots of small |
| 113 |
utility programs that could be linked together in shell |
113 |
utility programs that could be linked together in shell |
| 114 |
scripts to perform useful tasks.</para> |
114 |
scripts to perform useful tasks.</para> |
|
Lines 135-150
Link Here
|
| 135 |
|
135 |
|
| 136 |
<variablelist> |
136 |
<variablelist> |
| 137 |
<varlistentry> |
137 |
<varlistentry> |
| 138 |
<term><acronym>BASIC</></term> |
138 |
<term><acronym>BASIC</acronym></term> |
| 139 |
|
139 |
|
| 140 |
<listitem> |
140 |
<listitem> |
| 141 |
<para>Short for Beginner's All-purpose Symbolic |
141 |
<para>Short for Beginner's All-purpose Symbolic |
| 142 |
Instruction Code. Developed in the 1950s for teaching |
142 |
Instruction Code. Developed in the 1950s for teaching |
| 143 |
University students to program and provided with every |
143 |
University students to program and provided with every |
| 144 |
self-respecting personal computer in the 1980s, |
144 |
self-respecting personal computer in the 1980s, |
| 145 |
<acronym>BASIC</> has been the first programming |
145 |
<acronym>BASIC</acronym> has been the first programming |
| 146 |
language for many programmers. It's also the foundation |
146 |
language for many programmers. It's also the foundation |
| 147 |
for <trademark>Visual Basic</>.</para> |
147 |
for <trademark>Visual Basic</trademark>.</para> |
| 148 |
|
148 |
|
| 149 |
<para>The <ulink |
149 |
<para>The <ulink |
| 150 |
URL="ftp://ftp.FreeBSD.org:pub/FreeBSD/packages/lang/bwbasic-2.10.tgz">Bywater |
150 |
URL="ftp://ftp.FreeBSD.org:pub/FreeBSD/packages/lang/bwbasic-2.10.tgz">Bywater |
|
Lines 184-190
Link Here
|
| 184 |
<listitem> |
184 |
<listitem> |
| 185 |
<para>Very popular with system administrators for writing |
185 |
<para>Very popular with system administrators for writing |
| 186 |
scripts; also often used on World Wide Web servers for |
186 |
scripts; also often used on World Wide Web servers for |
| 187 |
writing <acronym>CGI</> scripts.</para> |
187 |
writing <acronym>CGI</acronym> scripts.</para> |
| 188 |
|
188 |
|
| 189 |
<para>The latest version (version 5) comes with FreeBSD.</para> |
189 |
<para>The latest version (version 5) comes with FreeBSD.</para> |
| 190 |
</listitem> |
190 |
</listitem> |
|
Lines 284-290
Link Here
|
| 284 |
using separate programs, many commercial compiler makers have |
284 |
using separate programs, many commercial compiler makers have |
| 285 |
produced Integrated Development Environments |
285 |
produced Integrated Development Environments |
| 286 |
(<acronym>IDE</acronym>s for short). FreeBSD does not have an |
286 |
(<acronym>IDE</acronym>s for short). FreeBSD does not have an |
| 287 |
<acronym>IDE</> as such; however it is possible to use Emacs |
287 |
<acronym>IDE</acronym> as such; however it is possible to use Emacs |
| 288 |
for this purpose. This is discussed in <xref |
288 |
for this purpose. This is discussed in <xref |
| 289 |
linkend="emacs">.</para> |
289 |
linkend="emacs">.</para> |
| 290 |
</sect2> |
290 |
</sect2> |
|
Lines 295-301
Link Here
|
| 295 |
|
295 |
|
| 296 |
<para>This section deals only with the GNU compiler for C and C++, |
296 |
<para>This section deals only with the GNU compiler for C and C++, |
| 297 |
since that comes with the base FreeBSD system. It can be |
297 |
since that comes with the base FreeBSD system. It can be |
| 298 |
invoked by either <command>cc</> or <command>gcc</>. The |
298 |
invoked by either <command>cc</command> or <command>gcc</command>. The |
| 299 |
details of producing a program with an interpreter vary |
299 |
details of producing a program with an interpreter vary |
| 300 |
considerably between interpreters, and are usually well covered |
300 |
considerably between interpreters, and are usually well covered |
| 301 |
in the documentation and on-line help for the |
301 |
in the documentation and on-line help for the |
|
Lines 324-332
Link Here
|
| 324 |
understandable by humans. Allegedly. |
324 |
understandable by humans. Allegedly. |
| 325 |
|
325 |
|
| 326 |
<footnote> |
326 |
<footnote> |
| 327 |
<para>To be strictly accurate, <command>cc</> converts the |
327 |
<para>To be strictly accurate, <command>cc</command> converts the |
| 328 |
source code into its own, machine-independent |
328 |
source code into its own, machine-independent |
| 329 |
<firstterm>p-code</> instead of assembly language at |
329 |
<firstterm>p-code</firstterm> instead of assembly language at |
| 330 |
this stage.</para> |
330 |
this stage.</para> |
| 331 |
</footnote></para> |
331 |
</footnote></para> |
| 332 |
</step> |
332 |
</step> |
|
Lines 361-380
Link Here
|
| 361 |
</step> |
361 |
</step> |
| 362 |
</procedure> |
362 |
</procedure> |
| 363 |
|
363 |
|
| 364 |
<para>The word <firstterm>compiling</> is often used to refer to |
364 |
<para>The word <firstterm>compiling</firstterm> is often used to refer to |
| 365 |
just steps 1 to 4—the others are referred to as |
365 |
just steps 1 to 4—the others are referred to as |
| 366 |
<firstterm>linking</>. Sometimes step 1 is referred to as |
366 |
<firstterm>linking</firstterm>. Sometimes step 1 is referred to as |
| 367 |
<firstterm>pre-processing</> and steps 3-4 as |
367 |
<firstterm>pre-processing</firstterm> and steps 3-4 as |
| 368 |
<firstterm>assembling</>.</para> |
368 |
<firstterm>assembling</firstterm>.</para> |
| 369 |
|
369 |
|
| 370 |
<para>Fortunately, almost all this detail is hidden from you, as |
370 |
<para>Fortunately, almost all this detail is hidden from you, as |
| 371 |
<command>cc</> is a front end that manages calling all these |
371 |
<command>cc</command> is a front end that manages calling all these |
| 372 |
programs with the right arguments for you; simply typing</para> |
372 |
programs with the right arguments for you; simply typing</para> |
| 373 |
|
373 |
|
| 374 |
<screen>&prompt.user; <userinput>cc foobar.c</> |
374 |
<screen>&prompt.user; <userinput>cc foobar.c</> |
| 375 |
</screen> |
375 |
</screen> |
| 376 |
|
376 |
|
| 377 |
<para>will cause <filename>foobar.c</> to be compiled by all the |
377 |
<para>will cause <filename>foobar.c</filename> to be compiled by all the |
| 378 |
steps above. If you have more than one file to compile, just do |
378 |
steps above. If you have more than one file to compile, just do |
| 379 |
something like</para> |
379 |
something like</para> |
| 380 |
|
380 |
|
|
Lines 393-410
Link Here
|
| 393 |
isn't.</para> |
393 |
isn't.</para> |
| 394 |
</footnote></para> |
394 |
</footnote></para> |
| 395 |
|
395 |
|
| 396 |
<para>There are lots and lots of options for <command>cc</>, which |
396 |
<para>There are lots and lots of options for <command>cc</command>, which |
| 397 |
are all in the man page. Here are a few of the most important |
397 |
are all in the man page. Here are a few of the most important |
| 398 |
ones, with examples of how to use them.</para> |
398 |
ones, with examples of how to use them.</para> |
| 399 |
|
399 |
|
| 400 |
<variablelist> |
400 |
<variablelist> |
| 401 |
<varlistentry> |
401 |
<varlistentry> |
| 402 |
<term><option>-o <replaceable>filename</replaceable></></term> |
402 |
<term><option>-o <replaceable>filename</replaceable></option></term> |
| 403 |
|
403 |
|
| 404 |
<listitem> |
404 |
<listitem> |
| 405 |
<para>The output name of the file. If you do not use this |
405 |
<para>The output name of the file. If you do not use this |
| 406 |
option, <command>cc</> will produce an executable called |
406 |
option, <command>cc</command> will produce an executable called |
| 407 |
<filename>a.out</>. |
407 |
<filename>a.out</filename>. |
| 408 |
|
408 |
|
| 409 |
<footnote> |
409 |
<footnote> |
| 410 |
<para>The reasons for this are buried in the mists of |
410 |
<para>The reasons for this are buried in the mists of |
|
Lines 432-438
Link Here
|
| 432 |
</screen> |
432 |
</screen> |
| 433 |
</informalexample> |
433 |
</informalexample> |
| 434 |
|
434 |
|
| 435 |
<para>This will produce an <firstterm>object file</> (not an |
435 |
<para>This will produce an <firstterm>object file</firstterm> (not an |
| 436 |
executable) called <filename>foobar.o</filename>. This |
436 |
executable) called <filename>foobar.o</filename>. This |
| 437 |
can be linked together with other object files into an |
437 |
can be linked together with other object files into an |
| 438 |
executable.</para> |
438 |
executable.</para> |
|
Lines 525-531
Link Here
|
| 525 |
|
525 |
|
| 526 |
<listitem> |
526 |
<listitem> |
| 527 |
<para>Turn off most, but not all, of the |
527 |
<para>Turn off most, but not all, of the |
| 528 |
non-<acronym>ANSI</> C features provided by |
528 |
non-<acronym>ANSI</acronym> C features provided by |
| 529 |
<command>cc</command>. Despite the name, it does not |
529 |
<command>cc</command>. Despite the name, it does not |
| 530 |
guarantee strictly that your code will comply to the |
530 |
guarantee strictly that your code will comply to the |
| 531 |
standard.</para> |
531 |
standard.</para> |
|
Lines 537-543
Link Here
|
| 537 |
|
537 |
|
| 538 |
<listitem> |
538 |
<listitem> |
| 539 |
<para>Turn off <emphasis>all</emphasis> |
539 |
<para>Turn off <emphasis>all</emphasis> |
| 540 |
<command>cc</command>'s non-<acronym>ANSI</> C |
540 |
<command>cc</command>'s non-<acronym>ANSI</acronym> C |
| 541 |
features.</para> |
541 |
features.</para> |
| 542 |
</listitem> |
542 |
</listitem> |
| 543 |
</varlistentry> |
543 |
</varlistentry> |
|
Lines 1478-1484
Link Here
|
| 1478 |
listings of core files and sweat over machine code manuals, |
1478 |
listings of core files and sweat over machine code manuals, |
| 1479 |
but now life is a bit easier. Incidentally, under FreeBSD and |
1479 |
but now life is a bit easier. Incidentally, under FreeBSD and |
| 1480 |
other 4.4BSD systems, a core file is called |
1480 |
other 4.4BSD systems, a core file is called |
| 1481 |
<filename><replaceable>progname</>.core</> instead of just |
1481 |
<filename><replaceable>progname</replaceable>.core</filename> instead of just |
| 1482 |
<filename>core</filename>, to make it clearer which program a |
1482 |
<filename>core</filename>, to make it clearer which program a |
| 1483 |
core file belongs to.</para> |
1483 |
core file belongs to.</para> |
| 1484 |
|
1484 |
|
|
Lines 1771-1777
Link Here
|
| 1771 |
|
1771 |
|
| 1772 |
<itemizedlist> |
1772 |
<itemizedlist> |
| 1773 |
<listitem> |
1773 |
<listitem> |
| 1774 |
<para>Everything beginning with a <literal>;</> is a comment |
1774 |
<para>Everything beginning with a <literal>;</literal> is a comment |
| 1775 |
and is ignored by Emacs.</para> |
1775 |
and is ignored by Emacs.</para> |
| 1776 |
</listitem> |
1776 |
</listitem> |