库依赖关系及其顺序 [英] lib dependencies and their order

查看:250
本文介绍了库依赖关系及其顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,如果我们没有列出在makefile里面一定顺序库,它失败。

at times if we don't list libs in certain order inside a makefile, it fails.

其原因是 - 定义应该在使用前。

The reason being - definition should come before its use.

如何确定正确的顺序?

推荐答案

其实,链接库时,使用应该定义之前。任何未解决的符号需要一个库文件提供处理它们的定义之前是已知的。

Actually, when linking libraries, the use should come before the definition. Any unresolved symbols need to be known before a library file providing their definitions is processed.

什么来的次序,恐怕你必须手动完成。如果力霸取决于libB(即力霸使用符号从libB),那么你必须按照这个顺序链接:香格里拉-lb

What comes to the order, I'm afraid you have to do this manually. If libA depends on libB (i.e. libA uses symbols from libB), then you have to link in this order: -lA -lB.

这是主要的文件的问题。良好的文档库中明确规定这取决于什么其他的库,所以你可以计算出正确的链接顺序。

This is mostly a matter of documentation. A well-documented library clearly states what other libraries it depends on, so you can figure out the correct linking order.

如果你不想阅读文档,或没有可用的,试错的文档始终是一个选择:)

If you don't want to read documentation or there is no documentation available, trial and error is always an option :)

这篇关于库依赖关系及其顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆