Hi, I’d like to use the Fortran subroutine ZGELSS from MKL in Julia and I’m a bit confused.

```
julia> versioninfo()
Julia Version 1.3.0
Commit 46ce4d7933 (2019-11-26 06:09 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin19.0.0)
CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 4
```

I tried to find the subroutine in libmkl_rt.dylib and I’m confused about what everything is.

```
nm /opt/intel/compilers_and_libraries_2020.0.166/mac/mkl/lib/libmkl_rt.dylib | grep zgelss
00000000003e28f0 T _LAPACKE_zgelss
00000000003e2ed0 T _LAPACKE_zgelss_work
00000000003e2590 T _lapacke_zgelss
00000000003e27d0 T _lapacke_zgelss_
00000000003e2a20 T _lapacke_zgelss_work
00000000003e2d40 T _lapacke_zgelss_work_
0000000000528960 T _mkl_lapack__zgelss_
00000000005284e0 T _zgelss
0000000000528660 T _zgelss_
```

The closest topic I could find regarding this was Call Intel MKL as external library. The code shown there worked, so I tried to ccall LAPACKE_zgelss that way and I get

```
signal (11): Segmentation fault: 11
in expression starting at /path to julia file/MKL_zgelss_test.jl:46
mkl_lapack_zgelss at /opt/intel/compilers_and_libraries_2020.0.166/mac/mkl/lib/libmkl_core.dylib (unknown line)
ZGELSS at /opt/intel/compilers_and_libraries_2020.0.166/mac/mkl/lib/libmkl_intel_ilp64.dylib (unknown line)
LAPACKE_zgelss_work at /opt/intel/compilers_and_libraries_2020.0.166/mac/mkl/lib/libmkl_intel_ilp64.dylib (unknown line)
LAPACKE_zgelss at /opt/intel/compilers_and_libraries_2020.0.166/mac/mkl/lib/libmkl_intel_ilp64.dylib (unknown line)
Allocations: 53473789 (Pool: 53462622; Big: 11167); GC: 57
```

the code for this is

```
using Libdl
const global librt = Libdl.find_library(["libmkl_rt"],
["path to libmkl_rt"])
Libdl.dlopen(librt)
function zgelssMKL_C(A::StridedMatrix{ComplexF64}, b::StridedMatrix{ComplexF64})
m, n = size(A)
lda = ldb = max(1,stride(A, 2))
s = similar(A, Float64, lda)
rcond = -1.0
rank = 0
# lapack_int LAPACKE_zgelss(
# int matrix_layout,
# lapack_int m,
# lapack_int n,
# lapack_int nrhs,
# lapack_complex_double * a,
# lapack_int lda,
# lapack_complex_double * b,
# lapack_int ldb,
# double * s,
# double rcond,
# lapack_int * rank)
dd = ccall(("LAPACKE_zgelss", librt),
Cint, # Return type
(Int64, Int64, Int64, Int64,
Ptr{ComplexF64}, Int64, Ptr{ComplexF64}, Int64,
Ptr{Float64}, Float64, Int64),
102, m, n, 1,
A, lda, b, ldb,
s, rcond, rank)
dd, b # dd = 0 if calculation is done, b = output
end # function
N = 10;
A = rand(ComplexF64,N,N);
AA = copy(A);
b = rand(ComplexF64, N,1);
c = copy(b);
dd, x = zgelssMKL_C(A, b)
```

What could be causing this?

Is it possible to call ZGELSS?

Would there be any differences between LAPACKE_zgelss and ZGELSS

Thanks