简体   繁体   English

如何与现有自动制作项目中的静态库链接

[英]how to link with a static library in an existing auto make project

I have a static library (.a file) that i can link fine with a main program using the following command line on Linux by placing the .a in the current folder and using an include with "" to prefer current folder for library location. 我有一个静态库(.a文件),可以通过在Linux上使用以下命令行,将.a放在当前文件夹中,并使用包含“”的include来首选当前文件夹的库位置,从而可以与主程序很好地链接。

gcc userfile.c -L. -lnameoflib

However, i needed to integrate this pre-built library into an auto make file project. 但是,我需要将此预构建的库集成到一个自动制作文件项目中。 I have tried adding the userfile.c to the list of source files in Makefile.am. 我尝试将userfile.c添加到Makefile.am中的源文件列表中。 However, when make is ran, it fails to find references of functions called from the static lib ie .a 但是,当运行make时, 它无法找到从静态库(即.a)调用的函数的引用。

Upon some investigation it seems to be attempting to create a library with the name.a where as the library already exists and i just want script to use it . 经过一番调查,它似乎正在尝试使用name.a创建一个库,因为该库已经存在 ,我只希望脚本使用它

The make file project is an existing well known open source project with standard bootstrap, configure, make and make install steps. make文件项目是一个现有的知名开源项目,带有标准的引导程序,配置,make和make安装步骤。

Would really appreciate any help. 非常感谢您的帮助。

If you don't want this .a to be built by existing makefiles, just add LDADD = ./libsomething.a into Makefile.am and re-run automake && configure. 如果您不希望此.a由现有的makefile构建,只需将LDADD = ./libsomething.a添加到Makefile.am然后重新运行automake && configure。 – keltar –海藻

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

相关问题 如何将项目链接到同一C静态库的两个不同版本? - How to link a project to two different versions of the same C static library? 如何使链接到静态库也链接到它的依赖项? - How to make linking to a static library also link to its dependency as well? 如何链接到C中的静态库? - How to link to a static library in C? 在不更改源文件的情况下重建exe时如何自动链接新的静态库? - How auto link new static library when rebuild exe with no source file change? 如何将带有 .c 和 .h 文件的现有项目转换为 Visual Studio 2019 中的动态链接库? - How can I convert an existing project with .c and .h files into a dynamic link library in visual studio 2019? 将静态库与静态库链接 - Link static library with static library 如何在Eclipse中将C项目与C ++静态库(使用opencv)链接 - How to link a C project with a C++ static library(using opencv) in eclipse 如何在MinGW或GCC中自动链接库? - How to auto link a library in MinGW or GCC? 如何在静态库中使用gcc链接强符号来覆盖弱符号? - How to make gcc link strong symbol in static library to overwrite weak symbol? 如何将应用程序与静态库链接+为什么不起作用 - How to link app with static library + why this is not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM