hi...
I'm new to the cppunit. I'm using cppunit framework for my c++ program. I want to build my program using a makefile. can anyone help me to compile my program using a make file.
wijitha

I don't know anything about the CppUnit framework, but you should be able to compile just like any other.

A makefile has a pretty simple layout. I'll assume that you are compiling a program named "quux" from the source files "quux.cpp" and "baz.cpp" and linking the library "bar". A makefile for that using GCC might look something like this:

quux: quux.o baz.o
	g++ -o quux quux.o baz.o -lbar

quux.o: quux.cpp
	g++ -c quux.cpp

baz.o: baz.cpp
	g++ -c baz.cpp

clean:
	del quux.o
	del baz.o

The default target is "quux", the name of your exe. It requires "quux.o" and "baz.o", which also have rules. You can clean things up by targeting "clean" (this assumes Windows Cmd.exe --you'll have to adjust to the appropriate commands for your platform).

Presumably libbar.a is in GCC's ~\lib directory.

A make target starts at the beginning of the line, followed by a colon (:), followed by a list of required sources. The following line(s) must begin with a TAB, then the commands necessary to make the target.

So, to make "quux" you can type either make or make quux to compile it.

To just make "baz.o" (instead of the whole project) type make baz.o To clean up any mess from compiling (before archiving or just to make sure for a clean build): make clean This example is about as simple as it gets. If you want to play with a little more sophistication or if you just want to learn more about makefiles, start at WikiPedia.

Hope this helps.

This article has been dead for over six months. Start a new discussion instead.