g++ output: file not recognized: File format not recognized

This is wrong:

 g++ -c src/CNumber.cpp src/CNumber.h -o src/CNumber.o

You shouldn’t “compile” .h files. Doing so will create precompiled header files, which are not used to create an executable. The above should simply be

 g++ -c src/CNumber.cpp -o src/CNumber.o

Similar for compiling the other .cpp files

Leave a Comment