Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

fortran libraries to include in using gcc

czhenry
Beginner
2,012 Views
Hi, list,
I've been developing an application for the open source program pd. This requires compiling different parts of code in both Fortran and C. I've been using gcc to compile and link everything...
The fortran code has been successfully compiled, linked, and tested using the intel fortran compiler, but I'm having difficulty making the transition to linking everything together with gcc.
The makefile compiles all of the fortran code into individual .o files, and then gcc tries to link them with the C code for the module. I found that when I link using -lifcore (includes libifcore.a) in gcc, I resolve the undefined symbol errors, but further errors remain when I try to run the code. Namely, the code produces a segmentation fault. I've been trying to debug using gdb, and I find that the error stems from a symbol for_open, and subsequent calls made by ifcore.
Should I be including other libraries from the intel fortran compiler as well?
(I'm running FC4 on an i386 arch).
Chuck Henry
0 Kudos
7 Replies
TimP
Honored Contributor III
2,012 Views
In many situations, it's simpler to use ifort to drive the link, adding any libraries required by your gcc code. Usually, there are several libraries required by ifort. Ifort option -# would show details of the link command.
0 Kudos
czhenry
Beginner
2,012 Views
hmmm....so, could I compile my C code and link it with ifort?
On the other hand, I could find the libraries in the test code which is successful, using -#, and then, link them in with gcc...
I'll try gcc first, since there are many C libraries to link in as well, and then try ifort after that. I'll reply back later, once I get the results.
0 Kudos
joseph-krahn
New Contributor I
2,012 Views
Ifort linking requirements are usually rather complex compared to gcc. Fortunately, you can use the -v flag to see all of the details. Remember that the way you link mixed C/Fortran code depends on what language the main entry procedure is in.
0 Kudos
Tony_Garratt
Beginner
2,012 Views

Im trying to do exactly the same thing - use gcc to link gcc C++ objects with Intel Fortran objects (all on Linux). My question is: how to I know which Intel Fortran libraries to pull in? Ive search the documentation but cant find anything to help me. At the moment Im getting the following unresolved: __svml_log2; __svml_pow2 and a message that says

/opt/intel/fce/10.1.008/lib/libifcore.so.5: undefined reference to `dlsym'

Any advice would be most welcome.

Thanks

Tony

0 Kudos
Steven_L_Intel1
Employee
2,012 Views
You need libsvml.a for the __svml_log2 routine. I strongly recommend using ifort to do the link step.
0 Kudos
Tony_Garratt
Beginner
2,011 Views

Thanks for your reply Steve. I will look into linking with ifort - in the meantime, the only error using gcc to link that I am getting now is

/opt/intel/fce/10.1.008/lib/libifcore.so.5: undefined reference to `dlsym'

Does that mean I am still missing an additional library? Thank you so much.

Tony

0 Kudos
Tony_Garratt
Beginner
2,011 Views
I found out the problem myself - I needed to add -ldl to my gcc link.
0 Kudos
Reply