Content #
Rpath, or the run path, is a way of embedding the location of shared libraries in the executable itself, instead of relying on default locations or environment variables.
当前目录下有libfoo.so共享库,现在要使用gcc的rpath选项,将共享库的位置嵌入在可执行文件中,gcc的命令行该怎么写?
gcc -L/home/username/foo -Wl,-rpath=/home/username/foo -Wall -o test main.c -lfoo