LinuxQuestions.org
Review your favorite Linux distribution.
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-29-2012, 05:54 PM   #1
bjdodo
Member
 
Registered: Dec 2006
Location: Ireland
Distribution: Slackware 12, kubuntu
Posts: 35

Rep: Reputation: 16
dependency introduced breaking change, how to workaround with automake


Hi

I am maintaining an application that I wrote a long time ago, in c++. I am facing an issue now in that a library I use has changed the signature of one of its functions. So the code I have builds on ubuntu (ubuntu has an old version of this library in its repos), but it does not build on archlinux (archlinux is bleeding edge). If I fix the code on archlinux, it breaks on ubuntu.

I have read that you can achieve that some defines can be created by the automake tool, depending on the version of the library that I could use in my c++ code. The way I imagine it is that I run ./configure, then it will detect the version of the library, will decide whether it is old or new and then it will define constants. So in my c++ code I can do this:

#ifdef NEWLIBRARY
libfunction(1,2,3); // new signature
#else
libfunction(1,2); // old signature
#endif

Could someone please describe how it works, and could you please give me a few pointers like an example that does this or some keywords that can be used in configure.ac to achieve this?

Thank you and best regards,
Jozsef
 
Old 03-01-2012, 12:26 AM   #2
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
In general you can use AC_DEFINE to pass information from configure into your code.

But usually, a library should have some way of getting the version from the code.

Also, note that
Quote:
The Autoconf approach to portability is to test for features, not for versions.

http://en.wikipedia.org/wiki/Autoconf#Approach
 
Old 03-01-2012, 04:58 PM   #3
bjdodo
Member
 
Registered: Dec 2006
Location: Ireland
Distribution: Slackware 12, kubuntu
Posts: 35

Original Poster
Rep: Reputation: 16
Hi

Thank you for your answer.

Quote:
The Autoconf approach to portability is to test for features
That is a great approach! But where do I start? How does this work?

Thank you again,
Jozsef
 
Old 03-01-2012, 10:50 PM   #4
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
Hi.

You can write a simple check to test if it compiles with your library successfully. Look here.
 
Old 03-02-2012, 12:55 PM   #5
bjdodo
Member
 
Registered: Dec 2006
Location: Ireland
Distribution: Slackware 12, kubuntu
Posts: 35

Original Poster
Rep: Reputation: 16
Hi firstfire,

Using the page you have given I have solved it with versioning. Possibly the compiling thing would be a bit more robust, but for this, for now it does not matter.

Here are the details, if someone is interested, search for PKG_CHECK_MODULES on this page:
https://sites.google.com/site/jozsef...tents/automake

Also here is a real life example, search for MEDIASTREAMER28:
http://gtalx.svn.sourceforge.net/vie...42&view=markup
and here is the .h file (note that ../../config.h is included):
http://gtalx.svn.sourceforge.net/vie...42&view=markup

BTW I find it amazing that ./configure can try to build small snippets to see if a function is supported on the user's PC. This is the best technology I have seen; automake has grown a lot in my eyes :-)

Thank you very much for your help!
Jozsef
 
1 members found this post helpful.
Old 03-02-2012, 10:03 PM   #6
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:
AC_MSG_NOTICE([Error - gloox is required to build the app])
You might want to use AC_MSG_WARN or AC_MSG_ERROR for this.
 
  


Reply

Tags
autobuilds, autoconf, autotools, version



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
Inter library dependency and automake chocopie1986 Programming 6 09-19-2011 06:00 AM
How to change the filename of a library dependency? thatbloke Linux - Software 1 01-29-2009 02:29 PM
Change in dependency of libxine1 and broken new package chandru.in Ubuntu 5 11-29-2007 05:32 AM
Scribus installation problem, sez I need automake 1.6 when automake 1.9 is istalled Rockgod2099 Linux - Software 13 11-14-2004 06:37 PM
slackware 9 asking for automake 1.6 while i have automake 1.7 gtgoku Slackware 1 10-19-2003 08:59 AM

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

All times are GMT -5. The time now is 03:54 AM.

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