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,24 @@
#!/bin/bash
set -e
echo "=== Step 1: Compile each .cpp to object files ==="
g++ -std=c++17 -c foo.cpp -o foo.o
g++ -std=c++17 -c main.cpp -o main.o
echo "Created foo.o and main.o"
echo ""
echo "=== Step 2: Inspect object files with nm ==="
echo "--- foo.o symbols (defines add) ---"
nm -C foo.o
echo ""
echo "--- main.o symbols (references add) ---"
nm -C main.o
echo ""
echo "=== Step 3: Link object files into executable ==="
g++ foo.o main.o -o app
echo "Created app"
echo ""
echo "=== Step 4: Run ==="
./app