compile question

This is a discussion on compile question within the Linux Programming forums, part of the Platform Specific Boards category; hi, i have just started to learn c, here is my problem (its not really a problem) when i write ...

  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    1

    Question compile question

    hi, i have just started to learn c, here is my problem (its not really a problem) when i write my code in gedit save the file as hello.c for instance i then go to terminal and type cc hello.c this works but i get a_out (again not an issue) so i type cc -o hello hello.c now i get the desired hello executable so my question is this,

    can i add an alias to my terminal session to make cc hello.c preform the same as cc -o hello hello.c ?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    bash(1): GNU Bourne-Again SHell - Linux man page
    Just search for "alias" and do a bit of reading.
    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.

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    847
    If you create Makefile in the same directory,
    Code:
    CC      := gcc
    CFLAGS  := -W -Wall -O2
    LD      := $(CC)
    LDFLAGS :=
    PROGS   := hello
    
    .PHONY: all clean run
    
    all: clean run
    
    clean:
    	rm -f $(PROGS)
    
    %: %.c
    	$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
    
    run: hello
    	@echo
    	@echo Running ./hello:
    	@echo
    	@./hello
    you only need to type make to compile and run your program. Just note that when you create the above file, the indentation must be a TAB character, not spaces.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compile error question
    By joey2264 in forum C++ Programming
    Replies: 3
    Last Post: 09-20-2010, 06:57 PM
  2. Another mock question that doesnt compile!
    By spadez in forum C Programming
    Replies: 12
    Last Post: 04-16-2009, 12:00 PM
  3. Compile question?
    By tomy in forum C++ Programming
    Replies: 6
    Last Post: 04-11-2008, 05:33 AM
  4. Compile Question
    By siavoshkc in forum Windows Programming
    Replies: 11
    Last Post: 03-13-2006, 09:50 AM
  5. Conditional Compile Question
    By nobbyv in forum C Programming
    Replies: 1
    Last Post: 12-05-2005, 09:19 AM

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