Causes and solutions of nm test o file format not recognized

               

        Recently, I wrote makefile,   Encountered the error nm: test. O: file format not recognized. Let’s see:

        test.h:

void output();

        test.cpp:

#include <stdio.h>#include "test.h"void output(){ printf("c is good\n");}

          compile:

xxxxxx:~/mkfile> g++ -c test.cpp test.h -o test.oxxxxxx:~/mkfile> nm test.onm: test.o: File format not recognizedxxxxxx:~/mkfile>

          Strange, isn’t it?The reason is that there are too many test. H files. There is no need at all. The compiler will find them automatically as long as you specify the directory.   If you change the order of test. H and test. CPP, you will be prompted:

xxxxxx:~/mkfile> g++ -c test.h test.cpp -o test.og++: cannot specify -o with -c or -S with multiple filesxxxxxx:~/mkfile> 

          We have already said that.

          It seems that when there is – O, you can go to – C to specify multiple files, which is a huge pit.

           

Let’s share my teacher Dashen’s AI course. Zero base! Easy to understand! Funny! And yellow jokes! Hope you can join our AI team! https://blog.csdn.net/jiangjunshow


Read More: