Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Tip] Makefiles
Index -> Programming, C++ -> C++ Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Wed May 31, 2006 11:12 am   Post subject: [Tip] Makefiles

Learn to use makefiles.

This means practicing. A lot.

When you want to compile your "hello world" program... write a makefile.

You'll be glad you did.
Sponsor
Sponsor
Sponsor
sponsor
md




PostPosted: Wed May 31, 2006 11:24 am   Post subject: (No subject)

A simplish makefile for a "Hello, world" app. The code is all in the file main.cpp. It could be simpler yes... but this gives an idea of how things can be done without making it horribly complicated (see http://files.nxor.org/makefile).

code:
#
#   "Hello, world" makefile
#   
#

########################################
# compiler & linker
#
CC = g++
LN = g++


########################################
# build options
#
CXX_FLAGS = -g -Wall
LN_FLAGS =
LN_LIBS =

########################################
# rules

#default rule
all: hello

# main
main.o : main.cpp
        ${CC} ${CXX_FLAGS} main.cpp -o main.o

# the app       
hello : main.o
        ${LN} ${LN_FLAGS} ${LN_LIBS} main.o -o hello
       
# clean
.PHONY : clean
clean :
        touch main.o
        touch hello
        rm main.o hello
Display posts from previous:   
   Index -> Programming, C++ -> C++ Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: