简体   繁体   English

将静态库与静态库链接

[英]Link static library with static library

I have a Makefile.am with two noinst_LIBRARIES , and one of them needs to link with the other. 我有一个带有两个noinst_LIBRARIESMakefile.am ,其中一个需要与另一个链接。

Adding it to the CFLAGS throws a compiler warning, but as far as I know, automake likes to freak out about using LDADD with libraries, since they are not complete programs. 将其添加到CFLAGS会引发编译器警告,但据我所知,由于它们不是完整的程序,因此automake会喜欢将LDADD与库一起使用。

How can I do this, assuming libb.a needs to pull in liba.a ? 我怎样才能做到这一点,假设libb.a需要拉liba.a

You can't do it. 你做不到 Actually, what you are trying to do doesn't really make sense. 实际上,您尝试执行的操作实际上没有任何意义。 Static libraries are just archives containing object files and a table of contents. 静态库只是包含目标文件和目录的存档。 Put simply, you can think of a static library as a .zip containing .o files. 简而言之,您可以将静态库视为包含.o文件的.zip

The linking phase only takes place when compiling a shared object or executable. 链接阶段仅在编译共享库或可执行文件时发生。 When your program is linked against liba.a , you also need to specify -static -lb or similar and that's it. 当您的程序与liba.a链接时,您还需要指定-static -lb或类似名称即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM