SlideShare a Scribd company logo
Compilingunder Linux
Whatyouneed… COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 2 Pierre Masure    |     EMBEDDED LINUX: COMPILING UNDER LINUX
[COMMAND GCC] GNU COMPILER COLLECTION COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 3 Pierre Masure    |     EMBEDDED LINUX: COMPILING UNDER LINUX
[COMMAND GCC]-o option: file.cfile.exe COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 4 Pierre Masure    |     EMBEDDED LINUX: COMPILING UNDER LINUX
[COMMAND GCC]Compiles multiple sources COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 5 Pierre Masure    |     EMBEDDED LINUX: COMPILING UNDER LINUX $ gcc -Wall main.chello_fn.c -o newhello $ cat hello.h void hello (const char * name);
[COMMAND GCC]-c option to createobjects COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 6 Pierre Masure    |     EMBEDDED LINUX: COMPILING UNDER LINUX $ gcc -Wall -c main.c main.o $ gcc -Wall -c hello_fn.c hello_fn.o $ gccmain.ohello_fn.o -o hello  hello.exe Linking step gcc uses the linkerld ld = a separate program.
[COMMAND GCC]Linkwith the libraries COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 7 Pierre Masure    |     EMBEDDED LINUX: COMPILING UNDER LINUX Default library: libc.a ___ #include <math.h>  #include <stdio.h>  intmain (void) { double x = sqrt (2.0); printf ("The square root of 2.0 is %f", x); return 0;}  ___ $ gcc -Wall calc.c -o calc /tmp/ccbR6Ojm.o: In function `main':  /tmp/ccbR6Ojm.o(.text+0x19): undefinedreference to `sqrt'  ___ $ gcc -Wall calc.c/usr/lib/libm.a-o calc ___ $ ./calc The square root of 2.0 is 1.414214 ___ $ gcc -Wall calc.c-lm -o calc
[COMMAND GCC]Linkingorder COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 8 Pierre Masure    |     EMBEDDED LINUX: COMPILING UNDER LINUX $ gcc -Wall calc.c-lm -o calc (correct order)  $ gcc-Wall -lm calc.c -o calc (incorrect order)  main.o: In function `main':  main.o(.text+0xf): undefinedreference to `sqrt'
[COMMAND GCC]-Wall option COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 9 Pierre Masure    |     EMBEDDED LINUX: COMPILING UNDER LINUX #include <stdio.h>  intmain (void) {  double x = pow (2.0, 3.0);  printf("Two cubed is %f", x);  return 0;  }  ___ $ gccbadpow.c -lm  $ ./a.out Two cubed is 2.851120 (incorrect result, should be 8) ___ $ gcc -Wall badpow.c -lm  badpow.c: In function `main':  badpow.c:6: warning: implicitdeclaration of  function`pow'
[COMMAND MAKE]Functionality COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 10 Pierre Masure    |     EMBEDDED LINUX: COMPILING UNDER LINUX ,[object Object]
Makefile
Relations between the files
Dependencies
Make: brain,[object Object]
Creates B & D
Determineslibraries and gcc arguments for B & D
Compiles
Advanced feature: update of files depending on other files,[object Object]
[MAKEFILE] EXAMPLE COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 13 Pierre Masure    |     EMBEDDED LINUX: COMPILING UNDER LINUX

More Related Content

What's hot

GCC Compiler as a Performance Testing tool for C programs
GCC Compiler as a Performance Testing tool for C programsGCC Compiler as a Performance Testing tool for C programs
GCC Compiler as a Performance Testing tool for C programsDaniel Ilunga
 
C++ compilation process
C++ compilation processC++ compilation process
C++ compilation processRahul Jamwal
 
Golang execution modes
Golang execution modesGolang execution modes
Golang execution modesTing-Li Chou
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerPriyank Kapadia
 
Debugging With GNU Debugger GDB
Debugging With GNU Debugger GDBDebugging With GNU Debugger GDB
Debugging With GNU Debugger GDBkyaw thiha
 
Goroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoGoroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoYu-Shuan Hsieh
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDBDavid Khosid
 
Syncevolution: Open Source and Funambol
Syncevolution: Open Source and FunambolSyncevolution: Open Source and Funambol
Syncevolution: Open Source and FunambolFunambol
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdbOwen Hsu
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handoutSuraj Kumar
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about goDvir Volk
 
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...corehard_by
 
淺入淺出 GDB
淺入淺出 GDB淺入淺出 GDB
淺入淺出 GDBJim Chang
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Robert Stern
 
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019corehard_by
 
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...Mickael Istria
 

What's hot (20)

GCC Compiler as a Performance Testing tool for C programs
GCC Compiler as a Performance Testing tool for C programsGCC Compiler as a Performance Testing tool for C programs
GCC Compiler as a Performance Testing tool for C programs
 
C++ compilation process
C++ compilation processC++ compilation process
C++ compilation process
 
C compilation process
C compilation processC compilation process
C compilation process
 
Golang execution modes
Golang execution modesGolang execution modes
Golang execution modes
 
Gnu debugger
Gnu debuggerGnu debugger
Gnu debugger
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
 
Debugging With GNU Debugger GDB
Debugging With GNU Debugger GDBDebugging With GNU Debugger GDB
Debugging With GNU Debugger GDB
 
Goroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoGoroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in Go
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDB
 
Syncevolution: Open Source and Funambol
Syncevolution: Open Source and FunambolSyncevolution: Open Source and Funambol
Syncevolution: Open Source and Funambol
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
 
Usage of GDB
Usage of GDBUsage of GDB
Usage of GDB
 
GDB Rocks!
GDB Rocks!GDB Rocks!
GDB Rocks!
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handout
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
 
淺入淺出 GDB
淺入淺出 GDB淺入淺出 GDB
淺入淺出 GDB
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
 
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
 
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
 

Viewers also liked

Viewers also liked (10)

MinGw Compiler
MinGw CompilerMinGw Compiler
MinGw Compiler
 
How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)
 
HRM - PM in GCC
HRM - PM in GCCHRM - PM in GCC
HRM - PM in GCC
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
 
NetBeans para Java, C, C++
NetBeans para Java, C, C++NetBeans para Java, C, C++
NetBeans para Java, C, C++
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions Framework
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
Gcc opt
Gcc optGcc opt
Gcc opt
 
Deep C
Deep CDeep C
Deep C
 
GCC
GCCGCC
GCC
 

Similar to Compiling Under Linux

Writing mruby Debugger
Writing mruby DebuggerWriting mruby Debugger
Writing mruby Debuggeryamanekko
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...Puppet
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configurationlutter
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020CloudHero
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developersSuraj Deshmukh
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortalsHenryk Konsek
 
Docker: The basics - Including a demo with an awesome full-stack JS app
Docker: The basics - Including a demo with an awesome full-stack JS appDocker: The basics - Including a demo with an awesome full-stack JS app
Docker: The basics - Including a demo with an awesome full-stack JS appMarcelo Rodrigues
 
The Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptThe Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptDocker, Inc.
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Bo-Yi Wu
 
Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Benny Siegert
 
Building CLI Applications with Golang
Building CLI Applications with GolangBuilding CLI Applications with Golang
Building CLI Applications with GolangAnshul Patel
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with dockerGiacomo Bagnoli
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScriptChengHui Weng
 
HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4Linaro
 
HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3Linaro
 
Mender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionSchalk Cronjé
 

Similar to Compiling Under Linux (20)

Writing mruby Debugger
Writing mruby DebuggerWriting mruby Debugger
Writing mruby Debugger
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developers
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
 
Docker: The basics - Including a demo with an awesome full-stack JS app
Docker: The basics - Including a demo with an awesome full-stack JS appDocker: The basics - Including a demo with an awesome full-stack JS app
Docker: The basics - Including a demo with an awesome full-stack JS app
 
The Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptThe Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build Script
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]
 
Building CLI Applications with Golang
Building CLI Applications with GolangBuilding CLI Applications with Golang
Building CLI Applications with Golang
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScript
 
CI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOWCI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOW
 
Docker Compose Explained
Docker Compose ExplainedDocker Compose Explained
Docker Compose Explained
 
HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4
 
HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3
 
kubernetes for beginners
kubernetes for beginnerskubernetes for beginners
kubernetes for beginners
 
Mender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and Golang
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 version
 

More from PierreMASURE

Présentation Web Technology
Présentation Web TechnologyPrésentation Web Technology
Présentation Web TechnologyPierreMASURE
 
Projet Traitement Du Signal
Projet Traitement Du SignalProjet Traitement Du Signal
Projet Traitement Du SignalPierreMASURE
 
Projet De ThéOrie Des Circuits
Projet De ThéOrie Des CircuitsProjet De ThéOrie Des Circuits
Projet De ThéOrie Des CircuitsPierreMASURE
 

More from PierreMASURE (7)

Sms On FiRe
Sms On FiReSms On FiRe
Sms On FiRe
 
Présentation Web Technology
Présentation Web TechnologyPrésentation Web Technology
Présentation Web Technology
 
Projet Traitement Du Signal
Projet Traitement Du SignalProjet Traitement Du Signal
Projet Traitement Du Signal
 
Projet Ma2
Projet Ma2Projet Ma2
Projet Ma2
 
Projet De ThéOrie Des Circuits
Projet De ThéOrie Des CircuitsProjet De ThéOrie Des Circuits
Projet De ThéOrie Des Circuits
 
Projet Bac3
Projet Bac3Projet Bac3
Projet Bac3
 
Projet Bac2
Projet Bac2Projet Bac2
Projet Bac2
 

Compiling Under Linux

  • 2. Whatyouneed… COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 2 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX
  • 3. [COMMAND GCC] GNU COMPILER COLLECTION COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 3 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX
  • 4. [COMMAND GCC]-o option: file.cfile.exe COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 4 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX
  • 5. [COMMAND GCC]Compiles multiple sources COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 5 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX $ gcc -Wall main.chello_fn.c -o newhello $ cat hello.h void hello (const char * name);
  • 6. [COMMAND GCC]-c option to createobjects COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 6 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX $ gcc -Wall -c main.c main.o $ gcc -Wall -c hello_fn.c hello_fn.o $ gccmain.ohello_fn.o -o hello  hello.exe Linking step gcc uses the linkerld ld = a separate program.
  • 7. [COMMAND GCC]Linkwith the libraries COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 7 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX Default library: libc.a ___ #include <math.h> #include <stdio.h> intmain (void) { double x = sqrt (2.0); printf ("The square root of 2.0 is %f", x); return 0;} ___ $ gcc -Wall calc.c -o calc /tmp/ccbR6Ojm.o: In function `main': /tmp/ccbR6Ojm.o(.text+0x19): undefinedreference to `sqrt' ___ $ gcc -Wall calc.c/usr/lib/libm.a-o calc ___ $ ./calc The square root of 2.0 is 1.414214 ___ $ gcc -Wall calc.c-lm -o calc
  • 8. [COMMAND GCC]Linkingorder COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 8 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX $ gcc -Wall calc.c-lm -o calc (correct order) $ gcc-Wall -lm calc.c -o calc (incorrect order) main.o: In function `main': main.o(.text+0xf): undefinedreference to `sqrt'
  • 9. [COMMAND GCC]-Wall option COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 9 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX #include <stdio.h> intmain (void) { double x = pow (2.0, 3.0); printf("Two cubed is %f", x); return 0; } ___ $ gccbadpow.c -lm $ ./a.out Two cubed is 2.851120 (incorrect result, should be 8) ___ $ gcc -Wall badpow.c -lm badpow.c: In function `main': badpow.c:6: warning: implicitdeclaration of function`pow'
  • 10.
  • 14.
  • 16. Determineslibraries and gcc arguments for B & D
  • 18.
  • 19. [MAKEFILE] EXAMPLE COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 13 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX
  • 20. [MAKEFILE] RICH MAKEFILE COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 14 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX
  • 21. [MAKEFILE]MACROS FOR FLEXIBILITY COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 15 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX
  • 22. [MAKEFILE]DIRECTIVES COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 16 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX
  • 23. [DEBUG]Working COMPILING UNDER LINUX COMMAND GCC -o option Multiples sources -c option Linking with Libraries -wall option COMMAND MAKE Functionality Working MAKEFILE Minimal makefile Example Rich makefile Macros Directives DEBUG Working Features Example 17 Pierre Masure | EMBEDDED LINUX: COMPILING UNDER LINUX gdb
  • 24.
  • 27.