nm: test.o: File format not recognized的原因和解决方案

来源:互联网 发布:算法的乐趣代码 编辑:程序博客网 时间:2024/05/20 23:36

        最近写makefile,  碰到了nm: test.o: File format not recognized这个错误, 一起看看:

        test.h:

void output();
        test.cpp:

#include <stdio.h>#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指定多个文件, 那就是天大的坑。






阅读全文
1 0
原创粉丝点击