how gcc automatically know to include glib library

依然范特西╮ 提交于 2019-12-02 04:16:56

No.

The problem of looking at C source code and figuring out which libraries it uses is very hard. It feels kind of "AI complete" to me, which is why it's typically solved manually by the programmer pointing out the exact right libraries to satisfy the dependencies with.

Just for glib, it's easy to imagine a system with both glib 1.x and 2.x versions installed, and some calls are named exactly the same. Now try to imagine a computer program capable of decucing what you meant, which library to link with. It's not possible, since only the programmer knows.

The pkg-config tool helps with the mechanics of what each library requires in order to be used, but it's still up to yuo to tell it (via the module name argument(s)) which exact libraries to use.

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