Hello World Library using autotools
Asked Answered
B

1

10

Creating bin program is really easy using autotools I need to just define two files.

`Makefile.am'

bin_PROGRAMS = hello
hello_SOURCES = hello.c

`configure.in'

AC_INIT(hello.c)
AM_INIT_AUTOMAKE(hello,1.0)
AC_PROG_CC
AC_PROG_INSTALL
AC_OUTPUT(Makefile)

can any body give a smallest example for creating static library using autotools ?

Burgonet answered 28/9, 2011 at 11:43 Comment(3)
The syntax you use for configure.in is seriously outdated! Please read the "Hello World" example from the Automake manual for the current syntax. sourceware.org/automake/automake.html#Hello-WorldDivvy
@adi I just started learning it. and found that as exampleBurgonet
Yes, it's a problem when you begin: a lot of tutorials you find on the Internet has been written around 1999-2000 when Automake 1.4 and Autoconf 2.13 were everywhere. But these tools have been huge improvement over the year, and the syntax changed a lot. As a rule of thumb, if your document uses configure.in instead of configure.ac, it is likely to be outdated. I have a tutorial with up-to-date syntax at lrde.epita.fr/~adl/autotools.html if you want.Divvy
D
17

Makefile.am:

lib_LIBRARIES = libhello.a
libhello_a_SOURCES = hello.c

configure.ac:

AC_INIT([libhello], [1.0], [[email protected]])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_PROG_RANLIB
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

The documentation for building libraries with Automake is here.

Divvy answered 28/9, 2011 at 14:43 Comment(3)
@adi I got one more question https://mcmap.net/q/1083805/-autotools-include-pathBurgonet
Is AM_PROG_AR missing from configure.ac in the above example?Tail
@Tail Yes if you need to support MSVC's "lib" tool.Divvy

© 2022 - 2024 — McMap. All rights reserved.