# Intel Fortran with external libraries

**URL:** <https://fortran-lang.discourse.group/t/intel-fortran-with-external-libraries/1917>\
**Category:** Help\
**Created:** [September 22, 2021, 3:45pm UTC](https://fortran-lang.discourse.group/t/intel-fortran-with-external-libraries/1917 "2021-09-22T15:45:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hbayraktaroglu](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/hbayraktaroglu/32/1056_2.png) [@hbayraktaroglu](https://fortran-lang.discourse.group/u/hbayraktaroglu)\
**Post date:** [September 22, 2021, 3:45pm UTC](https://fortran-lang.discourse.group/t/intel-fortran-with-external-libraries/1917/1 "2021-09-22T15:45:39Z")

</div>

Hi,  
I am using OpenBlas (libopenblas.a) with gfortran (MSYS2). How can I use the same library in the Visual Studio+Intel Fortran combination? In other words, is there a way to include external libraries to VS+Intel Fortran?

Thanks

---

<div class="post-metadata">

**Author:** ![mecej4](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/mecej4/32/855_2.png) [@mecej4](https://fortran-lang.discourse.group/u/mecej4)\
**Post date:** [September 22, 2021, 3:52pm UTC](https://fortran-lang.discourse.group/t/intel-fortran-with-external-libraries/1917/2 "2021-09-22T15:52:59Z")

</div>

No, Gfortran and Intel Fortran libraries are not interchangeable. In fact, you do not even need the OpenBlas libraries if you have Intel Fortran and Intel MKL installed. Instead of the OpenBlas library, use the MKL library. When you create a new Fortran project in Visual Studio, select the option to use MKL.

---

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [September 23, 2021, 11:53am UTC](https://fortran-lang.discourse.group/t/intel-fortran-with-external-libraries/1917/3 "2021-09-23T11:53:34Z")

</div>

Hello @hbayraktaroglu and @mecej4! Welcome to Discourse.

@mecej4, your replies at the Intel Fortran forum have helped me a lot in the past.

For users of Linux or mac OS I would add that the Intel Fortran compiler also has an MKL compiler flag: `–mkl[=<lib>]` where `<lib>` is either `sequential`, `parallel` or `cluster`. I find this useful for small projects.

For code that has to work with multiple compilers (and using a build system) it is better to use `pkg-config` or the MKL Link Line Advisor (edited: see post below from @mecej4).

---

<div class="post-metadata">

**Author:** ![mecej4](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/mecej4/32/855_2.png) [@mecej4](https://fortran-lang.discourse.group/u/mecej4)\
**Post date:** [September 23, 2021, 3:43pm UTC](https://fortran-lang.discourse.group/t/intel-fortran-with-external-libraries/1917/4 "2021-09-23T15:43:02Z")

</div>

On Windows, the command line option /Qmkl corresponds to the -mkl option for Linux and OSX, but I suspected that the OP is building inside Visual Studio.

For more complicated situations, Intel provides a nice tool, the [MKL Link Line Advisor](https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onemkl/link-line-advisor.html).

---

<div class="post-metadata">

**Author:** ![wyphan](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/wyphan/32/632_2.png) [@wyphan](https://fortran-lang.discourse.group/u/wyphan)\
**Post date:** [September 23, 2021, 9:35pm UTC](https://fortran-lang.discourse.group/t/intel-fortran-with-external-libraries/1917/5 "2021-09-23T21:35:50Z")

</div>

I wish the MKL Link Line Advisor gets updated for NVIDIA HPC SDK, which has now effectively replaced PGI compilers.
