Thread: Adding Library to Linux

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    61

    Smile

    Thank you MK27 REALLY
    Your description was just fine, but this sentence:
    If a library is missing, the script should tell them so they can install it
    This can be very hard according to the distribution and the different versions, maybe conflict between versions and so on. I'm writing this program for a private place that handing these matters will be hard for them But still you are right about probable crashing or problems with glibc.

    Thank you again

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by hosseinyounesi View Post
    This can be very hard according to the distribution and the different versions, maybe conflict between versions and so on.
    No, it's actually not that much work -- altho learning to do it the first time is, because autotools is not very well documented anywhere. But once you understand it, it's as simple as this:
    Code:
    # Checks for libraries.
    GTK_REQUIRED_VERSION=2.12.0
    That's the minimum version that is known to work, this goes in "configure.ac". When the configure script generated from this by autoconf is run, if the min development libraries are not installed, you get a message like "configure could not find gtk-lib-devel >= 2.12...aborting". Then you know you have to install your distro's gtk-lib-devel package. Which is the only real hassle about compiling from source -- you do need to have development library headers installed, not just the library runtime packages.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    61

    Question

    Well, how can make configure and makefile files? I'm now using KDEVELOP, it makes these files but there is a problem: automake versions conflict or is not compatible I solved this problem by using autoreconf -fvi Other IDEs in Linux don't do this
    Any EASY way to do this? Or wayS?

    Thanks

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by hosseinyounesi View Post
    Well, how can make configure and makefile files? I'm now using KDEVELOP, it makes these files but there is a problem: automake versions conflict or is not compatible I solved this problem by using autoreconf -fvi Other IDEs in Linux don't do this
    Any EASY way to do this? Or wayS?
    I don't use an IDE (and I don't program C++) so... Anyway I've only done the whole autotools routine a few times, with things that I actually distributed (and it worked). Here's my notes:
    Code:
    need:
    Makefile.am for each dir
    /configure.ac (could use autoscan)
    
    then in order:
    aclocal
    automake -ac
    autoheader
    automake -ac again
    autoconf
    the actual commands are in bold. The reason for the second automake is that you need to run it before autoheader, but you need the file produced by autoheader (config.h.in) to do the automake properly.

    The only manual work is writing the Makefile.am and configure.ac files. Here are the two links I used and bookmarked:
    Introduction to GNU Build Tools (automake, autoconf, and configure Script)
    GNU Automake By Example
    Plus a little bit reading the man pages. When you're done you have a directory like this:
    Code:
    aclocal.m4  
    autom4te.cache  
    compile      
    configure     
    COPYING   
    install-sh   
    Makefile.in  
    NEWS    
    src/
    AUTHORS     
    ChangeLog       
    config.h.in  
    configure.ac  
    depcomp  
    INSTALL  
    Makefile.am  
    missing
    Most of which autotools does. src/ contains the .c and .h files and another Makefile.am, and the file produced by automake from it, Makefile.in. If you've ever downloaded a source packaged and compiled it this should be familiar (if not, find something and try it, it's easy). Now the end user just unzips the tar ball and types:

    ./configure
    make
    make install


    And maybe gets to watch gcc doing strange things for a minute. The Makefile can contain instructions for installing various components, like documentation, images, etc. in the right places in the filesystem.
    Last edited by MK27; 07-31-2009 at 08:56 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Registered User
    Join Date
    Jul 2009
    Posts
    61

    Thumbs up

    Thank you,

    I'm now going to first learn then try it out

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dlopen, dlsym does not work in Linux as expected
    By balakv in forum C Programming
    Replies: 2
    Last Post: 04-03-2007, 12:44 AM
  2. SVN Import Causes Crash
    By Tonto in forum Tech Board
    Replies: 6
    Last Post: 11-01-2006, 03:44 PM
  3. Problems adding a user in linux
    By axr0284 in forum Tech Board
    Replies: 1
    Last Post: 12-10-2004, 09:13 AM
  4. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM
  5. linux vs linux?
    By Dreamerv3 in forum Linux Programming
    Replies: 5
    Last Post: 01-22-2002, 09:39 AM