I'm having some difficulty with the C++ "new" operator. I'm using an RZ/A1L (custom PCB), developing in e2 Studio on Windows 8, and "debugging" my compiled programs under "HardwareDebug" using a Segger J-link. I create a new C++ project in e2 Studio, and select all the appropriate options, including selecting the KPIT GNUARM-NONE-EABI toolchain. The default C++ project it creates for me compiles and runs fine. However, as soon as I use the "new" operator to create an instance of any class at runtime (even the most bare-bones class with nothing in it, or with just a constructor), I run into problems. The problems differ depending on the library settings in e2 Studio. If "library type" is set to "project-built", then the mere existence of the "new" operator in my code causes a number of linker errors like this one: E:\Renesas e2 workspace\cpp_test_3\Release\libcpp_test_3.a(redboot-syscalls.o): In function `_close': redboot-syscalls.c:(.text._close+0x0): multiple definition of `_close' E:\Renesas e2 workspace\cpp_test_3\Release\libcpp_test_3.a(linux-syscalls0.o):(.text+0x28): first defined here ... and several more, relating to functions (which it seems are being included automatically in the library) called _exit, _stat, _fstat, _getpid, _gettimeofday, and several more. If, however, "library type" is set to "pre-built", then there are no linker errors and the code begins executing, but the code freezes while running as soon as it tries to execute the "new" operator. I.e. I'll be debugging the project from e2 Studio, stepping through the lines of code, and as soon as it tries to execute the line of code containing "new", it never arrives at any further breakpoints, and e2 Studio just reports that the thread is "running". Changing the "select library" setting from "newlib" to "optimized" doesn't help either - I then get a number of different compile-time errors that mostly look like this: vterminate.cc:(.text._ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x78): undefined reference to `fwrite' Any clues? I'm developing something that uses a lot of dynamic memory allocation, and relies heavily on the "new" operator. I'm guessing the problem is related to the included libraries, but troubleshooting those is a bit beyond me. Thanks!
↧