本文共 563 字,大约阅读时间需要 1 分钟。
最近写makefile, 碰到了nm: test.o: File format not recognized这个错误, 一起看看:
test.h:
void output();test.cpp:
#include编译:#include "test.h"void output(){ printf("c is good\n");}
xxxxxx:~/mkfile> g++ -c test.cpp test.h -o test.oxxxxxx:~/mkfile> nm test.onm: test.o: File format not recognizedxxxxxx:~/mkfile>奇怪了吧? 原因是多了test.h文件, 根本没必要啊, 编译器会自动去找的, 只要你指定了目录即可。 如果把test.h和test.cpp的顺序调换, 则提示:
xxxxxx:~/mkfile> g++ -c test.h test.cpp -o test.og++: cannot specify -o with -c or -S with multiple filesxxxxxx:~/mkfile>这一点, 我们在前面已经说过了。
看来, 有-o的时候, 你再去搞-c指定多个文件, 那就是天大的坑。
转载地址:http://gnwti.baihongyu.com/