CentOS 上的 gcc 版本:gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
Ubuntu 上的 gcc 版本:gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
CentOS 正常编译过,Ubuntu 报错,纠结了一天,原来是 gcc 版本不一样导致 linker 查找链接函数方式不同,贴上来帮助遇到同样问题的 coder
The trick here is to put the library AFTER the module you are compiling. The problem is a reference thing. The linker resolves references in order, so when the library is BEFORE the module being compiled, the linker gets confused and does not think that any of the functions in the library are needed. By putting the library AFTER the module, the references to the library in the module are resolved by the linker.