C++ linker presentation
This commit is contained in:
24
cpplinker/01_compilation_pipeline/build.sh
Normal file
24
cpplinker/01_compilation_pipeline/build.sh
Normal 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
|
||||
Reference in New Issue
Block a user