I'm running Ubuntu 12.10 (64-bit), with Linux kernel 3.5.0-51-generic, on an AMD Athlon(tm) 64 X2 Dual Core Processor 5200+ ×2. I have GNU Fortran (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2.
I'm trying to compile some code into a 32-bit executable. I've checked that all the needed libraries are installed on my system (I ran ldd on a program previously compiled on a 32-bit computer, and downloaded the missing packages). I tried running $ gfortran foo.f -m32 -L/lib/i386-linux-gnu, but I get the following errors:
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgfortran.so when searching for -lgfortran
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgfortran.a when searching for -lgfortran
/usr/bin/ld: cannot find -lgfortran
/usr/bin/ld: cannot find -lm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/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.7/libquadmath.so when searching for -lquadmath
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libquadmath.a when searching for -lquadmath
/usr/bin/ld: cannot find -lquadmath
/usr/bin/ld: cannot find -lm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: returned 1 exit status
I checked the /usr/lib/gcc/i686-linux-gnu/4.7 and /usr/lib/gcc/i686-linux-gnu/4.7.2 directories, and they are both empty.
Can you please help me solve this problem? I did my research but this was as far as I could get.
Thank you in advance!
Mostly compiler(gcc or clang) of C and C++, nowadays come with default 64-bit version.
To check this, we have to type this command. gcc –v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu ........... ........... ...........
The Windows Fortran compiler supports a full range of project targets including command-line programs, GUI based applications, and Window's DLLs.
-m32 is there to compile 32 bits objects on a compiler configured to compile 64 bits objects by default.
The 64-bit libraries /usr/lib/gcc/x86_64-linux-gnu/...
don't apply to your 32-bit compile. You need to install the multilib compiler packages (see https://help.ubuntu.com/community/InstallingCompilers). For example:
sudo apt-get install gfortran-multilib
Now gfortran -m32 foo.f
should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With