简体   繁体   English

使用Autotools打包库

[英]Packaging a library with Autotools

I'm starting out with Autotools, and I'm trying to package a library (a generic stack implementation for learning purposes) along with some usage examples. 我从Autotools开始,并尝试打包一个库(用于学习目的的通用堆栈实现)以及一些用法示例。

The library source lives in src and the example in examples . 库源代码位于src ,示例包含在examples

I have the following Makefile.am : 我有以下Makefile.am

lib_LTLIBRARIES = libstack.la
libstack_la_SOURCES = src/stack.c    

check_PROGRAMS = example/stack
example_stack_SOURCES = example/stack.c
example_stack_LDADD = libstack.la

As long as my understanding goes, I need to specify a header for libstack.la , and include that from my example, but I get the following error when running autoreconf after adding libstack_la_HEADERS = src/stack.h to Makefile.am : 只要我能理解,我就需要为libstack.la指定一个头libstack.la ,并在示例中包括它,但是在将libstack_la_HEADERS = src/stack.h添加到Makefile.am之后,运行autoreconf时出现以下错误:

$ autoreconf -iv
... (omiting irrelevant parts)
Makefile.am:3: error: 'libstack_la_HEADERS' is used but 'libstack_ladir' is undefined
autoreconf: automake failed with exit status: 1

I couldn't find any information related to the dir prefix. 我找不到与dir前缀相关的任何信息。

What am I missing here? 我在这里想念什么?

To handle header of library you should write something like this: 要处理库的标头,您应该编写如下内容:

libstackincludedir = $(includedir)/my_mega_stack
libstackinclude_HEADERS = stack.h

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

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