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,33 @@
#!/bin/bash
set -e
echo "=== Compile object files ==="
g++ -std=c++17 -c vec.cpp -o vec.o
g++ -std=c++17 -c mat.cpp -o mat.o
echo ""
echo "=== Create static library (archive) ==="
ar rcs libmymath.a vec.o mat.o
echo "Created libmymath.a"
echo ""
echo "=== Inspect archive contents ==="
ar t libmymath.a
echo ""
echo "=== Symbols in the archive ==="
nm -C -g libmymath.a
echo ""
echo "=== Compile and link main against the static library ==="
g++ -std=c++17 -c main.cpp -o main.o
g++ main.o -L. -lmymath -o app
echo "Created app"
echo ""
echo "=== Check dynamic dependencies ==="
ldd app || echo "(ldd not available or statically linked)"
echo ""
echo "=== Run ==="
./app