转自:http://blog.csdn.net/russule/article/details/7057398
动态链接库
1 生成hello.so
g++ -shared hello.cpp -olibhello.so
g++ main.cpp -lhello -L./ -Wl,-rpath=./ -o main
链接命令可使用g++ main.cpp libhello.so.2 -L./ -Wl,-rpath=./ -o main
g++ main.cpp -L./second/ -Wl,-rpath=./second/ -lsecond -L./hello/ -Wl,-rpath=./hello/ -lhello -o main
http://www.cnblogs.com/maximusfz/archive/2010/12/01/1893384.html