Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly error when compiling a C file under Linux

Tags:

c

assembly

Hi I am trying to compile simple C programs in my computer and I get the similar msgs from under the terminal [see images] when compiling, stating some sort of assembly error. I dont know if this is a computer memory/stack issue (although I have restarted my computer) or anything else, but what I know for sure is that I have been compiling C programs these past days in the same manner.

Code:

   #include <stdio.h>
   main(){
      printf("hello");
   }

Output:

/tmp/cconajAc.s: Assembler messages: /tmp/cconajAc.s:9: Error: suffix or operands invalid for `push'

Please tell me how to fix this!

EDITED: I have just changed from workstation from another computer lab room and it works alright with no assembly errors whatsoever. My guess would be an error in the development tools installed in those computers in the other lab room. I guess for now this works for me although it would be interesting to know the source of the problem that I had in the other computer.

like image 856
Ini Avatar asked Nov 04 '12 22:11

Ini


2 Answers

The error seems strange but try adding a return type to your main(): int main().

like image 160
SomeWittyUsername Avatar answered Sep 21 '22 15:09

SomeWittyUsername


Write in vi editor and save the file as "hello.c":

 #include <stdio.h>
 int main() {   printf("hello");   return 0; }

Check if you have the 32-bit glibc headers installed.
Try this in ubuntu to install:
# apt-get install gcc-multilib

Then try:
# gcc -m32 -o hello hello.c

# gcc Wa,--32 else

# gcc -m32 --32

like image 42
askmish Avatar answered Sep 18 '22 15:09

askmish