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

How to create a *.so library file, and how link the *.so library file to a file?

james_uta
Beginner
2,311 Views
I have several source files in both C and Fortran as library files. I hope I can create a library file A.so for these source code files by IntelFORTRAN compile under Linux operating system first.

I have abig application file in Intel Fortran feature such as dynamical memory allocation, in which will call functions that come from A.so.

Please tell me how I can do forboth ofthem, thanks in advance.

James
0 Kudos
5 Replies
TimP
Honored Contributor III
2,311 Views
Quoting - james_uta
I have several source files in both C and Fortran as library files. I hope I can create a library file A.so for these source code files by IntelFORTRAN compile under Linux operating system first.

http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/index.html
is one of several examples of where to look up such information. Intel linux compilers should work the same as gnu compilers in such context.
0 Kudos
james_uta
Beginner
2,311 Views
Quoting - tim18
http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/index.html
is one of several examples of where to look up such information. Intel linux compilers should work the same as gnu compilers in such context.
Thanks for the help. I checked the website, but I can not find. Can you give me some specific help such as
for gnu compiler has f77, Intel Fortran can use "ifort" to replace "f77" in a makefile. But for
ar ruv liba.a a1.o a2.o b1.o b2
how can change it into Intel Fortran part, thanks.
0 Kudos
Ron_Green
Moderator
2,311 Views
Quoting - james_uta
Thanks for the help. I checked the website, but I can not find. Can you give me some specific help such as
for gnu compiler has f77, Intel Fortran can use "ifort" to replace "f77" in a makefile. But for
ar ruv liba.a a1.o a2.o b1.o b2
how can change it into Intel Fortran part, thanks.

James,

the 'ar', 'ld' and other commands are part of binutils, part of the whole GNU compilation environment. Our philosophy is to use the same object formats and tools as gnu and not reinvent things. GNU compatibility.

So 'ar' will work just fine with object files created by the Intel compiler. The only thing you need to change is f77 to ifort

ron
0 Kudos
james_uta
Beginner
2,311 Views

James,

the 'ar', 'ld' and other commands are part of binutils, part of the whole GNU compilation environment. Our philosophy is to use the same object formats and tools as gnu and not reinvent things. GNU compatibility.

So 'ar' will work just fine with object files created by the Intel compiler. The only thing you need to change is f77 to ifort

ron

Hi Ron, thank you very much. If I am using openmpi compiler, what I should do for it? thanks.

0 Kudos
TimP
Honored Contributor III
2,311 Views
Quoting - james_uta

If I am using openmpi compiler, what I should do for it? thanks.

As the openmpi compiler would use the same gnu binutils as the underlying gnu or Intel compiler, the use of ar et al. would be the same as for any of those compilers.
If you have a pre-built openmpi, you could find out which compiler it uses by commands such as
mpif77 -v (will work if it's gfortran)
mpif77 -V (if it's ifort)
Similarly for mpif90. If you want to use ifort, it will be much easier if you configure and build a copy of openmpi which uses ifort. I believe Ron has posted instructions for that, and they're available also on openmpi support site.
0 Kudos
Reply