2

I state that I am a beginner.I wrote a small program, max.c

int max(int a,int b){
  if(a > b) return a;
  return b;
}

I compiled with:

gcc -m32 -S max.c

to generate the IA32 assembly program. Then, I created a small main trial to test the operation of the program, main-max.c

#include <stdio.h>

int max(int a,int b);
int main(){
  printf("%d\n",max(3,-5));
  printf("%d\n",max(3,5));
  return 0;
}

I compiled and passing the assembly code of the program previously compiled:

gcc -m32 main-max.c max.s -o max

gives me the following error:

/usr/bin/ld: saltato /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a incompatible durante la ricerca di 
/usr/bin/ld: impossibile trovare -lgcc
/usr/bin/ld: saltato /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so incompatible durante la ricerca 
/usr/bin/ld: impossibile trovare -lgcc_s
collect2: error: ld returned 1 exit status

you know help me?

myaut
  • 11,174
  • 2
  • 30
  • 62
Balboa
  • 59
  • 6
  • 1
    Please write the error messages in English. – Michael Apr 30 '15 at 08:38
  • 2
    Please do `export LANG=C` before running compiler so we can read your errors in English – myaut Apr 30 '15 at 08:38
  • 1
    No idea if this will work, but try changing the order, that is: `gcc -m32 max.s main-max.c -o max` – Beko Apr 30 '15 at 08:40
  • 1
    See http://stackoverflow.com/questions/21103826/m32-option-doesnt-work-with-gcc-but-works-with-g – Michael Apr 30 '15 at 08:40
  • 2
    Are you on a 64-bit system? Have you installed the multilib packages for GCC? – Some programmer dude Apr 30 '15 at 08:41
  • This is the error: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc /usr/bin/ld: cannot find -lgcc /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s /usr/bin/ld: cannot find -lgcc_s – Balboa Apr 30 '15 at 08:50
  • 1
    The linker doesn't find valid libraries: libgcc.a and libgcc_s.so – Sir Jo Black Apr 30 '15 at 09:21
  • 2
    See the answer of the user @Silverstorm in the question http://stackoverflow.com/questions/23498237/compile-program-for-32bit-on-64bit-linux-os-causes-fatal-error – Sir Jo Black Apr 30 '15 at 09:54
  • I installed the libraries, as you suggested, but the error remains @SergioFormiggini – Balboa Apr 30 '15 at 10:13
  • 1
    @Balboa. Try to see if the libraries the linker searches are in the correct path. You may do this at the system pront: cd /usr/lib/gcc/x86_64-linux-gnu then, at the system prompt: find . -iname " * gcc * " (without the spaces insides the ""). You should see something like this: ./4.8/libgcc.a ./4.8/libgcc_eh.a ./4.8/include/stdint-gcc.h ./4.8/x32/libgcc.a ./4.8/x32/libgcc_eh.a ./4.8/x32/libgcc_s.so ./4.8/32/libgcc.a ./4.8/32/libgcc_eh.a ./4.8/32/libgcc_s.so ./4.8/libgcc_s.so ./4.8/libgcc_s_x32.so ./4.8/libgcc_s_32.so – Sir Jo Black Apr 30 '15 at 10:42
  • I checked all the directories that you wrote: there are all except ./4.8/32/libgcc.a ./4.8/32/libgcc_eh.a ./4.8/32/libgcc_s.so ./4.8/libgcc_s_32.so @SergioFormiggini – Balboa Apr 30 '15 at 12:13
  • 1
    @Balboa. The compiler is saying to you that the libraries are not in the format it expects. I think should be a good idea that you uninstall and re-install such a libraries. (On my Linux 64 bits (Ubuntu 14.10) the code is compiled without problems) – Sir Jo Black Apr 30 '15 at 12:23
  • could you show me how to do?My problem could not be because I'm working on virtual machine? @SergioFormiggini – Balboa Apr 30 '15 at 12:39
  • i solved! I installed the missing parts have been mentioned previously and now compile! Thank you very much for your support! @SergioFormiggini – Balboa Apr 30 '15 at 12:52

0 Answers0