Thread: make

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    270

    Question make

    Hi

    Say i got a make file that compiles:
    name.c
    library.h
    name2.c

    Now name.c is my main line program. Now i just want to see if i got this correct.
    I type make to compile the three. Then to run the main line file what do i type?
    is it a.out?

    (Im using unix)

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Unless your make renamed the executable, then I'm guessing it would be called a.out.

    Post your actual makefile if you're still stuck.
    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.

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    270

    Lightbulb here

    Heres my makefile:
    Code:
    FILE=Image
    CFLAGS=-I. -I/usr/units/ep100/ass2.072/ `imlib2-config --cflags` -g
    $(FILE): $(FILE).o Image_lib.o
    	cc  $(FILE).o Image_lib.o -o $(FILE) `imlib2-config --libs` -L/usr/units/ep100/ass2.072/ -lep100 -g
    
    IMAGE=images/pa300570_small.jpg
    PARAM=
    run: $(FILE)
    	$(FILE) $(PARAM) $(IMAGE)
    
    # DO NOT DELETE
    The thing is i type make and it runs the program, i want to be able to also enter command line arguments like this:

    Code:
    a.out -i (image_directory)

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Your output file is whatever comes after -o in the cc line. In this case $FILE which is Image.

    So
    ./Image -i images/pa300570_small.jpg

    should run your application.

    Assuming of course that it actually builds correctly.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Aug 2007
    Posts
    270
    so i dont enter a.out?
    just:

    Code:
    $ ./Image -i images/pa300570_small.jpg
    ?

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    a.out is what the compiler calls the executable if you DON'T specify a name with -o.

    Since your makefile has "-o $FILE" in it, the name of your exectuable is "$FILE".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Aug 2007
    Posts
    270
    oh so there is no a.out in my makefile so cant enter command line arguments?

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Of course you can enter command line arguments. Your application is just not called a.out, but something else [which I don't think is a bad thing - calling everything a.out gets complicated after a while].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Aug 2007
    Posts
    270
    so how would i enter the arguments?

    $ make -i image_path
    ?

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    No, to run your image, you do "make run". the option and image that is operated on are defined in your makefile. (PARAM and IMAGE specify those, you may want to make PARAM=-i

    You could change how that works, but you then would have to specify the variables as part of the command-line to make.

    Something like this (assuming you remove IMAGE= and PARAM= in your current makefile):
    make IMAGE=blah.jpg PARAM=-i run

    I don't see why you want to do that tho'.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Registered User
    Join Date
    Aug 2007
    Posts
    270
    well i have to c files, one main line and one function one. i then have a library file.

    now my main line file a run with arguments in the CL. it then checks what you entered and goes to the other C file to the appropiate function.

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, that makes sense. And what is your question?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    Registered User
    Join Date
    Aug 2007
    Posts
    270
    same as above, how would i run it with CLA

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    If you want to run your executable, what I wrote earlier should work. Doesn't it?

    ./Image -i images/pa300570_small.jpg

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #15
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by taurus View Post
    Heres my makefile:
    This makefile contains no rules that actually build anything. So that answers the question of why you don't know what your executable is -- you don't have one.

    EDIT: No, I'm stupid and just can't read. Your executable is called "Image" Also, the makefile expects the source code to be in a file called Image.c. If your code has some other filename, it won't work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Establishing 'make clean' with GNU make
    By Jesdisciple in forum C Programming
    Replies: 9
    Last Post: 04-11-2009, 09:10 AM
  2. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 09:51 PM
  3. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  4. make all rule
    By duffy in forum C Programming
    Replies: 9
    Last Post: 09-11-2003, 01:05 PM
  5. Replies: 6
    Last Post: 04-20-2002, 06:35 PM