Using cpp file

Hi,
I am new to SDL. Where do I make the changes in the makefile or
makefile.in etc so that I am able to compile a “.cpp” file. I tried changing
but it still searches for a “.c” file and throws error while compiling.

regards,
Paresh.

If you could show the errors it might help. In general however, make
will process C++ files with the ending of .cc (instead of .cpp)
it will use the command:

$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)

by default as described in the info files. You can always write an
explicit rule for the file using

My Simple makefile

CC = gcc
CXX = g++ # yes this is being anal

CFLAGS = sdl-config --cflags # let sdl do it for us
LDFLAGS = sdl-config --libs # and for libraries too

PROGIE = foo # not everything has to be standard
HEADERS = foo.h
SRCS = foo.cpp
OBJS := $(SRCS: %.cpp %.o) # ooh fancy a rewrite

foo.o : foo.cpp $(HEADERS)
$(CXX) -c foo.cpp $(CFLAGS)

foo : $(OBJS)
$(CXX) -o $(PROGIE) $(OBJS) $(LDFLAGS)

.SILENT: test # we can turn auto echo this way
test : foo
./foo # if you can’t run the file then it is busted

end of makefile

I would highly recommend actually reading the info pages for make, gcc,
etc. The above example should highlights just a few of the cool things
one can do with make. In general, you shouldn’t be editing a Makefile.in
though, as that is generated by automake from the Makefile.am. Once
again, I suggest reading the info pages. Automake is powerful, intimidating,
and fairly well documented. It works well with autoconf which generates
the configure scripts from configure.in (confusing I know).

All of this stuff is not really SDL related but general GNU tools stuff.
If you really need help, talk to me off the list and I’d be happy to help.

Dave Goehrig http://cthulhu-burger.comOn Tue, Oct 30, 2001 at 06:17:38PM +0530, paresh wrote:

I am new to SDL. Where do I make the changes in the makefile or

makefile.in etc so that I am able to compile a “.cpp” file. I tried changing
but it still searches for a “.c” file and throws error while compiling.

Hi,
Thank you Dave Goehrig, I modified the makefile that you send and now I
am able to compile my “.cpp” files.

regards,
Paresh.Date: Tue, 30 Oct 2001 02:25:03 -0600
From: dave@cthulhu-burger.com (Dave Goehrig)
To: sdl at libsdl.org
Subject: Re: [SDL] using cpp file
Reply-To: sdl at libsdl.org

On Tue, Oct 30, 2001 at 06:17:38PM +0530, paresh wrote:

I am new to SDL. Where do I make the changes in the makefile or

makefile.in etc so that I am able to compile a “.cpp” file. I tried
changing
but it still searches for a “.c” file and throws error while compiling.

If you could show the errors it might help. In general however, make
will process C++ files with the ending of .cc (instead of .cpp)
it will use the command:

$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)

by default as described in the info files. You can always write an
explicit rule for the file using

My Simple makefile

CC = gcc
CXX = g++ # yes this is being anal

CFLAGS = sdl-config --cflags # let sdl do it for us
LDFLAGS = sdl-config --libs # and for libraries too

PROGIE = foo # not everything has to be standard
HEADERS = foo.h
SRCS = foo.cpp
OBJS := $(SRCS: %.cpp %.o) # ooh fancy a rewrite

foo.o : foo.cpp $(HEADERS)
$(CXX) -c foo.cpp $(CFLAGS)

foo : $(OBJS)
$(CXX) -o $(PROGIE) $(OBJS) $(LDFLAGS)

.SILENT: test # we can turn auto echo this way
test : foo
./foo # if you can’t run the file then it is busted

end of makefile

I would highly recommend actually reading the info pages for make, gcc,
etc. The above example should highlights just a few of the cool things
one can do with make. In general, you shouldn’t be editing a Makefile.in
though, as that is generated by automake from the Makefile.am. Once
again, I suggest reading the info pages. Automake is powerful,
intimidating,
and fairly well documented. It works well with autoconf which generates
the configure scripts from configure.in (confusing I know).

All of this stuff is not really SDL related but general GNU tools stuff.
If you really need help, talk to me off the list and I’d be happy to help.

Dave Goehrig http://cthulhu-burger.com