简体   繁体   English

尽管链接到数学库,但未定义对`sqrt`的引用

[英]Undefined reference to `sqrt` despite linking to math library

I am trying to compile an example program from the Intel MKL library ( /opt/intel/mkl/examples/versionqueryc/ ). 我正在尝试从英特尔MKL库( /opt/intel/mkl/examples/versionqueryc/ )编译示例程序。 I copied the source code (C-file) to a new directory. 我将源代码(C文件)复制到一个新目录。 I then went and tried to build this example using CMake. 然后我去尝试用CMake构建这个例子。

In the course of debugging this, I am stuck when trying to use the following command (isolated from cmake by now). 在调试过程中,我在尝试使用以下命令时遇到困难(现在与cmake隔离)。

It doesn't find the Math library but I have -lm included in the linking. 它没有找到数学库,但我在链接中包含了-lm So what is going on? 那么发生了什么?

:~/devel/mkl/MKL Test/build$  /usr/bin/gcc -m64 CMakeFiles/mkltest.dir/main.c.o \
>     -o mkltest    -rdynamic -L/home/myuser/src/intel/mkl/lib/intel64 \
>     -lm  -lmkl_intel_lp64 -lmkl_sequential -lmkl_core  -lmkl_cdft_core \
>     -lmkl_scalapack_lp64 \
>     /home/myuser/src/intel/lib/intel64/libiomp5.so \
>     -Wl,-rpath,/home/myuser/src/intel/mkl/lib/intel64:/home/myuser/src/intel/lib/intel64 
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `logf'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `atan2'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `sin'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `fabs'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `exp'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `sqrtf'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `cos'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `sqrt'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_sequential.so: undefined reference to `log'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `pow'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `log10'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `ceil'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `expf'
collect2: ld returned 1 exit status

-lm作为最后一个参数,链接时参数的顺序很重要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM