"ld: 0711-224 WARNING: Duplicate symbol"
------解决方案--------------------------------------------------------
警告没关系的
------解决方案--------------------------------------------------------
6.1 的 ld 确实会由这种警告,建议查一下代码。
多半是在.h文件里定义变量引起的
- C/C++ code
$ cat foo.h foo.c main.c/** * @file foo.h * @brief */int foo = 1;/** * @file foo.c * @brief */#include "foo.h"/** * @file main.c * @brief */#include <stdio.h>#include "foo.h"int main(int argc, char *argv[]){ printf("%d\n", foo); return 0;}$ xlc -o foo foo.c main.cfoo.c:main.c:ld: 0711-224 WARNING: Duplicate symbol: foold: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.$ cat foo.h foo.c main.c /** * @file foo.h * @brief */extern int foo;/** * @file foo.c * @brief */#include "foo.h"int foo = 1;/** * @file main.c * @brief */#include <stdio.h>#include "foo.h"int main(int argc, char *argv[]){ printf("%d\n", foo); return 0;}$ xlc -o foo foo.c main.cfoo.c:main.c:$