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

Building on CENTOS

David_J_2
Beginner
572 Views
I'm trying to build a couplelarge applications under CENTOS using Composer XE. I have one working, but the other link and I don't understand why. I have a main source a.F and two libraries. p.a and u.a

If I get a compiled as a.o
then do

ifort ./a.o -o aexe -B/home/dajum/p.a -B/home/dajum/u.a

It doesn't find routines in the libraries. Using -L instead of -B fails the same way.

Using

ld a.o /home/dajum/p.a /home/dajum/u.a -o aexe

it finds library routines, but not fortran library routines like 'pow' and 'for_write_seq_fmt'

trying

ifort -o aexe ./a.o /home/dajum/p.a /home/dajum/u.a

seems to find the library routines that are fortran sourced, but not the c sourced ones.

What is the right way to do this?

Thanks
0 Kudos
2 Replies
mecej4
Honored Contributor III
572 Views
A look at the manual pages for ifort and ld would have told you that your first two commands above were bound to fail.

The third command is correct as far as I can see, if the entire contents of p.a and u.a are to appear in the a.out, but you did not show what the error message said. Certain conditions have to be met in order for inter-language linking to work correctly.

Neither the compiler driver nor the linker know the difference between "Fortran-sourced" and "C-sourced" objects and libraries at this point.
0 Kudos
TimP
Honored Contributor III
572 Views
I don't know what ifort should do with -Bsome.a. Normally, you would set -L to point to the library directory, and use -lyourlib, if the library file is named libyourlib.a. If your libraries aren't named according to libsomething.a, it should be possible simply to give the library name as you did, without -B or -L. Also, I would expect you to put your -o option before your list of objects and libraries.
ld has no knowledge about which libraries must be linked in an ifort build, even if the PATH variables are set by sourceing the compilervars script. You would need to find out (e.g. by ifort -#) how the ifort libraries are to be searched, and specify them. ld doesn't even know the libraries which g++ would require.
Are your C functions built by gcc or by icc? If you install the same version of icc and ifort, they must share all their directories, so there should be no problem finding icc libraries.
If built by gcc, it should be the same gcc version as the g++ version which is active to support ifort.
I haven't run into any problems with ifort/icc 12.0 on CentOS 5.5, other than the installer complaining about non-support, and that the JRE may not be the right one (to support idb). Many customers use CentOS, in spite of Intel not testing specifically on it.
0 Kudos
Reply