2017-07-07 101 views
1

我在鏈接英特爾MKL問題,libdl使用在CentOS黃金鍊接:如何鏈接英特爾MKL和libdl與黃金鍊接器?

當我運行此腳本:

#!/bin/bash 

MKL_INC=$MKL_INSTALL_DIR/include 
MKL_LIB=$MKL_INSTALL_DIR/lib 

. /opt/rh/devtoolset-6/enable 

cat > t.c << end_mkltest 

#include <dlfcn.h> 
#include "mkl_service.h" 

int main() { 
    dlerror();    /* use libdl */ 
    mkl_set_num_threads(1); /* use mkl */ 
} 

end_mkltest 

gcc -I$MKL_INC -c t.c -o t.o 
gcc -L$MKL_LIB -fuse-ld=gold t.o -lmkl_rt -ldl 

我得到:

libmkl_rt.so: error: undefined reference to 'calloc' 
libmkl_rt.so: error: undefined reference to 'realloc' 
libmkl_rt.so: error: undefined reference to 'malloc' 
libmkl_rt.so: error: undefined reference to 'free' 

我們使用:

CentOS 7.3 
devtoolset-6 
mkl-2017.2.174.tar.bz2 

任何想法?

回答

0

這應該工作。你能發佈這個命令顯示的鏈接器命令嗎?

gcc -v -L$MKL_LIB -fuse-ld=gold t.o -lmkl_rt -ldl 

(對不起,不能發佈此作爲註釋由於缺乏信譽的。)