Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29487 Discussions

problem linking 32bit ifort mkl on 64bit ubuntu

Demian_De_Feo
Beginner
2,485 Views
Can anyone help please???? I am trying to produce 32bit fortran binaries on a 64 bit ubuntu but problems seem to occur whenever I link to the mkl libraries . I used to use 64bit CENTOS for the same purpose and never had problems when linking with the following flags -convert big_endian -L/usr/lib -lblas -llapack . On ubuntu 6.10 I get the following errors :
ld: skipping incompatible /usr/lib/libm.so when searching for -lm
ld: skipping incompatible /usr/lib/libm.a when searching for -lm
ld: skipping incompatible /usr/lib/libm.so when searching for -lm
ld: skipping incompatible /usr/lib/libm.a when searching for -lm
ld: skipping incompatible /usr/lib/libm.so when searching for -lm
ld: skipping incompatible /usr/lib/libm.a when searching for -lm
ld: cannot find -lm

I have also tried -convert big_endian -L/opt/intel/mkl/10.1.1.019/lib -lmkl_blas -lmkl_lapack which I believe is the correct way as this would automatically link to the intel mkl libs but the error is very similar:
ld: skipping incompatible /usr/lib/libm.so when searching for -lm
ld: skipping incompatible /usr/lib/libm.a when searching for -lm
ld: skipping incompatible /usr/lib/libm.so when searching for -lm
ld: skipping incompatible /usr/lib/libm.a when searching for -lm
ld: cannot find -lm

I have tried many different ways, different compiler versions but to no avail.. Can anyone please please help??
Thank you
0 Kudos
9 Replies
Kevin_D_Intel
Employee
2,485 Views

The error suggests the linker search found /usr/lib/libm.so, which is the 32-bit version, but something else being linked in (presumably MKL) has been linked against and wants the 64-bit version of libm. Your -L path to MKL is not specific to the 32-bit versions so that may be the issue.

What happens when using a 32-bit specific path to MKL of: -L/opt/intel/mkl/10.1.1.019/lib/32
0 Kudos
Demian_De_Feo
Beginner
2,485 Views

The error suggests the linker search found /usr/lib/libm.so, which is the 32-bit version, but something else being linked in (presumably MKL) has been linked against and wants the 64-bit version of libm. Your -L path to MKL is not specific to the 32-bit versions so that may be the issue.

What happens when using a 32-bit specific path to MKL of: -L/opt/intel/mkl/10.1.1.019/lib/32

Hello Kevin and thank you for your quick reply. Unfortunately the 32 bit specific path -L/opt/intel/mkl/10.1.1.019/lib/32 gives the same error:
ld: skipping incompatible /usr/lib/libm.so when searching for -lm
ld: skipping incompatible /usr/lib/libm.a when searching for -lm
ld: skipping incompatible /usr/lib/libm.so when searching for -lm
ld: skipping incompatible /usr/lib/libm.a when searching for -lm
ld: cannot find -lm
I am using build 21( 10.1.1.021) ifort compiler but build 19 (10.1.1.019) libs. Could that be a problem? Thanks
0 Kudos
Kevin_D_Intel
Employee
2,485 Views

I don't expect the ifort/MKL versions used is the issue. We need to determine what is calling for the 64-bit version of libm.

If you are driving the link via ifort, can you add -# and then capture the output into a reply. If you are driving the link from ld, can you provide the complete link line.
0 Kudos
Demian_De_Feo
Beginner
2,485 Views

I don't expect the ifort/MKL versions used is the issue. We need to determine what is calling for the 64-bit version of libm.

If you are driving the link via ifort, can you add -# and then capture the output into a reply. If you are driving the link from ld, can you provide the complete link line.
I apologise but my Linux is not too good, but if I understood correctly the reply I seem to get is:
ifort: command line warning #10156: ignoring option '-s'; no argument required

also if this is any help, I also seem to produce wrong binaries in 64 bit as well! If I use compiler (fce) for 64bit with flags -convert big_endian -L/opt/intel/mkl/10.1.1.019/lib/64 -lmkl_blas -lmkl_lapack the error is:
ld: skipping incompatible /opt/intel/mkl/10.1.1.019/lib/64/libmkl_lapack.so when searching for -lmkl_lapack
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a(_DftiCreateDescriptorDM1_fortran_lp64.o): warning: sh_link not set for section `.IA_64.unwind'
ld: skipping incompatible /opt/intel/mkl/10.1.1.019/lib/64/libmkl_intel_lp64.a when searching for libmkl_intel_lp64.a
ld: cannot find libmkl_intel_lp64.a

While using fce with -L/usr/lib64 -lblas -llapack seems to compile and link ok and produce an executable but unfortunately this gives the incorrect result.. Thanks

0 Kudos
TimP
Honored Contributor III
2,485 Views
In order to build 32-bit mode on x86_64, you must have installed full support for g++ -m32. You must set the -m32 option for gnu compilers, and also set the 32-bit paths for all Intel compilers and libraries (fce or ia32 versions of ifort). Your errors indicate that your library paths and your compiler don't agree on 32- vs 64-bit choice.
As 64-bit Ubuntu uses a scheme for placement of 32- and 64-bit gnu libraries which is different from all other distros, except (hopefully) Debian, there could be problems in that aspect of setup. g++ -m32 -print-search-dirs would show the paths where those libraries must be installed; it would have to be a 32-bit g++ which is built specifically for the peculiar Ubuntu directory setup.
0 Kudos
Kevin_D_Intel
Employee
2,485 Views

Tim is right. You have a mix of mismatched components at play and may not have the appropriate g++ 32-bit environment installed. If you did not install the 32-bit version of ifort either, then you may need to do that too.

First, fce implies you are using the ifort Intel 64 compiler that will *not* produce 32-bit code. To produce a 32-bit executable you must use the 32-bit ifort that resides under the fc sub-directory. That requires you source the appropriate ifortvars.sh (or ifortvars.csh) under a path similar to: /opt/intel/fc/10.1.021

Next, the path -L/opt/intel/mkl/10.1.1.019/lib/64 is for the Itanium processor (also 64-bit but not for use on Intel 64 and what you want). While they are not of interest to you, the MKL libraries under the em64t specific MKL sub-directory are for use on Intel 64 when producing a 64-bit capable executable to run on x86_64.

If you are trying to produce a 32-bit executable then you need to:

1.Ensure you installed the appropriate g++ Tim mentions (use: g++ -m32 -print-search-dirs)
2. Compile using the 32-bit ifort (if you source the 32-bit ifortvars.sh/ifortvars.csh you will be fine). You can verify which ifort is used with the command: which ifort
3. Link with the 32-bit MKL libraries using the 32 specific MKL path I mentioned earlier

Just FYI. What I was asking for was to add -# to the ifort command, something like:

ifort -# -o hello_exe hello.f90
0 Kudos
Demian_De_Feo
Beginner
2,485 Views

Tim is right. You have a mix of mismatched components at play and may not have the appropriate g++ 32-bit environment installed. If you did not install the 32-bit version of ifort either, then you may need to do that too.

First, fce implies you are using the ifort Intel 64 compiler that will *not* produce 32-bit code. To produce a 32-bit executable you must use the 32-bit ifort that resides under the fc sub-directory. That requires you source the appropriate ifortvars.sh (or ifortvars.csh) under a path similar to: /opt/intel/fc/10.1.021

Next, the path -L/opt/intel/mkl/10.1.1.019/lib/64 is for the Itanium processor (also 64-bit but not for use on Intel 64 and what you want). While they are not of interest to you, the MKL libraries under the em64t specific MKL sub-directory are for use on Intel 64 when producing a 64-bit capable executable to run on x86_64.

If you are trying to produce a 32-bit executable then you need to:

1.Ensure you installed the appropriate g++ Tim mentions (use: g++ -m32 -print-search-dirs)
2. Compile using the 32-bit ifort (if you source the 32-bit ifortvars.sh/ifortvars.csh you will be fine). You can verify which ifort is used with the command: which ifort
3. Link with the 32-bit MKL libraries using the 32 specific MKL path I mentioned earlier

Just FYI. What I was asking for was to add -# to the ifort command, something like:

ifort -# -o hello_exe hello.f90
Thank you for your help Kevin and Tim. Unfortunately I still have not managed to get the 32bit working but 64bit works great and cross-32bit is not essential. Kevin, I did try 4 different ifort versions and was aware of the differences between each and as I never had the problem with CENTOS 64 / RH as Tim said, it must be due to the peculiarities of Ubuntu. Thanks again, you guys are great!
0 Kudos
Kevin_D_Intel
Employee
2,485 Views
Demian, this is the root-cause of the errors you suffered.

Ubuntu (64-bit) uses this directory structure for 32-bit/64-bit libs, where /usr/lib contains 64-bit libraries:

drwxr-xr-x 42 root root 12288 2008-04-04 05:46 /usr/lib
drwxr-xr-x 5 root root 4096 2007-11-22 01:49 /usr/lib32
lrwxrwxrwx 1 root root 3 2007-06-26 03:07 /usr/lib64 -> lib
drwxr-xr-x 10 root root 4096 2007-06-26 03:07 /usr/local

Something like RedHat EL5 (64-bit) uses this, where /usr/lib contains 32-bit libraries:

$ ls -ld /usr/l*
drwxr-xr-x 88 root root 65536 May 9 2008 /usr/lib
drwxr-xr-x 112 root root 94208 Oct 26 04:04 /usr/lib64
drwxr-xr-x 15 root root 4096 Oct 26 04:04 /usr/libexec
drwxr-xr-x 13 root root 4096 Oct 22 15:41 /usr/local

Using the 32-bit compiler on any 64-bit Linux pulls libraries from /usr/lib. So the issue is clear. /usr/lib on Ubuntu contains 64-bit libraries, hence the ld errors shown below:

$ ifort -V hello.f90
Intel Fortran Compiler for applications running on IA-32, Version 10.1 Build 20090203 Package ID: l_fc_p_10.1.022
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Intel Fortran 10.1-2052

GNU ld version 2.17.50 20070103 Ubuntu
ld: skipping incompatible /usr/lib/libm.so when searching for -lm
ld: skipping incompatible /usr/lib/libm.a when searching for -lm
ld: skipping incompatible /usr/bin/../lib/libm.so when searching for -lm
ld: skipping incompatible /usr/bin/../lib/libm.a when searching for -lm
ld: skipping incompatible /usr/lib/libm.so when searching for -lm
ld: skipping incompatible /usr/lib/libm.a when searching for -lm
ld: cannot find -lm

ifort does not support a -m32 like option so there is no straightforward method of convincing the 32-bit compiler to use complete 32-bit libraries under this Ubuntu (64-bit) directory structure. I do not know if we will succeed, but we have a couple of other items to try. I will keep you updated.

0 Kudos
bspeckel
Beginner
2,485 Views
The library layout on 64bit Debian-like distributions is different from other distributions :
  • other distributions have added 64bit support to their 32bit version
  • initially, Debian took the same route, but noticing that 64bit executables were generally faster than their 32bit versions, started over (~2004), adding 32bit support to a 64bit distribution
That's why on Debian, /lib64 is simply a symbolic link to /lib, which contains 64bit stuff.

The path of the C library initialization routines is hard-coded in ifortbin, but there is a simple workaround : the path of the linker is not hard-coded, one can add a wrapper to the linker which adapts the names to the Debian layout.

Just add the following script to ifort's directory, should be /opt/intel/fc//bin, call it 'ld', make it executable, and it should work (the ifort script puts it's directory at the front of the PATH)

[shell]#!/bin/bash

# ld wrapper for ifort to compile in 32bits mode on 64bits Debian-like dists
# Benoit Speckel - 2009 - Public domain

lib32=/emul/ia32-linux/usr/lib

args=(-L $lib32) i=2
for o
do      [[ "$o" == /usr/lib/*crt?.o ]] &&
        {       f=$lib32/${o##*/}
                [ -e $f ] && o=$f
        }
        args[$((i++))]=$o
done

exec /usr/bin/ld "${args[@]}"
[/shell]
Tested on a 64bit Debian-Lenny with ifort 10.1, hope it helps.

0 Kudos
Reply