Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

from D2L. It is a simple program that prints out Hello world?, and yoe can compike and ran it. To compile it, 80 to a

image text in transcribed
image text in transcribed
image text in transcribed
from D2L. It is a simple program that prints out "Hello world?, and yoe can compike and ran it. To compile it, 80 to a Unix Shell window, connect to the directory into wheh you dowaloaded the program, and coter the following command: gec hello.e no hello This command compiles hello.e into an executable progam named thello" that you run by typing ". /hello" at the command line. It does nothing more than perint the mord thello" on the screen. Aiternatively, the above prograas coald be compiled using the following two commande gec-chello,cgecbello.o-0bello The end roult is the same, bat this two-itep socthad firnt eompllen belloce into a machine code file named thello.o" and then links helloio with some system likraries to pruduce the final program thello". In fact the first method also does this two-1 Tage proces of compilng and linking, but the stapes are doee traniparently, and the intermediate atse "helbo" is deleted in the procme. Frequently used compilation options C and C+ + compilers allow for many options for bow to compile a peognam, and the ecamples below desnonstrate how to us many of the more comanaly used optiose. In ench example, anprog. C" contains C/C++ source code for the ececutable 'isyprog". In mont cases options can be cumbined, althoagh it is geacrally not tseful to tise "debugeing" and "ogtimination" optines together. - Compile ayproge so that mygres cuntains nymbolic infirmation that malhr it to be debugrod with the gilb debugzer: gec5njprog,e0ayprog: gec -Wall ayprog-c +e mjteg - Genierate syabodic informatica fine pill and nany marniss masagrs. gec--Mallaygeog.e0ayprog zec0ayprogicanyprog. zec mypres e toimprof - le The focus of this Section is to show the basics of compilation under Lintix/Unix. Download be1lo. c from D2L. It is a simple program that ptints out "Hello world", and you can compile and run it. To compile it, go to a Unix Sbell window, connect to the directory into which you downloaded the program, and enter the following command: gec hello.c -o bello This command compiles hello.e into an executable program named "hello" that you run by typing ". /bello" at the command line. It does nothing more than print the word "hello" on the screen. Alternatively, the above program could be compiled using the following two commands. gce -c hello.c gec hello. 0 -o hello The end result is the same, but this two-step method first compiles hello.c into a machine code file named "hello" and then links hello.o with some system libraries to produce the final program "hello". In fact the first method also does this two-stage process of compiling and linking, but the stages are done transparently, and the intermediate file -hello. 0 is deleted in the process. Frequently used compilation options Cand C++ compilers allow for many options for how to compile a program, and the examples below demonstrate how to use many of the more commonly used options. In each example, "myprog. C contains C/C++ source code for the executable "myprog". In most cases options can be combined, although it is generally not useful to use "debugging" and "optimization" options together. - Compile myprog.e so that myprog contains symbolic information that enables it to be debugged with the gdb debugger: gecgmyprog.c-omyprog - Have the coupiler generate many warnings about kyntactically correct but questionable looking code. It is good practice to always nse this option with gce and gtt. gce-Wallayprog.c0myprog - Gencrate symbolic information for gdb anc many warning messags? gecgWallmyprog.c0rog - Generate optimized code on a Limux/Unix ion next. Section for more information) machine., gec0myprog.omyprog - Compile myprogec when it contains Xlib graphies routines. gec myprog.c -o myprog -1xi1 - Compile a C program that uses math functions such as "sqrt". gecmyprog,c0myprog1m Finally, If "myprogecpp" is a C+ t program, then the above commands will all work by replacing gec with g++ and "myprog.c" with myprog.cpp": Section 2 - Makefiles

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

=+3. Who are the brand's competitors?

Answered: 1 week ago