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

link options for static build

Scott_L_
New Contributor I
2,763 Views

 

For an application with primarily Fortran but a bit of C & C++ code, what are the link options I need to get a fully static built executable?

 

thanks,

Scott

 

0 Kudos
4 Replies
Kevin_D_Intel
Employee
2,763 Views

More detail may be needed about the app to get a complete answer. Are you building via command-line?  Does it have a Fortran main?  Are the C/C++ just objects files or a static lib?

At least for Fortran, when linking via the command-line using the ifort driver, one can add /MT. For Fortran project, under the IDE the equivalent setting is under Properties > Fortran > Libraries > Runtime Library.

Note if using OpenMP, a static version of the OpenMP library (libiomp5mt.lib) is no longer available as of the early PSXE 2013 release.

0 Kudos
Scott_L_
New Contributor I
2,763 Views

Sorry, left everything out !!!!!!!!!!!

building in Linux (porting from windows MS VS) using Makefiles

using intel fortran 17.1 and intel C

compiler link flags


export FFLAGS = -c -I ../Includes -DLINUX -assume nounderscore  -names lowercase -noauto -O0   \
               -fp-model=precise -fp-speculation=strict -fpconstant  -traceback  -debug full
export CFLAGS = -c -I ../Includes -DLINUX -O1
export LINKFLAGS =   -lirng -ldecimal -lcilkrts  -static-intel

#                -Bstatic

 

If I add -Bstatic to the link flags, then -lcilkrts   is not found but it links OK without -Bstatic;  it just is not fully static and will not run if the path to the shared libs is not defined.

 

thanks,

scott

p.s. if you ever could get Visual Studio on windows to compile and build Linux exe's, I would send you a xmas card.

0 Kudos
TimP
Honored Contributor III
2,763 Views

Your quoted link flags look ok. There is no static libcilkrts, so those features make a .so dependency.  It would be surprising that cilk parallel would be used with O0.

0 Kudos
Kevin_D_Intel
Employee
2,763 Views

As Tim said, there’s no static version of libcilkrts available. Is that the only library of concern that isn’t linking static?

If so, then also as Tim said, your options would yield linking to available static Intel libs at least. Other non-Intel libs may still link dynamically. We also have a –static option which yields statically linking other libs beyond just Intel libraries. That option may work better than your forcing –Bstatic along with trying to exempt libcilkrts from that. You might try it instead of –static-intel.

0 Kudos
Reply