Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Calling Fortran Blas routine from C



I am trying to call Fortran subroutine that calls zdotu from C.

I am using linking flags from Advisor

These linking flags for both C and Fortran work when I compiled samples dgemm and matrix multiplication.

However, I am getting SIGSEGV, when running my simple app when both Fortran and C linking flags are used.

I am using GNU compiler, Intel OpenMP lib, intel64 platform, sizeof(int)=4, tried both dynamic and static linking.

The code I am trying to run is actually from R configure script.

Please let me know, how to link both Fortran and C at the same time.


0 Kudos
3 Replies
Black Belt

I doubt that the problem is just a linking issue. I suspect that the Fortran routine in MKL is not receiving the proper argument list. If you show the malfunctioning code and instructions to reproduce it, some progress may be possible.

0 Kudos

Hi Eli,

Could you please tell how do you call the function.  MKL support call fortran routine from c.

for example,  you may refer to the MKL user guide : there is sample call zdotc.  (almost same as zdotu).  Please not the output C was the first parameter in routine. 

Example "Calling a Complex BLAS Level 1 Function from C++"
Below is the C++ implementation:
#include <complex>
#include <iostream>
#define MKL_Complex16 std::complex<double>
#include "mkl.h"
#define N 5
int main()
int n, inca = 1, incb = 1, i;
std::complex<double> a, b, c;
n = N;
for( i = 0; i < n; i++ ){
a = std::complex<double>(i,i*2.0);
b = std::complex<double>(n-i,i*2.0);
zdotc(&c, &n, a, &inca, b, &incb );
std::cout << "The complex dot product is: " << c << std::endl;
return 0;

Best Regards,


P.S If your program related to R and MKL.

It may be more than the problem. Just for your reference:

for example, there are mainly  two ways

1. how you could use MKL from R by load dynamic library

2. integrate MKL to R to use BLAS and LAPACK.  and

Build R-3.4.2 with Intel® C++ and Fortran Compilers


0 Kudos

Thanks everybody for prompt replies

I fixed the problem. Everything is linking and works now. However, R regression test with MKL vs OpenBLAS reports at least 2 more failures.

I am not sure if number in R regression tests are right, it needs some investigation.

0 Kudos