简体   繁体   中英

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.

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. However, when make is ran, it fails to find references of functions called from the static lib ie .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 .

The make file project is an existing well known open source project with standard bootstrap, configure, make and make install steps.

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. – keltar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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