#!/bin/bash set -e OPT="${1:--O0}" # Compile hello.cpp as a shared library g++ -std=c++17 "$OPT" -shared -fPIC -o libhello.so hello.cpp # Compile and link main.cpp with the shared library g++ -std=c++17 "$OPT" -o main main.cpp -L. -lhello -Wl,-rpath,'$ORIGIN' echo "Build successful"