g++ cannot static link libmongcxx(r3.0.2) but dynamic link works

╄→гoц情女王★ 提交于 2019-12-01 11:33:47

The -static flag forces the linker to accept only static libraries and not any shared libraries. In other words it does not require a dependency on dynamic libraries at runtime in order to run. Most likely mongocxx has some dependencies. To achieve static linking requires that the archive (.a) versions of your libraries exist on the system.

The another possible issue is that the order of static libraries in the linker command line does matter, so that might also be an issue if there is a dependency on different static libs. The linker will process the libraries in order as they are in the command line, and from each static lib it will only pull those symbols that are required (with as much information as the linker has at that time)

Use nm . That will give you the symbol names.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!