Thread: how to execute more than one files??

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    12

    how to execute more than one files??

    heyya..

    I'm a new member in da house,and also new to this "C world"..I have to learn this language since I'm in engineering .....can sumbody tells me how the command line looks like or if there is anything wrong with my MakeFile coz I have type in the program but I dunno how to use it. I'm currently using Borland 5.5 compiler.....so..if anybody can give me some guidance

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Does it give you errors when trying to use the makefile? If so, you should post them.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    12
    I don't even know how to compile it...
    urmm..the complete version is like this.

    Code:
        /* headers.h */
    #include <stdio.h>
    
    void function_a(void);
    void function_b(void);
    void function_c(void);
    Code:
    /*  main.c  */
    #include "headers.h"
    
    main()
    {
    	printf("In the main program\n");
    	function_a();
    	function_b();
    	printf("All done\n");
                      
    }
    Code:
    /* fun_a.c*/
    
    #include "headers.h"
    
    void function_a(void)  {
      printf("	In function_a() \n");
    }
    Code:
    /* fun_b.c*/
    
    #include "headers.h"
    
    void function_b(void)  {
      printf("	In function_b() \n");
      function_c();
    }
    Code:
    /* fun_c.c */
    
    #include "headers.h"
    
    void function_c(void)  {
      printf("	In function_c() \n");
    }
    And then I have this program to type in as my "MakeFile"

    Code:
    CC=bcc32
    HEADERS=headers.h
    silly.exe: main.obj fun_a.obj fun_b.obj fun_c.obj
    	$(CC) -esilly.exe main.obj fun_a.obj fun_b.obj fun_c.obj
    main.obj: $(HEADERS) main.c
    	$(CC) -I. -c main.c
    fun_a.obj: $(HEADERS) fun_a.c
    	$(CC) -I. -c fun_a.c
    fun_b.obj: $(HEADERS) fun_b.c fun_c.obj
    	$(CC) -I. -c fun_b.c
    fun_c.obj: $(HEADERS) fun_c.c
    	$(CC) -I. -c fun_c.c
    clean:
    	del silly *.obj *.tds
    tidy:
    	del *.tds
    -----------------------------------------------------
    what type of file should I save that "MakeFile"...is it just MakeFile or MakeFile.exe .......or any other extension...

    and in my lecture notes, it said that I have to type in command
    Code:
    make silly.exe
    to build the program. But when I type in the command.....I got msg >>>
    Code:
    Fatal: 'silly.exe' does not exist - don't know how to make it

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    You having troubles running make, what you need to do first is to try and remove the exe and obj files when you compiled the program. do the following ls to see the files. remove the old object files by doing make clean <hit enter>. Also you clean in the make file should be
    Code:
     clean:
    rm *.o
    that will remove the obj files. as stated above. After you have done that ls again and you will see the source files. Now simple do make <hit enter>. now make will follow the instructions in the make file and will compile the program.
    Last edited by InvariantLoop; 03-12-2005 at 06:56 PM. Reason: man too many typos today
    When no one helps you out. Call google();

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Using Unix style commands from inside a Borland makefile isn't going to help too much.

    Here's what to do.
    Ensure the makefile is called "Makefile" (no extension).
    Put all the files in the same directory, then type:
    Code:
    >make
    
    MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
            bcc32 -I. -c main.c
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    main.c:
    Warning W8070 main.c 11: Function should return a value in function main
            bcc32 -I. -c fun_a.c
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    fun_a.c:
            bcc32 -I. -c fun_c.c
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    fun_c.c:
            bcc32 -I. -c fun_b.c
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    fun_b.c:
            bcc32 -esilly.exe main.obj fun_a.obj fun_b.obj fun_c.obj
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
    Alternatively, you can call your makefile something else, and use "make -f MyMakeFile.txt".

    To clean up (delete .exe's etc), use "make clean".
    To compile a specific component, use something like "make fun_b.obj". To specifically request a full compile, use "make silly.exe".
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    Ah i thought he was trying to make his makefile work, didnt know he had to use Borland specifically. Thanks Hammer
    When no one helps you out. Call google();

  7. #7
    Registered User
    Join Date
    Mar 2005
    Posts
    12

    Thumbs up thanks

    hey....this is really great...I wish I have registered here long time ago so I would have learn lot more,,,,allwiz thought that thic C thingy is quite interesting ....especially when we successfully run the program after so much tense..and effort make me wanna learn more about C.....cheers mate!!!

  8. #8
    Registered User
    Join Date
    Mar 2005
    Posts
    12

    cheers......

    <InvariantLoop> it doesn't matter.....thanks for trying to help anyway

  9. #9
    Registered User
    Join Date
    Mar 2005
    Posts
    12
    I manage to compile and run the right message just if I use "make -f MyMakeFile.txt".......when I try to rebuild specific component, I get the message that the rebuild was success (I think soo..) but it didn't reconnect with the main one....I still got the previous message even after the rebuild process...

    and also how come when i try to type in command
    Code:
     make clean
    i got message
    Code:
    C:\Borland\bcc55\Bin\EMAT10920>make clean
    MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
    Fatal: 'clean' does not exist - don't know how to make it
    ym id >>>>> asmahmazlan

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 09:52 PM
  2. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  3. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM