Thread: Problem in creating executable from configure.ac

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    113

    Problem in creating executable from configure.ac

    I want to create my own application in which I used configure.ac and create exe using make and make install.
    This all I am doing to clear more on configures command.........

    What I have done is as follow:

    I have create a C++ file in folder Test_Configure name test_file.cpp which only has to print name as follows:

    Code:
    #include<iostream.h>
    
    using namespace std;
    
    int main()
    {
    cout<<"This is Testing Application";
    }
    After that I create configure.ac which has following contents:

    Code:
    # Created by Bargi
    
    AC_PREREQ(2.59)
    AC_INIT([Bargi],[0.9.0],[bargi@xyz],[Test_Configure])
    AM_INIT_AUTOMAKE([foreign])
    AC_CONFIG_HEADER([config.h])
    AC_CONFIG_FILES([Makefile])
    AC_OUTPUT
        bin_PROGRAMS = test
        test_SOURCES = test_file.cpp
    
    AC_CANONICAL_BUILD
    AC_PROG_LIBTOOL
    AC_PROG_CXX
    Then I create Makefile.am

    Code:
    AUTOMAKE_OPTIONS = foreign 1.6
    
    
    sources = new_file.cpp   
    
    package-messages:
    	$(MAKE) -f admin/Makefile.common package-messages
    	$(MAKE) -C po merge
    After all this I run autoreconf command ... It gives following output:

    configure.ac:4: installing `./missing'
    configure.ac:4: installing `./install-sh'
    And It create 16 files including autom4te.cache folder.

    Then I run ./configure ........It create Makefile.

    The output of .configure command is :

    ./configure
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for a thread-safe mkdir -p... /bin/mkdir -p
    checking for gawk... no
    checking for mawk... mawk
    checking whether make sets $(MAKE)... yes
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating config.h
    ./configure: line 3567: bin_PROGRAMS: command not found
    ./configure: line 3568: test_SOURCES: command not found
    checking build system type... i686-pc-linux-gnu
    checking host system type... i686-pc-linux-gnu
    checking for style of include used by make... GNU
    checking for gcc... gcc
    checking for C compiler default output file name... a.out
    checking whether the C compiler works... yes
    checking whether we are cross compiling... no
    checking for suffix of executables...
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking dependency style of gcc... none
    checking for a sed that does not truncate output... /bin/sed
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for ld used by gcc... /usr/bin/ld
    checking if the linker (/usr/bin/ld) is GNU ld... yes
    checking for /usr/bin/ld option to reload object files... -r
    checking for BSD-compatible nm... /usr/bin/nm -B
    checking whether ln -s works... yes
    checking how to recognize dependent libraries... pass_all
    checking how to run the C preprocessor... gcc -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking dlfcn.h usability... yes
    checking dlfcn.h presence... yes
    checking for dlfcn.h... yes
    checking for g++... g++
    checking whether we are using the GNU C++ compiler... yes
    checking whether g++ accepts -g... yes
    checking dependency style of g++... none
    checking how to run the C++ preprocessor... g++ -E
    checking for g77... no
    checking for xlf... no
    checking for f77... no
    checking for frt... no
    checking for pgf77... no
    checking for cf77... no
    checking for fort77... no
    checking for fl32... no
    checking for af77... no
    checking for xlf90... no
    checking for f90... no
    checking for pgf90... no
    checking for pghpf... no
    checking for epcf90... no
    checking for gfortran... no
    checking for g95... no
    checking for xlf95... no
    checking for f95... no
    checking for fort... no
    checking for ifort... no
    checking for ifc... no
    checking for efc... no
    checking for pgf95... no
    checking for lf95... no
    checking for ftn... no
    checking whether we are using the GNU Fortran 77 compiler... no
    checking whether accepts -g... no
    checking the maximum length of command line arguments... 98304
    checking command to parse /usr/bin/nm -B output from gcc object... ok
    checking for objdir... .libs
    checking for ar... ar
    checking for ranlib... ranlib
    checking for strip... strip
    checking if gcc supports -fno-rtti -fno-exceptions... no
    checking for gcc option to produce PIC... -fPIC
    checking if gcc PIC flag -fPIC works... yes
    checking if gcc static flag -static works... yes
    checking if gcc supports -c -o file.o... yes
    checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
    checking whether -lc should be explicitly linked in... no
    checking dynamic linker characteristics... GNU/Linux ld.so
    checking how to hardcode library paths into programs... immediate
    checking whether stripping libraries is possible... yes
    checking if libtool supports shared libraries... yes
    checking whether to build shared libraries... yes
    checking whether to build static libraries... yes
    configure: creating libtool
    appending configuration tag "CXX" to libtool
    checking for ld used by g++... /usr/bin/ld
    checking if the linker (/usr/bin/ld) is GNU ld... yes
    checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
    checking for g++ option to produce PIC... -fPIC
    checking if g++ PIC flag -fPIC works... yes
    checking if g++ static flag -static works... yes
    checking if g++ supports -c -o file.o... yes
    checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
    checking dynamic linker characteristics... GNU/Linux ld.so
    checking how to hardcode library paths into programs... immediate
    appending configuration tag "F77" to libtool
    checking whether we are using the GNU C++ compiler... (cached) yes
    checking whether g++ accepts -g... (cached) yes
    checking dependency style of g++... (cached) none
    But When I run make command it give me following output:

    make all-am
    make[1]: Entering directory `/home/bargi/Test_configure'
    make[1]: Nothing to be done for `all-am'.
    make[1]: Leaving directory `/home/bargi/Test_configure'

    Is my code written in above files correct ?

    Please suggest me where to make changes so that I can create executable ........

    Some code above written I have copied from net.


    Thanks

  2. #2
    Registered User
    Join Date
    Jun 2005
    Location
    Italy
    Posts
    11
    $su [yourpassword]
    $make install

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    113
    Hi ,

    I have tried it but the same result....

    I think that I have to specify the name of the exe and its path.......

    The output is as follow:

    make[1]: Entering directory `/home/bargi/Test_configure'
    make[1]: Nothing to be done for `install-exec-am'.
    make[1]: Nothing to be done for `install-data-am'.
    make[1]: Leaving directory `/home/bargi/Test_configure'

    Please suggest me .......

    Thanks

  4. #4
    Registered User
    Join Date
    Jun 2005
    Location
    Italy
    Posts
    11
    This is my rules for make "configure"

    $cd my program
    $ autoscan
    $ mv configure.scan configure.ac
    $ vim configure.ac
    edit this line
    AC_INIT(MY_PROGRAM_NAME, VERSION, AUTHOR)
    MY_PROGRAM_NAME = name of your program
    VERSION = version of program example 0.1 or 1.4
    AUTHOR = added your email.

    and added later in other line
    AM_INIT_AUTOMAKE

    save your file configure.ac

    $vim makefile.am
    edit this file and added your "src" directory
    SUBDIRS = src

    save your file makefile.am

    $cd src
    $vim makefile.am
    edit this file and added file for compiling
    bin_PROGRAMS = my_program
    my_program_SOURCES = main.c interface.c extra.c

    save this in your makefile.am

    $cd ..
    $ aclocal
    $ autoheader
    $ automake -ac --foreign
    $ autoconf

  5. #5
    Registered User
    Join Date
    Jan 2007
    Posts
    113
    Thanks a lot Salsan for your help !!!!!!!!!!!

    I have successfully build my application.

    One more question......

    Presently exe is created in src folder.......Is there a way so that exe is created on my desired

    location... ???

    And second is that what is the difference between autoconf and autoreconf and which

    command should be used and when ???

    Thanks a lot.........

  6. #6
    Registered User
    Join Date
    Jun 2005
    Location
    Italy
    Posts
    11
    Quote Originally Posted by Bargi View Post
    Presently exe is created in src folder.......Is there a way so that exe is created on my desired

    location... ???
    ......
    in your makefile.am change "src" with directory of source of your file or you speak about installation your "bin" in system ?

    if this look your configure options
    ./configure --help
    Quote Originally Posted by Bargi View Post
    And second is that what is the difference between autoconf and autoreconf and which

    command should be used and when ???
    I've take this from man
    NAME
    autoconf - Generate configuration scripts

    SYNOPSIS
    autoconf [OPTION] ... [TEMPLATE-FILE]

    DESCRIPTION
    Generate a configuration script from a TEMPLATE-FILE if given, or ‘con‐
    figure.ac’ if present, or else ‘configure.in’. Output is sent to the
    standard output if TEMPLATE-FILE is given, else into ‘configure’.
    NAME
    autoreconf - Update generated configuration files

    SYNOPSIS
    autoreconf [OPTION] ... [CONFIGURE-AC or DIRECTORY] ...

    DESCRIPTION
    Run ‘autoconf’ (and ‘autoheader’, ‘aclocal’, ‘automake’, ‘autopoint’
    (formerly ‘gettextize’), and ‘libtoolize’ where appropriate) repeatedly
    to remake the GNU Build System files in the DIRECTORIES or the direc‐
    tory trees driven by CONFIGURE-AC (defaulting to ‘.’).

    By default, it only remakes those files that are older than their pre‐
    decessors. If you install new versions of the GNU Build System, run‐
    ning ‘autoreconf’ remakes all of the files by giving it the ‘--force’
    option.

  7. #7
    Registered User
    Join Date
    Jan 2007
    Posts
    113
    Thanks once again !!!!!

    I have used the following command for installing exe in /home/bargi/run :

    ./configure --prefix=/home/bargi/run
    and then make from src folder.........

    It create exe in src folder......

    Thanks

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Yes. Now do
    make install
    and it should copy the exe to the final destination.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Registered User
    Join Date
    Jan 2007
    Posts
    113
    Thanks a lot to all of you .......................It's really help me.......

  10. #10
    Registered User
    Join Date
    Jun 2005
    Location
    Italy
    Posts
    11
    before make install take privilege of "root" for this try with "su" or "sudo"

    $ ./configure --prefix=YOUR FAVORITE DIRECTORY
    $make
    $su
    #make install

  11. #11
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Bargi View Post
    Thanks a lot to all of you .......................It's really help me.......
    Congratulations, your configure script is probably 10000 times larger than the source code it is "configuring".

  12. #12
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by salsan View Post
    before make install take privilege of "root" for this try with "su" or "sudo"
    Bad idea, if the prefix is within his home directory.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  13. #13
    Registered User
    Join Date
    Jun 2005
    Location
    Italy
    Posts
    11
    Quote Originally Posted by CornedBee View Post
    Bad idea, if the prefix is within his home directory.
    You right, but if you create "configure", I don't think install bin in home directory,

    $mv src/mybin /home/MYHOME/mybin
    .

  14. #14
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    [quote]./configure --prefix=/home/bargi/run[/qutoe]
    With this, it should install everything under /home/bargi/run.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem creating program to the specific specification
    By rushhour in forum C++ Programming
    Replies: 22
    Last Post: 11-28-2008, 12:15 AM
  2. gcc compiling and linking problem
    By maven in forum C Programming
    Replies: 6
    Last Post: 11-14-2008, 05:28 AM
  3. Problem creating dll with gcc/minGW
    By 6tr6tr in forum C++ Programming
    Replies: 1
    Last Post: 04-03-2008, 02:19 PM
  4. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM