【发布时间】:2013-05-20 09:10:34
【问题描述】:
简单的问题:
给定以下程序:
#include <stdio.h>
inline void addEmUp(int a, int b, int * result)
{
if (result) {
*result = a+b;
}
}
int main(int argc, const char * argv[])
{
int i;
addEmUp(1, 2, &i);
return 0;
}
我收到链接器错误...
Undefined symbols for architecture x86_64:
_addEmUp", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
好像不用编译。
它不应该是static,我不认为,根据我读过的内容:
Linker error inline function(因为这是在不同的对象中,并且处理2个定义而不是零)
这是一个相关链接,但它是 c++,我认为在 std C 中将代码放在标头中并不是一个好习惯:
inline function linker error
编译器信息:
cc --version
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
编译示例:
# cc main.c
Undefined symbols for architecture x86_64:
"_addEmUp", referenced from:
_main in main-sq3kr4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocatio
【问题讨论】:
-
你是用哪个命令编译的?
-
你用的是什么编译器?
-
它在 xcode 4.6.2 中发出叮当声
标签: c inline linker-errors