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

About specifying static or dynamic linking for each library

makoto2
Beginner
660 Views

Hi fellow members of the community,

When linking external libraries in intel fortran, is it possible to explicitly specify whether each library is static or dynamic?

My environment is,
x86_64 GNU/Linux
ifort version 2021.9.0

For example
ifort aaa.o bbb.o -O2
-I/opt/local/x86_64/apps/oneapi/2023/subapps/eccodes/lib64/include
-I/usr/include
-L/opt/local/x86_64/apps/oneapi/2023/lib
-L/usr/lib64
-o ... /out.exe
-lm -lmfhdf -ldf -ltirpc -lsz -ljasper -ljpeg -lz -lstdc++

In my environment, I have both of these libraries. (libdf.a, libmfhdf.a, libdf.so, libmfhdf.so)
However, I would like to use the static library because the shared library has a disable fortran interface.

Also, these libraries (libjasper.so, libjpeg.so) are only dynamic libraries.
On the other hand, these libraries (libz.a, libz.so) and others have both.

If I add the static option, an error occurs for the libraries that only have dynamic libraries, and I cannot compile them.

In the above situation, I want to link only these libraries (libdf.a, libmfhdf.a) with static libraries.

0 Kudos
1 Solution
makoto2
Beginner
629 Views

I am happy to report that I have solved the problem.

If I add the -Bstatic option to the libraries (libdf.a, libmfhdf.a) that I want to be static libraries only, the compilation went through.


Thank you very much to everyone who looked at this question.

View solution in original post

0 Kudos
1 Reply
makoto2
Beginner
630 Views

I am happy to report that I have solved the problem.

If I add the -Bstatic option to the libraries (libdf.a, libmfhdf.a) that I want to be static libraries only, the compilation went through.


Thank you very much to everyone who looked at this question.

0 Kudos
Reply