[cfe-dev] undefined reference to `operator new(unsigned int)'
Eli Friedman
eli.friedman at gmail.com
Fri Apr 8 16:24:19 PDT 2011
On Fri, Apr 8, 2011 at 3:33 PM, Klaus T. <nightos at gmail.com> wrote:
> Here you are.
>
> 2011/4/9 Eli Friedman <eli.friedman at gmail.com>
>>
>> On Fri, Apr 8, 2011 at 2:33 PM, Klaus T. <nightos at gmail.com> wrote:
>> > Hi,
>> > Recently I started moving from GCC to Clang to compile my own OS. I am
>> > using
>> > Windows and to compile my source files I use "clang++ -ccc-host-triple
>> > i686-pc-linux" and link them with i686-elf-ld. However, when I use the
>> > "new
>> > operator" (like int*p = new int; ...) I get "undefined reference to
>> > `operator new(unsigned int)'" while linking and yes, I use -lstdc++.
>> > When I
>> > compile my source files with GCC I don't have this problem. Any ideas?
>>
>> Can you attach the .s output from GCC and clang?
(For future reference, please use reply-to-all so cfe-dev ends up on
the CC list.)
It looks like the gcc-generated code is calling _Znwm, while the
clang-generated code is calling _Znwj, which means clang is coming up
with the "wrong" definition of size_t. So basically, the issue is
that "-ccc-host-triple i686-pc-linux" doesn't accurately reflect your
target. What's the output of gcc -v?
-Eli
More information about the cfe-dev
mailing list