icc/ifort 8.0 linking issue

icc/ifort 8.0 linking issue

hello,

I am trying to link GOTOs libraries (http://www.cs.utexas.edu/users/kgoto/) with LLCBench (http://icl.cs.utk.edu/projects/llcbench/) and using Version 8.0 with the latest update.

The code is a C code. Libraries are pre-built (donwloaded from site) and a single fortran source file.

The code is compiled with icc V8.0. the Fortran source code with ifort.

And I tried to link all the objects and libraries with icc without success. With V7.1 I am able to do that by linking -lF90, -lCEPCF90, -lIEPCF90. These libraries are not present in V8.0.

The I tried linking with ifort. It complains of multiple delcarations for main.

I looked in users guide. could not find any information.

1) How to link Fortran objects with a C main ?
2) How to link C objects with a Fortran main ?

any help is greatly appreciated.

warm regards,
Kalyan

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I'll echo the usual recommendation that you should try to set up your link using the Fortran compiler as a driver, so that you don't need to know about the specific libraries of each compiler. As 8.0 has dropped the no longer supported EPC front end, you won't find any EPC libraries.
So, if you don't do anything too fancy in C, you should be able to use ifort to drive the link, with the same options used to build the .o files. If the libraries have extra versions of main() which you want ignored, you may have to remove them, or pass a specific option to that effect through to ld by -Wl,... For screen echo to show what commands are passed to ld, ifort -# should do it.
There are some ifort issues with redhat 9 and EL 3.0 update 1.

For EL 3 U1 (ia32), we found yesterday that the current ifort package doesn't have the necessary up to date library for openmp. We are working on it.

Red hat 9 has been reported to have an ld which does not always search the libraries as requested, in a static link. It may be necessary to pass the libraries by full individual path names, rather than relying on the usual-L and -l flags. Then you would need to know the names of all libraries, including libc.a and those from the Fortran installation. I hope you aren't using rh9.

You also need -noformain on the ifort command that links the code (assuming the main program is not Fortran.) This is new in 8.0.

Retired 12/31/2016

Thank you for the detailed and prompt reply.

I tired the ifort as the driver for linking in the first time itself. It started complaining about multiplt declarations for main and undefined reference to MAIN__. hence I tried using icc as the linker driver.

As per your suggestion, I tried -# and noticed that lib/for_main.o was being passed to the linker. Using -nofor_main solved the problem.

thanks,
Kalyan

using -nofor_main, I was able to generate the executable.

However, the following messages appears:

/opt/intel_fc_80/lib/libifcoremt.a(tbk_linux.o)(.text+0xf2): In function `tbk_stack_trace':
: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
Though the executable is generated without any issues, I am curious to know the significance of the message.

Here is the -# output:

ld
/usr/lib/crt1.o
/usr/lib/crti.o
/opt/intel_fc_80/lib/crtxi.o
-dynamic-linker
/lib/ld-linux-ia64.so.2
-o
vbb
-relax
bb.o
flushall.o
xerbla.o
-L
/usr/lib/goto
-lgoto_it2-r0.9
-Qy
-L/opt/intel_fc_80/lib
-L/usr/lib
-Bstatic
-lifport
-lifcoremt
-ldl
-limf
-Bdynamic
-lm
-Bstatic
-Bdynamic
-lcxa
-lunwind
-Bdynamic
-u
__pthread_once
-lpthread
-Bstatic
-lirc
-Bdynamic
-lc
-Bstatic
-lirc
/opt/intel_fc_80/lib/crtxn.o
/usr/lib/crtn.o
regards,
Kalyan

Leave a Comment

Please sign in to add a comment. Not a member? Join today