Reputation: 432
I'm switching from gcc to Intel ifort and icc.
The Fortran code is mostly legacy, likewise the the rest of the system.
The main program is written in C. It handles the I/O and passes everything to a Fortran subroutine.
For now I compile the Fortran part with:
cd fortran
ifort -I../inc -debug full -c *.[fF]
cd ..
For C and linking I tried:
icc -ansi -static -debug full -Wall -o testout \
-I./inc -L./lib\
main.c \
fortran/*.o \
-lifcore -limf -lm\
this gives me:
ld: cannot find -lm
ld: cannot find -lm
ld: cannot find -lc
ld: cannot find -ldl
ld: cannot find -lc
This is mostly copied from the former bash script to compile with gcc.
Upvotes: 3
Views: 3860
Reputation: 1593
The -static
flag will link all the libraries statically. In that case you need to have a static version (the .a
files) of every library. For example, using -lm
will search for libm.a
. Those libraries are not installed by default, but may be in the -dev
or -devel
packages of your distribution.
If you only want to link statically the Intel libraries, then you should use -static-intel
.
A good trick to avoid static linking is to:
1) Dynamically link your program with -static-intel
and -Wl,-rpath=./lib
2) Use ldd
to find which libraries your program needs
3) Create a directory lib
where you copy all the required dynamic libraries
4) Instead of distributing your code as a single static binary you can disrtibute it as a binary + the lib directory (assuming the licenses of the libraries permit it).
Finally, if you need to try more things, I have succeeded to link an Intel Fortran file with gcc using this command:
$ gcc fortran_file.o c_main_file.o -lifcore -lirc -lcomposerxe_gen_helpers_core_2.3
hope this helps...
Upvotes: 4