[xxxhost]$gcc -c hello.c hi.c
[xxxhost]$ls *.o
hello.o hi.o
[xxxhost]$ar -rcs libhi.a hi.o
[xxxhost]$ls *.a
libhi.a
[xxxhost]$gcc -shared -fPIC -o libhello.so hello.o
/usr/bin/ld: hello.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
hello.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
[xxxhost]$gcc -fPIC -c hello.c
[xxxhost]$ls *.o
hello.o hi.o
[xxxhost]$gcc -shared -fPIC -o libhello.so hello.o
[xxxhost]$ls *.so
libhello.so
[xxxhost]$gcc -o hello main.c -L. -lhello -lhi
[xxxhost]$./hello
./hello: error while loading shared libraries: libhello.so: cannot open shared object file: No such file or directory
[xxxhost]$
[xxxhost]$export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./
[xxxhost]$./hello
Hello Lean!
Hi tom!