summaryrefslogtreecommitdiff
path: root/schulung_tools/linking/hello/shared_library.txt
blob: 1dd0f9f936a0bcba447b23614cd9d5ad277bd867 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# build shared library
gcc -fPIC -shared -Wl,-soname,libhello.so.1 -olibhello.so.1.0.3 libhello.c

# install shared library
sudo mkdir -p /opt/myfirma/lib
sudo cp libhello.so.1.0.3 /opt/myfirma/lib

# add custom path to dynamic loader search path
echo "/opt/myfirma/lib" | sudo tee /etc/ld.so.conf.d/myfirma.conf

# refresh dynamic loader cache
sudo ldconfig

# verify custom library is in cache
/sbin/ldconfig -p | grep libhello.so.1

# compile program using custom library
ln -s /opt/myfirma/lib/libhello.so.1.0.3 libhello.so
gcc -L. -ohello hello.c -lhello
rm libhello.so