"fstream: No such file or directory" but it is present

Axel Freyn axel-freyn@gmx.de
Wed May 25 22:18:00 GMT 2011


On Wed, May 25, 2011 at 11:46:08AM -0700, Mahmood Naderan wrote:
> >Either rename it or compile with g++, see the manual
>  
> The make file is generated with a configure script. If I rename to .C I get this error:
>  
> make[2]: *** No rule to make target `bpred.c', needed by `bpred.o'.  Stop.
> 
> On the other hand, I don't know how to tell makefile to compile *only* bpred.c with g++.

you can either adding a rule which states "bpred.o is generated from
"bpred.C", something like

bpred.o: bpred.C
  $(CXX) $(CXXFLAGS) -o $@ $^

but maybe you need more flags, files, ...?

Or you can change the makefile to use g++ instead of gcc:
bpred.o: bpred.c
  $(CXX) $(CXXFLAGS) -o $@ $^

"g++" automatically compiles its .c-files as being C++.

Or you can tell gcc to use C++:

bpred.o: bpred.c
  $(CC) $(CFLAGS) -x c++ -o $@ $^

(the parameter "-x c++" tells gcc to compile a C++-file.

Axel



More information about the Gcc-help mailing list