Problem with make file

This is a discussion on Problem with make file within the Linux Programming forums, part of the Platform Specific Boards category; Hi I am trying to create my own executable using makefile concepts. I have followed steps as mention in this ...

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    75

    Problem with make file

    Hi

    I am trying to create my own executable using makefile concepts.

    I have followed steps as mention in this thread:

    All files like makefile.am, makefile.in etc are created.
    But when I try to run make... it give me following errors:

    make[1]: Entering directory `/home/nick/Desktop/myprogram'
    Making all in src
    make[2]: Entering directory `/home/nick/Desktop/myprogram/src'
    make[2]: *** No rule to make target `test.o', needed by `test'. Stop.
    make[2]: Leaving directory `/home/nick/Desktop/myprogram/src'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/nick/Desktop/myprogram'
    make: *** [all] Error 2
    The makefile.am is as follow in src:
    bin_PROGRAMS = test
    test_SOURCES = test.c
    And the makefile.am in myprogram folder:
    SUBDIRS = src
    The configure.ac is:
    # -*- Autoconf -*-
    # Process this file with autoconf to produce a configure script.

    AC_PREREQ(2.61)
    AC_INIT(test.c, VERSION, BUG-REPORT-ADDRESS)
    AC_CONFIG_SRCDIR([test.c])
    AC_CONFIG_HEADER([config.h])

    # Checks for programs.
    AC_PROG_CC

    # Checks for libraries.

    # Checks for header files.

    # Checks for typedefs, structures, and compiler characteristics.

    # Checks for library functions.

    AC_CONFIG_FILES([makefile
    src/makefile])
    AM_INIT_AUTOMAKE
    AC_OUTPUT
    I think that I have mention somewhere for test.o.
    Can anybody help me in this?

    Thanks
    Nick

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,513
    With the files you gave, ./configure was failing for me with the following:
    Code:
    $ ./configureconfigure: error: cannot find sources (test.c) in . or ..
    Then I realized, your configure.ac doesn't specify the src directory before test.c:
    Code:
    AC_CONFIG_SRCDIR([src/test.c])
    Once I did that, configure and make worked just fine, I didn't have to add any .o rule.

    Start with a clean setup, just configure.ac, Makefile.am, src/Makefile.am and src/test.c.

    If that still doesn't work, provide all 4 of those basic files, and provide a full dump of your terminal session, with every command you run and all of it's output.

    Also, maybe Google around for some other tutorials. This one seems decent: Developing Programmers .com Blog Archive Autotools Tutorial.

  3. #3
    Registered User
    Join Date
    Jun 2010
    Posts
    75
    Thank for response.
    The executable was created in src now.
    I have a question..
    What should I do that it should always created in my myprogram folder and not in src?
    I have followed the instruction and done in that way.

    Thanks
    Nickman

  4. #4
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,513
    The tutorial you were following talks about how to change the location of where the executable is intalled, with the prefix argument to configure. The tutorial I linked you to also discusses how to do it via src/Makefile.am.

    EDIT: I never messed with GNU autotools until last night when I saw your post, so I know about as much as you do. The best thing you can do is read lots of tutorials and manuals, and experiment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 06-16-2008, 01:18 PM
  2. make file problem
    By bazzano in forum C Programming
    Replies: 7
    Last Post: 09-14-2005, 10:23 AM
  3. How would I make a c++ prgoram make a .exe file?
    By Rune Hunter in forum C++ Programming
    Replies: 9
    Last Post: 12-26-2004, 04:56 PM
  4. BSD make and GNU make problem
    By Skarr in forum Linux Programming
    Replies: 4
    Last Post: 09-10-2002, 12:31 PM
  5. stack make file problem
    By puckett_m in forum C Programming
    Replies: 2
    Last Post: 11-22-2001, 10:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21