Linking C files (Unix)

This is a discussion on Linking C files (Unix) within the C Programming forums, part of the General Programming Boards category; Hi, I am working on a growing c program in a Unix environment. I have a main program which is ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    19

    Linking C files (Unix)

    Hi, I am working on a growing c program in a Unix environment.

    I have a main program which is linked to some other programs through header files. I compile them all at once as follows

    gcc main.c a1.c b1.c

    It works. But if I just make changes in a1.c, is there any way I can just recompile that part, and then linking it somehow? (Rather than recompiling everything)

    Further, I have an alternative file called a2.c which can replace a1.c (the files contain functions with the same I/O, but somewhat different functionality). If I want to run some runs with a1.c and some with a2.c, do I need to recompile between the runs or is there some way I can have compiled versions of a1 and a2 and simply indicate which one to use when I execute the main program?

    Thanks for any and all help.

    Tor

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    But if I just make changes in a1.c, is there any way I can just recompile that part, and then linking it somehow? (Rather than recompiling everything)
    Yep. Use a make file.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    19

    Thanks, that helped. What about arguments?

    Thanks a lot vVv, that helped a lot.

    Now, what if I want to use arguments for the objects?

    I know that for my executable a.out, I can send in arguments with argv/argc. These go to the main function. But what if I need to specify one or a few arguments for one of the objects, say a1.o. Is this possible to do during linking or execution?

    Thanks again,

    Tor

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    19

    Smile Thanks, that was helpful

    Tor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open files inside directory (UNIX platform)
    By swagatob in forum C Programming
    Replies: 15
    Last Post: 10-25-2004, 01:58 AM
  2. Linking Source Files
    By ChrisJ in forum C++ Programming
    Replies: 4
    Last Post: 06-27-2003, 10:33 AM
  3. Linking multiple source files: Undefiled Reference to...
    By Inquirer in forum C++ Programming
    Replies: 4
    Last Post: 05-03-2003, 06:47 PM
  4. Using c++ standards
    By subdene in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2002, 10:15 AM
  5. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 09:35 AM

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