delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/09/20:52:30

From: varobert AT colba DOT net
Message-Id: <3.0.32.19990709205220.007a98c0@mail.colba.net>
X-Sender: varobert AT mail DOT colba DOT net
X-Mailer: Windows Eudora Pro Version 3.0 (32)
Date: Fri, 09 Jul 1999 20:52:27 -0400
To: djgpp AT delorie DOT com
Subject: Re: Implicit make rules fail to link with std C++ library
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

Try adding -lstdcxx or -lstdcx (on non long file name OS's) in CFLAGS.

At 10:20 PM 7/9/99 GMT, you wrote:
>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
>
>

- Raw text -


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