Files
strangecpp/namecollision/build.sh
2026-02-23 16:19:27 +01:00

13 lines
288 B
Bash

#!/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"