Download presentation
Presentation is loading. Please wait.
Published byOswin Booker Modified over 9 years ago
1
1 CS 161 Introduction to Programming and Problem Solving Chapter 10 g++ Compiler Usage Herbert G. Mayer, PSU Status 10/21/2014
2
2 Syllabus Compile Command Compile Command Execute Object Code Execute Object Code Compile Example Compile Example
3
3 C++ Compile Command The GNU Project provides a freely available, open source C compiler called gcc and g++ The syntax for compiling a program via Unix command line: g++ [options] file_list very similar to: gcc [options] file_list where: g++ → compiler name, lowercase g; or gcc for C [options] → compilation options (optional) file_list → list of source and/or object files
4
4 Compile Example Your source file is called prog1.cpp Your compiler generates a default executable file named a.out Type this at the command line (no extra checking): g++ prog1.cpp Or type this at the command line (full checking): g++ -ansi -pedantic -Wall prog1.cpp Very similar for C: gcc -ansi -pedantic -Wall prog1.c
5
5 Compile Example Your source file is called mathprog.cpp But you prefer the executable file not to be named a.out, but mprog Then type this command: g++ -ansi -pedantic -Wall mathprog.cpp –o mprog
6
6 Compile Example Your source files are ted.cpp and alice.cpp. You want the executable file to be named jupiter2 Type this at the command line: g++ -ansi -pedantic -Wall ted.cpp alice.cpp –o jupiter2
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.