1

我在 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

有任何想法吗?

4

1 回答 1

0

这应该有效。您可以发布此命令显示的链接器命令吗?

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

(抱歉,由于缺乏声誉,无法将此作为评论发布。)

于 2017-07-16T20:01:10.833 回答