Skip to main content Accessibility help
×
Hostname: page-component-848d4c4894-75dct Total loading time: 0 Render date: 2024-05-30T01:46:09.035Z Has data issue: false hasContentIssue false

A - C++ Basics

Published online by Cambridge University Press:  05 October 2013

George Em Karniadakis
Affiliation:
Brown University, Rhode Island
Robert M. Kirby II
Affiliation:
University of Utah
Get access

Summary

COMPILATION GUIDE

For the purposes of this compilation example, we will assume that we are using the GNU g++ compiler to compile a C++ program we have written contained within the file myprog.cpp. In the following examples, the argument following the “-o” flag designates the file name to be used for the output. If no “-o” option is specified, most compilers default to using the name “a.out.” We now present several different programming scenarios:

  1. • No user-defined libraries or user-defined header files are needed, and no special system libraries (such as those associated with math.h) are needed):

  2. g++ -o myprog myprog.cpp

  3. • No user-defined libraries or user-defined header files are needed, but the special system library corresponding to math.h is needed:

  4. g++ -o myprog myprog.cpp -lmath

  5. • User-defined libraries, user-defined header files, and the special system library corresponding to math.h are needed:

  6. g++ -o myprog myprog.cpp -I/users/kirby/includes -L/users/ kirby/libs -lSCmathlib -lmath

The string following the “-I” flag designates the location of the user-defined header files to be included. The string following the “-L” flag designates the location of the user-defined libraries to be included. The string “-lSCmathlib” links the program with the user-defined library we created, and the string “-lmath” links the program with the system math library corresponding to math.h.

Type
Chapter
Information
Parallel Scientific Computing in C++ and MPI
A Seamless Approach to Parallel Algorithms and their Implementation
, pp. 575 - 580
Publisher: Cambridge University Press
Print publication year: 2003

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • C++ Basics
  • George Em Karniadakis, Brown University, Rhode Island, Robert M. Kirby II, University of Utah
  • Book: Parallel Scientific Computing in C++ and MPI
  • Online publication: 05 October 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9780511812583.012
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • C++ Basics
  • George Em Karniadakis, Brown University, Rhode Island, Robert M. Kirby II, University of Utah
  • Book: Parallel Scientific Computing in C++ and MPI
  • Online publication: 05 October 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9780511812583.012
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • C++ Basics
  • George Em Karniadakis, Brown University, Rhode Island, Robert M. Kirby II, University of Utah
  • Book: Parallel Scientific Computing in C++ and MPI
  • Online publication: 05 October 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9780511812583.012
Available formats
×