Mail Archives: djgpp/1999/07/09/20:52:30
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 -