gcc does not know about "new" and "delete"

Joel W. Gannett jgannett@research.telcordia.com
Fri Sep 21 18:24:00 GMT 2007


I've checked but was unable to find any FAQs on this subject, as 
keywords such as "new" and "delete" apparently created too many hits.

Why doesn't my cygwin gcc know about the standard C++ functions "new" 
and "delete"?  Here is an ultra-simple program (newtest.cpp) that won't 
compile for me under cygwin:

// program begin

#include <stdio.h>

int
main()
{
        int *i;
       
        i = new int;
        *i = 15;
        printf ( "hello, world: %d\n", *i );
        delete i;
        return 0;
}

// program end

This is what happens when I try to compile this program under cygwin on 
my Windows XP machine:

% gcc newtest.cpp
/tmp/ccReoXoA.o:newtest.cpp:(.text+0x32): undefined reference to 
`operator new(unsigned int)'
/tmp/ccReoXoA.o:newtest.cpp:(.text+0x5e): undefined reference to 
`operator delete(void*)'
collect2: ld returned 1 exit status

Also, I get essentially the same compilation failure messages when I try 
to compile this under cygwin on my Windows 2000 machine.

When I compile this simple program using gcc on a Sun Unix workstation, 
it compiles fine, with no messages, and runs fine as well.

Any help on this problem would be appreciated.  I have attached the 
cygcheck.out file for my Windows XP machine.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20070921/08ef7928/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list