Skip to content
Snippets Groups Projects
Commit aeaec7cc authored by Dominik Zobel's avatar Dominik Zobel
Browse files

Add cpp compiler example

parent 90bd4724
No related branches found
No related tags found
1 merge request!56Debugging Strategies lecture notes
Pipeline #66853 passed
...@@ -52,9 +52,82 @@ digraph { ...@@ -52,9 +52,82 @@ digraph {
- Learn to understand what the compiler tries to tell you - Learn to understand what the compiler tries to tell you
## Example ## GCC C++ compiler examples (1/x) {.leftalign}
::::::::{.columns}
:::{.column width=45%}
```cpp
#include <iostream>
int main() {
using namespace std;
cout << "Hallo" << endl;
return 0;
}
```
Compiling with
`gcc test.cpp -o test`
:::
:::{.column width=55% .smaller}
```
/usr/bin/ld: /tmp/ccrbNm7k.o: warning: relocation against `_ZSt4cout' in read-only section `.text'
/usr/bin/ld: /tmp/ccrbNm7k.o: in function `main':
test.cpp:(.text+0x15): undefined reference to `std::cout'
/usr/bin/ld: test.cpp:(.text+0x1d): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: test.cpp:(.text+0x24): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/usr/bin/ld: test.cpp:(.text+0x2f): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/usr/bin/ld: /tmp/ccrbNm7k.o: in function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x66): undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: test.cpp:(.text+0x81): undefined reference to `std::ios_base::Init::~Init()'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
```
:::
::::::::
## GCC C++ compiler examples (1/x) {.leftalign}
::::::::{.columns}
:::{.column width=45%}
```cpp
#include <iostream>
int main() {
using namespace std;
cout << "Hallo" << endl;
return 0;
}
```
Compiling with
`g++ test.cpp -o test`
:::
:::{.column width=55% .smaller}
Compilation succeeded
:::
::::::::
TODO
## Compiler flags for compilation output {.leftalign} ## Compiler flags for compilation output {.leftalign}
...@@ -76,6 +149,7 @@ Also gcc compile time checks and options like ...@@ -76,6 +149,7 @@ Also gcc compile time checks and options like
Summary Summary
# Run-time errors {.leftalign} # Run-time errors {.leftalign}
- Let the compiler help you if something goes wrong - Let the compiler help you if something goes wrong
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment