Makefile errors

This is a discussion on Makefile errors within the C Programming forums, part of the General Programming Boards category; I'm trying to make a basic GTK program that just makes a button that says "Hello, World!" It compiles when ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    4

    Makefile errors

    I'm trying to make a basic GTK program that just makes a button that says "Hello, World!" It compiles when I type "cc -L../lib/ window.o -o test `pkg-config --cflags --libs gtk+-2.0`" but when I attempted to make a Makefile, it began to do something funky. I know the makefile works, it's a copy of another working program of mine, just changed the sources.

    Code:
    SRC = window.c
    OBJ = $(SRC:.c=.o)
    RM = rm -f
    TESTC = $(SRC)
    TESTO = $(TESTC:.c=.o)
    TESTE = test
    LPATH = ../lib/
    LIBS = -lmy
    GTK = `pkg-config --cflags --libs gtk+-2.0`
    all: $(TESTO)
    	cc -L$(LPATH) $(TESTO) $(LIBS) -o $(TESTE) $(GTK)
    clean:
    	-$(RM) *.o
    	-$(RM) *~
    	-$(RM) \#*
    	-$(RM) *.core
    fclean: clean
    	-$(RM) $(NAME)
    lol:
    	wellwtfaasdasdasd
    When I type make, I get
    Code:
    cc (tab space) -c -o window.o window.c
    I know that the "lol" part of the Makefile (make lol) attempts to execute "wellwtfaasdasdasd." I have no idea where the makefile is getting -c or window.c, I never coded that.

    Any help is much appreciated.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Akalic View Post
    I'm trying to make a basic GTK program that just makes a button that says "Hello, World!"

    I have no idea where the makefile is getting -c or window.c, I never coded that.
    If that's where you are at, my advice is you stop worrying about makefiles at all for now. They serve absolutely no purpose here except as a pointless complication.

    Just use the compiler. If you do not like typing switches out all the time, here's a line from my ~/.bashrc:
    Code:
    export CGTK=`pkg-config --cflags --libs gtk+-2.0`
    Now to compile a gtk app, you just use:

    gcc helloworld_gtk.c $CGTK

    Presto. No makefile required.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Quote Originally Posted by Akalic View Post
    Code:
    SRC = window.c
    I have no idea where the makefile is getting -c or window.c, I never coded that.
    make attempts to compile all .c files to .o files (this is your rule as you put it above). But, I don't get your above statement considering the above code block.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile help please
    By TriKri in forum C++ Programming
    Replies: 3
    Last Post: 09-24-2009, 12:36 AM
  2. Replies: 2
    Last Post: 08-11-2009, 06:45 AM
  3. Need help with makefile
    By New_Programmer in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2009, 04:55 PM
  4. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 10:50 PM
  5. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM

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