编译时增加-Wl,-rpath . 动态库路径检索增加当前路径。例子:g++ -o b.out main.cpp -L./ -lgTestClass -lgTestClass2 -Wl,-rpath .