Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c )make error& link problem: i386:x86-64 architecture of input file, incompatible with i386 output

Tags:

I have this output with error message when i type "make" in terminal!!

gcc test1.o dispatchQueue.o -o test1 -pthread /usr/bin/ld: i386:x86-64 architecture of input file `test1.o' is incompatible with i386     output /usr/bin/ld: final link failed: Invalid operation collect2: ld returned 1 exit status make: *** [test1] Error 1 

Is there anyone who can explain why and how to fix it? :(

I'm attaching makefile just in case

# Comment out the targets you don't want.  # Runs all of the tests. all: test1 test2 test3 test4 test5 testFor     ./test1     ./test2     ./test3     ./test4     ./test5     ./testFor  test1: test1.o dispatchQueue.o     gcc test1.o dispatchQueue.o -o test1 -pthread  test1.o: test1.c     gcc -c test1.c  test2: test2.o dispatchQueue.o     gcc test2.o dispatchQueue.o -o test2 -pthread  test2.o: test2.c     gcc -c test2.c  test3: test3.o dispatchQueue.o     gcc test3.o dispatchQueue.o -o test3 -pthread  test3.o: test3.c     gcc -c test3.c  test4: test4.o dispatchQueue.o     gcc test4.o dispatchQueue.o -o test4 -pthread  test4.o: test4.c     gcc -c test4.c  test5: test5.o dispatchQueue.o     gcc test5.o dispatchQueue.o -o test5 -pthread  test5.o: test5.c     gcc -c test5.c  testFor: testFor.o dispatchQueue.o     gcc testFor.o dispatchQueue.o -o testFor -pthread  testFor.o: testFor.c     gcc -c testFor.c  dispatchQueue.o: dispatchQueue.c dispatchQueue.h     gcc -c dispatchQueue.c 
like image 711
user890040 Avatar asked Aug 11 '11 13:08

user890040


People also ask

Is make 1 an error?

make error 1 just means the build failed. the content of the brackets is the make target name. The reason should be in the lines preceding the make error in the build console (or build log).

What is o C in Makefile?

The simple answer is that %.o is a target that matches any file ending in .o. "%.o: %. c" means that any file ending in .o depends on the same filename ending in . c to be present.

How do I ignore an error in Makefile?

To ignore errors in a recipe line, write a ' - ' at the beginning of the line's text (after the initial tab). The ' - ' is discarded before the line is passed to the shell for execution.

What is Gmake in Linux?

gmake (GNU make - called simply make on linux systems) is a tool to help you build a program from its source. For our trivial Zoo program its possible to completely build the Zoo.exe from scratch in a few seconds.


2 Answers

You probably have some old files (at least test1.o) compiled for i386-x64. You can remove these old files and run make again. If you can modify the Makefile try adding a line such as:

clean:     rm *.o test1 test2 test3 test4 test5 testFor 

Then when you run make clean it'll remove the old stuff, at which point you can run make again.

like image 102
Kenji Avatar answered Sep 21 '22 17:09

Kenji


I had similar problem. Problem for me was that object files were generated with i386 arichitecture and I was trying to link with x86_64 linker. I deleted object files generated them anew with x86_64 options and tried to linking again. It works now

like image 21
mopa Avatar answered Sep 19 '22 17:09

mopa