Undefined reference to operator new(未定义对 operator new 的引用)
问题描述
我正在尝试使用 cpputest 构建一个简单的单元测试可执行文件.我已经将 cpputest 框架构建到一个静态库中,现在正试图将它链接到一个可执行文件中.但是,由于相关代码,我被绑定到一个相当复杂的 Makefile 设置中.
I'm trying to build a simple unit test executable, using cpputest. I've built the cpputest framework into a static library, and am now trying to link that into an executable. However, I'm tied into a fairly complicated Makefile setup, because of the related code.
这是我的命令行:
/usr/bin/qcc -V4.2.4,gcc_ntoarmle_acpp-ne -lang-c++ -O2 -g -g -o Application/UnitTests/Tests/symbols/UnitTestExe -Wl,--start-group Application/UnitTests/Tests/../.objs/main.o Application/UnitTests/lib/libcpputest.a -Wl,--end-group -lm
我遇到了很多类似以下的错误:
I'm getting many errors like the following:
Application/UnitTests/lib/libcpputest.a(CommandLineTestRunner.o): In function `CommandLineTestRunner::parseArguments(TestPlugin*)':
Application/UnitTests/cpputest/src/CppUTest/.objs/../CommandLineTestRunner.cpp:114: undefined reference to `operator new(unsigned int, char const*, int)'
我不知道是什么原因造成的.我不是用 C++ 免费获得 operator new 吗?
I can't figure out what's causing this. Don't I get operator new for free with C++?
推荐答案
您的问题中可以处理的信息很少,但看起来有些代码使用了某种形式的 placement new,而那个特殊的 operator new
是 declared (编译器找到它并使用它编译代码),链接器找不到它的 定义.
There's very little information in your question to work from, but it looks like some code uses some form of placement new, and while that special operator new
is declared (the compiler finds it and compiles the code using it), the linker can't find its definition.
(由于我的这个旧答案似乎仍然受到关注:有关声明与定义.)
这篇关于未定义对 operator new 的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:未定义对 operator new 的引用


基础教程推荐
- 我有静态或动态 boost 库吗? 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何检查GTK+3.0中的小部件类型? 2022-11-30