add a file.c in a program.

This is a discussion on add a file.c in a program. within the C Programming forums, part of the General Programming Boards category; Hi I've written a new function for a program. I have the new_function.c, new_function.h and the new_function.o and I've added ...

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    56

    add a file.c in a program.

    Hi

    I've written a new function for a program.
    I have the new_function.c, new_function.h and the new_function.o and I've added those 3 files in the same directory of the others files.
    Then in the file.c (that use the new_function.c), I added:

    Code:
    #include "new_function.h"
    then i try to do:

    ./configure ........... ok

    but the "make" return with:
    926: undefined reference to `function_added'
    where "function_added" is defined and implemented in new_function.h and new_function.c.

    This is the first time for me, but i read that what i've done should be enough.
    Any idea why doesn't work?
    Thanks

    D.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If you look at your makefile, is new_function.c or new_function.o mentioned anywhere? (How did you set up configure?)

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    56
    You are right, the makefile doesn't contain "new_function.o".

    I'm not the author of the program, I've written just a function. So I have to add some reference in the configure file?

    Thanks

    D.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Right. I've never used configure scripts, so I don't know where it would go, but whatever or whoever builds the makefile would need to know what all the files are.

    (Does the person/people who did write the program know or expect you to write an additional function? If so, they would probably have left same in the configure file.)

  5. #5
    Registered User
    Join Date
    Jun 2009
    Posts
    56
    Quote Originally Posted by tabstop View Post
    (Does the person/people who did write the program know or expect you to write an additional function? If so, they would probably have left same in the configure file.)
    Yes, he asked me to add this function. I'd like to learn how to do it

    Thanks for your help, now I know where the problem is.

    D.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    IIRC, it's something like makefile.in which is read by configure to produce a customised makefile for your environment.
    It's the input file(s) to configure which you need to look at changing.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Jun 2009
    Posts
    56
    Yes there is a makefile.in,
    I'm reading it. it is very long file, I'm looking for the configure input files.

    thanks

    D.

  8. #8
    Registered User
    Join Date
    Jun 2009
    Posts
    56
    Hi
    i found the solution.

    I've added to Makefile.in and Makefile.source the file i created.

    Now it works!!

    Thanks

    D

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. add your program to start menu ?
    By Anddos in forum Windows Programming
    Replies: 6
    Last Post: 04-17-2008, 04:15 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 08:48 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

Tags for this Thread


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