-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-g++-dynamic.sh
More file actions
executable file
·29 lines (21 loc) · 945 Bytes
/
run-g++-dynamic.sh
File metadata and controls
executable file
·29 lines (21 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
# Exit immediately on error; echo the commands.
set -ex
# Load the build functions.
. ./build-libs.sh
# Build the dynamic library for `simplecalc`.
build_dynamic_lib "simplecalc"
# Build the dynamic library for `simplestr`.
build_dynamic_lib "simplestr"
# Create the executable.
# The libraries are linked dynamically by default so we don't really have to
# specify any additional options.
g++ main.cpp -L. -lsimplecalc -lsimplestr -Wall -o main-g++-dynamic.exe
# Run the executable by providing the proper `LD_LIBRARY_PATH`:
LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH" ./main-g++-dynamic.exe
# Remove the `.so` files so we cannot run the executable successfully because
# it requires the existence of the shared libraries.
rm -f libsimplecalc.so libsimplestr.so
# Run the executable again but expect the error "cannot open shared object
# file: No such file or directory".
LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH" ./main-g++-dynamic.exe