C++ linker presentation

This commit is contained in:
2026-02-24 10:21:15 +01:00
parent 0fda0d75fb
commit 6f3d98f388
32 changed files with 788 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
#!/bin/bash
set -e
echo "=== Compile to object files ==="
g++ -std=c++17 -c math.cpp -o math.o
g++ -std=c++17 -c main.cpp -o main.o
echo ""
echo "=== math.o: exported symbols (demangled) ==="
nm -C -g math.o
echo ""
echo "=== main.o: unresolved (UNDEF) symbols ==="
nm -C -u main.o
echo ""
echo "=== main.o: full symbol table ==="
objdump -t main.o
echo ""
echo "=== Link and run ==="
g++ math.o main.o -o app
./app

View File

@@ -0,0 +1,9 @@
#include <iostream>
double square(double);
int main() {
double r = square(5.0);
std::cout << "square(5.0) = " << r << "\n";
return 0;
}

View File

@@ -0,0 +1,3 @@
#include <iostream>
double square(double x) { return x * x; }