简体   繁体   中英

is there a way package C libary with header

I'm making a library in C. Now I am about to deliver it to my tester and a problem arises.

I have to ship both my .a library and quite a lot of header files. Those header files appeared to be very inconvenience to use for the tester. Is there anyway to reduce the amount of files need to deliver so it is easier to move around and setup? (eg pack all header files into 1 or something like that)

The most common way of delivering software (including libraries) on Linux is using packages (such as RPM on Red Hat/CentOS or DEB on Debian/Ubuntu). It will require some additional effort from you (learning to use some new tools, writing an rpm/deb spec, etc), but it will pay off:

  • packages include version numbers, so it will be easy to track, what exactly you are testing
  • packages allow you to install files into directories specified by you (eg /usr/include for headers, /usr/lib for libraries).
  • if you manage to set up a private package repository, your testers will be able to install/upgrade/downgrade the library using standard Linux tools like apt-get or yum .

As for minimizing the number of headers, a common practice is to split headers into two subsets: interface headers (that define the API of your library) and internal headers (that declare functions and types used internally, implementation details). Only the former need to be installed. Example: libjpegturbo . This repository has many header files, but the corresponding package for CentOS 7 only installs 4 headers).

If that is not enough, you could simply concatenate all your interface headers into one big header (it should work, provided that the order is correct). Googletest library uses a python script to merge their headers (and sources too).

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