简体   繁体   中英

How can I use a library's header files to generate a libfoo.sym file for use with libtool -export-symbols?

I am building a shared library for the Debian GNU/Linux distribution and I am worried about the number of symbols from internal functions that it exports without any need. Since the library is built using autoconf/automake/libtool, the answer is easy: I can just add -export-symbols libfoo.sym to libfoo_la_LDFLAGS and specify only the symbols I want exported in that file.

But since this involves error-prone manual work, I figured that there has to be a better way. Is it possible to automate reading the (in this case) dozens of .h files that accompany the library and generate a first version of the libfoo.syms file.

Could I just use the C (or C++) compiler to do the busy work for me?

这等效于提取函数原型,并在此处介绍: 提取C / C ++函数原型

But since this involves error-prone manual work, I figured that there has to be a better way. Is it possible to automate reading the (in this case) dozens of .h files that accompany the library and generate a first version of the libfoo.syms file.

It might be more useful to use nm on the object files instead of trying to parse header files. nm can be told to restrict the output to just exports.

Could I just use the C (or C++) compiler to do the busy work for me?

Certain compilers have tools to assist with this, like gcc's visibility support.

But the real problem is you must know what functions must be exported and which must not.

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