www.delorie.com/archives/browse.cgi | search |
From: | ryot AT bigfoot DOT com (George Ryot) |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Implicit make rules fail to link with std C++ library |
Message-ID: | <37897534.8132755@news.clara.net> |
X-Newsreader: | Forte Agent 1.5/32.452 |
X-No-Archive: | yes |
MIME-Version: | 1.0 |
Lines: | 48 |
Date: | Fri, 09 Jul 1999 22:20:20 GMT |
NNTP-Posting-Host: | 195.8.91.168 |
X-Complaints-To: | abuse AT clara DOT net |
X-Trace: | nnrp4.clara.net 931558820 195.8.91.168 (Fri, 09 Jul 1999 23:20:20 BST) |
NNTP-Posting-Date: | Fri, 09 Jul 1999 23:20:20 BST |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
I'm trying to set up a simple makefile to build C++ programs. The following line compiles and links without error: C:\C\test>gxx -O -Wall -Werror -o hello.exe hello.cpp But when I run make I get: C:\C\test>make gcc hello.cpp -o hello c:/djgpp/tmp\ccci43cl(.text+0x19):hello.cpp: undefined reference to `cout' c:/djgpp/tmp\ccci43cl(.text+0x1e):hello.cpp: undefined reference to `ostream::op erator<<(char const *)' make.exe: *** [hello] Error 1 The link phase seems to be failing to link with the standard C++ library. Also my CFLAGS are not being picked up. Here are the test files I am using: /*---- hello.cpp ----*/ #include <iostream.h> int main(void) { cout << "Hello World!\n"; return(0); } # ---- makefile ---- TARGETS = hello CFLAGS = -O -Wall -Werror all: $(TARGETS) clean: @for %x in ($(TARGETS)) do rm -f %x %x.o %x.exe Adding the line "CXX = gxx" solves the linking problem, and changing CFLAGS to CPPFLAGS solves the other but neither of these seem to me to be the best answer. Building C++ programs with make should be as straight forward as with C programs, did I miss something in the FAQ or could my installation be at fault. Any debugging of the files above or pointers to documentation gratefully received. -- george
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |