Getting error while linking with g++

Getting error while linking with g++

I try to compile and link my application in 2 steps :


g++ -c -o file1.o general_header.h
g++ -c -o file2.o general_header.h
g++ -c -o file3.o general_header.h


g++ -o myApp file1.o file2.o file3.o

I'm getting a link error as following:

file1.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status

Am i doing something wrong ?


How to send a EML file as email using python script to list of emails one at a time?


How to retrieve value from etc/sysconfig in Python
No need to include header files in your input files list. Displaying an image from the tmp directory g++ -c -o file1.o How do they read clusters/cylinders/sectors from the disk?
Use OpenBSD's malloc, realloc and free in my programStrange results while measuring delta time on Linux


Java OutOfMemoryError due to Linux RAM disk cache not freed
You should not be mentioning your header file on the command line - you don't want to compile it directly, although only as it is included in your source files. Spring ResourceServlet throws too many open files exception in jetty and tomcat under linuxalso, I would let the compiler name the object files, as it's too easy to make a typo when doing this explicitly. So your compilation commands should look like:.
g++ -c  
and you must then also say:.
g++ -c 

90 out of 100 based on 35 user ratings 550 reviews