math 676 finite element methods in scientifjc computing
play

MATH 676 Finite element methods in scientifjc computing Wolfgang - PowerPoint PPT Presentation

MATH 676 Finite element methods in scientifjc computing Wolfgang Bangerth, T exas A&M University http://www.dealii.org/ Wolfgang Bangerth Lecture 2.91: A (very brief) introduction to Linux Part 2: Compiling programs


  1. MATH 676 – Finite element methods in scientifjc computing Wolfgang Bangerth, T exas A&M University http://www.dealii.org/ Wolfgang Bangerth

  2. Lecture 2.91: A (very brief) introduction to Linux Part 2: Compiling programs http://www.dealii.org/ Wolfgang Bangerth

  3. Compiling, linking, etc. Building an application is a 2-step process: ● “Compile” every .cc fjle into a .o fjle: c++ -c a.cc -o a.o c++ -c b.cc -o b.o ● “Link” all .o fjles into one executable: c++ a.o b.o -o myprog The details are easier to explain using an example... http://www.dealii.org/ Wolfgang Bangerth

  4. What could go wrong? Both compiling and linking can produce errors: ● Compiler errors: – Your code does not follow the C++ “syntax” – You reference a variable that has not been “declared” – You call a function that has not been “declared” ● Linker errors: – You call a function that has been “declared” but not “implemented” ● Important: When fjguring out what's wrong, need to know which “phase” you're in! http://www.dealii.org/ Wolfgang Bangerth

  5. What could go wrong? Notes on compiler/linker errors: ● Errors often “cascade” → start at the top (i.e., the fjrst error message) ● If there are many error messages, use the command c++ -c a.cc -o a.o 2>&1 | less Here, ' 2>&1 ' “redirects” stderr to stdout, so that it can serve as input to 'less'. ● Linker errors can only happen once everything has been compiled. http://www.dealii.org/ Wolfgang Bangerth

  6. Automating compilation/linking Building an application is a 2-step process: ● “Compile” every .cc fjle into a .o fjle: c++ -c a.cc -o a.o c++ -c b.cc -o b.o ● “Link” all .o fjles into one executable: c++ a.o b.o -o myprog Problem: This is (i) cumbersome to do every time, and (ii) diffjcult to get right with “dependencies”. Solution: Write rules for a program called “ make ”, then say make myprog http://www.dealii.org/ Wolfgang Bangerth

  7. Automating compilation/linking Makefjles contain: ● “targets” – what should be done ● “dependencies” – what does a target depend on ● “rules” – how should a target be created ● Variables and generic rules to make writing rules easier Again: Simpler to to see using a concrete example! http://www.dealii.org/ Wolfgang Bangerth

  8. Automating compilation/linking Makefjles contain: ● “targets” – what should be done ● “dependencies” – what does a target depend on ● “rules” – how should a target be created Problems: ● Simple Makefjles are easy to write ● But quickly become complex and unreadable. Archaic syntax does not help (“make” was invented in 1976). ● Not platform independent ● Not meant as input for tools other than “make” http://www.dealii.org/ Wolfgang Bangerth

  9. Automating compilation/linking Makefjles contain: ● “targets” – what should be done ● “dependencies” – what does a target depend on ● “rules” – how should a target be created Problems: ● … Solutions: There are now tools/programming languages that describe targets, dependencies, and rules at a higher level. They then create Makefjles or other output. Example: autoconf/automake, cmake http://www.dealii.org/ Wolfgang Bangerth

  10. MATH 676 – Finite element methods in scientifjc computing Wolfgang Bangerth, T exas A&M University http://www.dealii.org/ Wolfgang Bangerth

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend