1 / 5

Unix tools for C/C++ Programming

Unix tools for C/C++ Programming. CS240 Computer Science II. Entering a program. You may use either vi or pico editor that is available on our system to enter your source code. The C and C++ source code must saved with a .c or .cpp extension, respectively.

diamond
Download Presentation

Unix tools for C/C++ Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unix tools for C/C++ Programming CS240 Computer Science II

  2. Entering a program You may use either vi or pico editor that is available on our system to enter your source code. The C and C++ source code must saved with a .c or .cpp extension, respectively.

  3. Components of the compilation process

  4. Compiling the source code • The cc utility calls the C preprocessor, C compiler, the assembler, and the link editor. If there is no error, an executable load module a.out is generated for the C program. • The g++ utility performs the same tasks for a C++ program.

  5. cc and g++ options • -l: requests the compiler to search the other libraries. Note that the option appears after the filenames. In the example below, the compiler will search the math library libm.a (by default, the compiler searches the the standard library libc.a). $ ccprog.c -lm # m stands for libm.a • -O: causes the compiler to use the optimizer and lists all the object files with .o extension. • -o: allows the user to replace default a.out with a different name. $ g++ -o Hello Hello.cpp # Hello replace a.out $ Hello # executes the code • -c: supresses the link-edit phase; it does not treat unresolved external references as errors. Once all modules have separately debugged, one can recompile by listing as arguments in the cc or g++ command the needed .c, .cpp, or .o files.

More Related