LinuxQuestions.org
Help answer threads with 0 replies.
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
 
LinkBack Search this Thread
Old 02-09-2012, 02:24 PM   #1
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Gentoo
Posts: 330
Blog Entries: 24

Rep: Reputation: 38
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: Slackware64 13.37, Kubuntu 10.04
Posts: 2,944

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: Gentoo
Posts: 330
Blog Entries: 24

Original Poster
Rep: Reputation: 38
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: Slackware64 13.37, Kubuntu 10.04
Posts: 2,944

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
Posts: 1,421

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
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: Slackware64 13.37, Kubuntu 10.04
Posts: 2,944

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: Gentoo
Posts: 330
Blog Entries: 24

Original Poster
Rep: Reputation: 38
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: Slackware64 13.37, Kubuntu 10.04
Posts: 2,944

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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 04:31 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration