help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: makefile for generating exe from single cpp


From: Paul Smith
Subject: Re: makefile for generating exe from single cpp
Date: Fri, 17 Oct 2014 08:51:12 -0400

On Fri, 2014-10-17 at 07:46 +0100, Amit Chaudhuri wrote:
> my reading of the manual for GNU make (v3.82) was that a simple
> makefile consisting of:
> 
> main: main.o
> 
> in a project consisting of a single main.cpp file would invoke g++ and
> generate .o from .cpp and main by linking with g++.

That is true.

> This is not what I see and it comes as a surprise.
> 
> The first implicit rule picked up is to link main from main.o with cc
> rather than g++.

If you provide us the output of the make command we can be more helpful.
My suspicion is you have both a "main.c" and a "main.cpp" in your
directory.  Since you don't specify which source file should be used to
build the object file, make uses rule precedence and chooses to build
"main.c".

If you're saying that make is actually compiling 'main.cpp' into
'main.o' and it's using 'cc' as the compiler, I'd say that's not
possible unless there is something else going on that you haven't
described.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]