Undefined Reference
释义 Definition
“undefined reference” 指链接阶段常见的报错信息,意思是:程序中引用了某个符号(如函数、变量),但链接器在目标文件或库中找不到它的实际定义。常见于 C/C++ 等编译型语言的构建过程中。(有时也会在其他语言的原生扩展/链接步骤中出现类似报错。)
发音 Pronunciation (IPA)
/ʌn.dɪˈfaɪnd ˈrɛf.ər.əns/
词源 Etymology
- undefined 来自前缀 *un-*(“不、非”)+ define(“定义”),表示“未被定义的”
- reference 源自拉丁语 referre(“带回、提及、指向”),在编程语境中常指“引用/指向某个符号”
合起来在编译工具链语境里固定指“引用了但未找到定义”的链接错误提示。
例句 Examples
I got an undefined reference when I tried to build the program.
我在编译构建这个程序时遇到了“undefined reference”的错误。
The linker reported an undefined reference to sqrt because the math library wasn’t linked (e.g., missing -lm).
链接器报出对 sqrt 的“undefined reference”,因为没有把数学库链接进去(例如缺少 -lm)。
相关词 Related Words
文学与著名作品用例 Notable Works
- The C Programming Language(Kernighan & Ritchie):在讨论编译/链接与外部函数时,常涉及“声明与定义不匹配会导致链接错误”的典型情境。
- Advanced Programming in the UNIX Environment(W. Richard Stevens):涉及 Unix 构建、库与链接器行为的章节中,经常出现与链接错误(包括“undefined reference”)相关的说明。
- Linkers and Loaders(John R. Levine):系统讲解链接器与符号解析,“undefined reference”所代表的问题属于其核心主题之一。
- GNU Binutils / GCC 文档(如 *Using the GNU Linker (ld)*):直接记录并解释链接器诊断信息,包含“undefined reference”这类报错文本与成因。