delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/02/00:29:55

Date: Sun, 1 Feb 1998 18:40:54 -0800 (PST)
Message-Id: <199802020240.SAA15953@adit.ap.net>
Mime-Version: 1.0
To: Rik Blok <blok AT physics DOT ubc DOT ca>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: making .cc files

At 01:48  2/1/1998 -0800, Rik Blok wrote:
>I'm trying to figure out how to use a makefile to create executables
>from both C and C++ sources.  My problem is that the default rule for
>the linker assumes that the file is just a C file and doesn't link in
>the C++ libraries.
So you have to use explicit rules.

>
>makefile
>--------
># executables 
>ccprog: ccprog.o common.o
Try this:

ccprog: ccprog.o common.o
        gxx $(LDFLAGS) -o $@ $^

I think you get the idea.
>justc:  justc.o common.o
>
># object files
>ccprog.o: ccprog.cc ccprog.h common.h
>justc.o:  justc.c justc.h common.h
>common.o: common.c common.h
>
># end of makefile
>
>How do I make the linker link in -lgpp -lstdxxx etc. just for the ccprog
>and not for justc?
>
>I think it works ok if I use something like
>	ccprog: ccprog.cc ccprog.h common.c common.h
>but that seems to me to be rather bad style and loses the advantage of
>conditional recompilation.
Yes it is. The solution I suggested is the one usually used.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019