delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/01/17:31:45

From: Rik Blok <blok AT physics DOT ubc DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: making .cc files
Date: Sun, 01 Feb 1998 13:48:55 -0800
Organization: Lynx Internet
Lines: 34
Message-ID: <34D4EDC7.D2D24204@physics.ubc.ca>
NNTP-Posting-Host: lynx-173.lynx.bc.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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.

makefile
--------
# executables 
ccprog: ccprog.o common.o
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.


I hope this is clear.  Thanks for the help.
	Rik.
-- 
Rik Blok  <blok AT physics DOT ubc DOT ca>
Department of Physics and Astronomy,
University of British Columbia, Canada
http://www.physics.ubc.ca/~blok/

- Raw text -


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