undefined reference to `operator new(unsigned int)'

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?

-Eli

(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

Mmm... clang doesn't have support for "i686-elf" at the moment.
Patches welcome. (Please ask if you need guidance).

-Eli