https://blog.csdn.net/u010312436/article/details/52486811 在CMakeLists.txt中添加如下一行: add_definitions(-fPIC)