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 的引用


基础教程推荐
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01