LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-09-2012, 02:24 PM   #1
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
first library with autotools / libtool


Hi. I created my first tiny C library yesterday. I can build it fine using manual gcc commands, but I'm having trouble getting it integrated with autotools and libtool.

When I run "autoreconf" I get this:
Code:
$ autoreconf
Makefile.am:1: variable `librremove_@EXAMPLE_API_VERSION@_la_SOURCES' is defined but no program or
Makefile.am:1: library has `librremove_@EXAMPLE_API_VERSION@_la' as canonical name (possible typo)
Makefile.am:2: variable `librremove_@EXAMPLE_API_VERSION@_la_LDFLAGS' is defined but no program or
Makefile.am:2: library has `librremove_@EXAMPLE_API_VERSION@_la' as canonical name (possible typo)
Here is my configure.ac, which I made trying to follow some online tutorials:

Code:
$ cat configure.ac
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_INIT([Recursive Remove], [0.3.1], [christopher.howard@frigidcode.com],
        [rremove], [http://frigidcode.com/code/rremove/])
AC_PREREQ([2.68])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CC

LT_INIT
AC_SUBST([EXAMPLE_SO_VERSION], [0:0:0])
AC_SUBST([EXAMPLE_API_VERSION], [0.0])

AC_CONFIG_SRCDIR([rremove.c])
AC_CONFIG_FILES([Makefile])

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT
Likewise, my Makefile.am:

Code:
$ cat Makefile.am 
librremove_@EXAMPLE_API_VERSION@_la_SOURCES = rremove.c
librremove_@EXAMPLE_API_VERSION@_la_LDFLAGS = -version-info $(EXAMPLE_SO_VERSION)
librremove_@EXAMPLE_API_VERSION@_la_CFLAGS = -Wall -Wextra -pedantic -std=c99
rremove_includedir = $(includedir)
nobase_rremove_include_HEADERS = rremove.h
Evidently I missed some important concept along the way. Can someone point me in the right direction?
 
Old 02-12-2012, 09:25 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
I don't think you can do that sort of substitution within variable names; it confuses libtool. Normally you would use lib_LTLIBRARIES=librremove.la, then librremove_la_SOURCES=..., and libtool will take care of numbering the .so at install time based on the -version-info. It looks like you're trying to put Makefile.in stuff in the Makefile.am, but the Makefile.am must be understandable by libtool before the Makefile.in can be created.

Also, have you run libtoolize? I always get confused about what to run and in which order, so I usually run automake, autoconf, and aclocal repeatedly until it works (taking care of warnings if they come up.) Not the best way to do it, but once you get it running for a project it's no work to add new things to the project (which is why I'm not all that skillful the initial setup.)
Kevin Barry
 
Old 02-12-2012, 11:25 PM   #3
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467

Original Poster
Blog Entries: 60

Rep: Reputation: 51
Quote:
Originally Posted by ta0kira View Post
I don't think you can do that sort of substitution within variable names; it confuses libtool. Normally you would use lib_LTLIBRARIES=librremove.la, then librremove_la_SOURCES=..., and libtool will take care of numbering the .so at install time based on the -version-info. It looks like you're trying to put Makefile.in stuff in the Makefile.am, but the Makefile.am must be understandable by libtool before the Makefile.in can be created.

Also, have you run libtoolize? I always get confused about what to run and in which order, so I usually run automake, autoconf, and aclocal repeatedly until it works (taking care of warnings if they come up.) Not the best way to do it, but once you get it running for a project it's no work to add new things to the project (which is why I'm not all that skillful the initial setup.)
Kevin Barry
What I did to fix the problem (before you posted) was I switched to a different tutorial and ended up with a Makefile.am more like this:

Code:
lib_LTLIBRARIES = librremove.la
     librremove_la_SOURCES = rremove.c
     librremove_la_LDFLAGS = -version-info 0:2:0
     librremove_la_CFLAGS = -Wall -Wextra -pedantic -std=c99
rremove_includedir = $(includedir)
nobase_rremove_include_HEADERS = rremove.h
And got rid of the AC_SUBST junk in the configure.ac. (Of course, I properly increment the version-info according to instructions.) So far, this is working great. Not sure now what the API_VERSION junk was about. I don't really care much about SO_VERSION variable substitution because it seems just as easy to edit the Makefile.am for this, though I suppose there might be a problem down the road if I expand to multiple directories.
 
Old 02-13-2012, 08:50 AM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
The -version-info should be specific to each .la because the resulting numbering will affect which library a new program is linked to (if multiple versions are installed.) That means it should probably be set within Makefile.am exactly where you have it, rather than in configure.ac. The reasoning is that if you're changing the library enough to change the version then you're probably messing around in it's source directory, anyway. I use autotools for a project with 27 libraries and it's helpful to change the version in the same place I change the source, but it can also be a pain if you have to change the versions of several libraries at the same time (e.g. a large set of plug-ins with comparable interfaces.)
Kevin Barry
 
Old 02-13-2012, 09:44 AM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by ta0kira View Post
Also, have you run libtoolize? I always get confused about what to run and in which order, so I usually run automake, autoconf, and aclocal repeatedly until it works
That's what autoreconf is for:
Quote:
man autoreconf(1)
...
Run 'autoconf' (and 'autoheader', 'aclocal', 'automake', 'autopoint' (formerly 'gettextize'), and 'libtoolize' where appropriate) repeatedly to remake the GNU Build System files in specified DIRECTORIES and their subdirectories (defaulting to '.').
 
Old 02-13-2012, 02:09 PM   #6
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by ntubski View Post
That's what autoreconf is for:
I've never actually looked at that manpage. Apparently I have the same functionality as autoreconf...
Kevin Barry
 
Old 02-14-2012, 12:57 AM   #7
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467

Original Poster
Blog Entries: 60

Rep: Reputation: 51
Quote:
Originally Posted by ta0kira View Post
The -version-info should be specific to each .la because the resulting numbering will affect which library a new program is linked to (if multiple versions are installed.) That means it should probably be set within Makefile.am exactly where you have it, rather than in configure.ac. The reasoning is that if you're changing the library enough to change the version then you're probably messing around in it's source directory, anyway. I use autotools for a project with 27 libraries and it's helpful to change the version in the same place I change the source, but it can also be a pain if you have to change the versions of several libraries at the same time (e.g. a large set of plug-ins with comparable interfaces.)
Kevin Barry
27 libraries?? What project is that?
 
Old 02-14-2012, 10:32 AM   #8
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by hydraMax View Post
27 libraries?? What project is that?
Almost all of them are plug-ins. It's a personal project that unfortunately outpaced my ability to document it. Realistically, I need to merge about 8 of them into 1, but there's only one that needs to be linked to by someone using the project. It's mostly been for the purposes of my own learning for the last 5 years, with some possible practical uses for me in the future.
Kevin Barry
 
Old 12-31-2014, 01:50 PM   #9
debguy
Member
 
Registered: Oct 2014
Location: U.S.A.
Distribution: mixed, mostly debian slackare today
Posts: 207

Rep: Reputation: 19
Try this !

autoproj (a short script)

i have used this on a few of my things even to re-make old termcap "new". it makes a project for you: it makes the AM_FOO and config.ac and etc all that.

autoproj-1.0.2.tar.gz

http://sourceforge.net/projects/debg...j-1.0.2.tar.gz

it looks at a "minimal" .c or .cpp project, fills in some templates, and runs autotools appropriately to make a bin or .so or .a (it can't do everything, no), includes distributing files and make check and make dist.

it's not "perfect" but on a small .c -> a.out or .c->a.so project you can read the short script "autoproj" to see what it does.

because it's automated the script, reading it tells you what you need to decide to do as well


i could not find a gnu termcap that made termcap.so.2 that was not distro-packaged, so i made this. i gnu what to make hack but didnt know how to start an autool project from scratch and wanted to record the process, and the recording of it is the script "autoproj".

termcap-1.3.2.tar.gz

http://sourceforge.net/projects/debg...p-1.3.2.tar.gz

Last edited by debguy; 12-31-2014 at 01:55 PM. Reason: URL are hacked, not visibl
 
Old 12-31-2014, 02:01 PM   #10
debguy
Member
 
Registered: Oct 2014
Location: U.S.A.
Distribution: mixed, mostly debian slackare today
Posts: 207

Rep: Reputation: 19
i think some IDE environments (graphical interface to compiling) create configure.ac and Makefile.am for you, fyi
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The good and the bad with Autotools, Autoconf, Automake and Libtool for open so LXer Syndicated Linux News 0 05-09-2008 09:12 PM
autotools and static library sergio21 Linux - Software 1 01-18-2007 03:46 PM
library output directory with autotools lgavitt Programming 0 10-15-2006 11:31 AM
libtool: link: cannot find library jrdioko Linux - Software 0 01-13-2006 10:23 PM
Libtool cant find library that exists... Kane635 Linux - Software 0 12-13-2004 06:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration