添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I've just installed GSL on my Deepin OS(Linux), and for testing my installation I'm trying to compile a testing file. When compiling with gcc , it works properly, but when using CMake, some Undefined Reference error occurs.

I tried compiling the file main.c with gcc :

gcc main.c -o demo -lm -lgsl -lgslcblas
./demo

and it works properly. But when I tried CMake :

cmake .

with a CMakeLists.txt file that looks like :

# CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(demo)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(SOURCE_FILES main.c)
add_executable(demo ${SOURCE_FILES})
find_package(GSL REQUIRED)
target_link_libraries(demo GSL::gsl GSL::gslcblas)

such error occurs :

(The output is in Chinese, because of the system language. For example :

/usr/local/lib/libcblas.a(cblas_srotg.o):在函数‘cblas_srotg’中:
cblas_srotg.c:(.text+0x1):对‘srotg_’未定义的引用

means :

/usr/local/lib/libcblas.a(cblas_srotg.o):In function ‘cblas_srotg’ :
cblas_srotg.c:(.text+0x1):Undefined reference to ‘srotg_’.
[ 50%] Linking C executable demo
/usr/local/lib/libcblas.a(cblas_srotg.o):在函数‘cblas_srotg’中:
cblas_srotg.c:(.text+0x1):对‘srotg_’未定义的引用
/usr/local/lib/libcblas.a(cblas_srotmg.o):在函数‘cblas_srotmg’中:
cblas_srotmg.c:(.text+0x13):对‘srotmg_’未定义的引用
/usr/local/lib/libcblas.a(cblas_srot.o):在函数‘cblas_srot’中:
cblas_srot.c:(.text+0x3c):对‘srot_’未定义的引用
/usr/local/lib/libcblas.a(cblas_srotm.o):在函数‘cblas_srotm’中:
cblas_srotm.c:(.text+0x21):对‘srotm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_sswap.o):在函数‘cblas_sswap’中:
cblas_sswap.c:(.text+0x21):对‘sswap_’未定义的引用
/usr/local/lib/libcblas.a(cblas_sscal.o):在函数‘cblas_sscal’中:
cblas_sscal.c:(.text+0x28):对‘sscal_’未定义的引用
/usr/local/lib/libcblas.a(cblas_scopy.o):在函数‘cblas_scopy’中:
cblas_scopy.c:(.text+0x21):对‘scopy_’未定义的引用
/usr/local/lib/libcblas.a(cblas_saxpy.o):在函数‘cblas_saxpy’中:
cblas_saxpy.c:(.text+0x35):对‘saxpy_’未定义的引用
/usr/local/lib/libcblas.a(sdotsub.o):在函数‘sdotsub_’中:
sdotsub.f:(.text+0x7):对‘sdot_’未定义的引用
/usr/local/lib/libcblas.a(sdsdotsub.o):在函数‘sdsdotsub_’中:
sdsdotsub.f:(.text+0x7):对‘sdsdot_’未定义的引用
/usr/local/lib/libcblas.a(snrm2sub.o):在函数‘snrm2sub_’中:
snrm2sub.f:(.text+0x7):对‘snrm2_’未定义的引用
/usr/local/lib/libcblas.a(sasumsub.o):在函数‘sasumsub_’中:
sasumsub.f:(.text+0x7):对‘sasum_’未定义的引用
/usr/local/lib/libcblas.a(isamaxsub.o):在函数‘isamaxsub_’中:
isamaxsub.f:(.text+0x7):对‘isamax_’未定义的引用
/usr/local/lib/libcblas.a(cblas_drotg.o):在函数‘cblas_drotg’中:
cblas_drotg.c:(.text+0x1):对‘drotg_’未定义的引用
/usr/local/lib/libcblas.a(cblas_drotmg.o):在函数‘cblas_drotmg’中:
cblas_drotmg.c:(.text+0x13):对‘drotmg_’未定义的引用
/usr/local/lib/libcblas.a(cblas_drot.o):在函数‘cblas_drot’中:
cblas_drot.c:(.text+0x3b):对‘drot_’未定义的引用
/usr/local/lib/libcblas.a(cblas_drotm.o):在函数‘cblas_drotm’中:
cblas_drotm.c:(.text+0x21):对‘drotm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dswap.o):在函数‘cblas_dswap’中:
cblas_dswap.c:(.text+0x21):对‘dswap_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dscal.o):在函数‘cblas_dscal’中:
cblas_dscal.c:(.text+0x25):对‘dscal_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dcopy.o):在函数‘cblas_dcopy’中:
cblas_dcopy.c:(.text+0x21):对‘dcopy_’未定义的引用
/usr/local/lib/libcblas.a(cblas_daxpy.o):在函数‘cblas_daxpy’中:
cblas_daxpy.c:(.text+0x38):对‘daxpy_’未定义的引用
/usr/local/lib/libcblas.a(ddotsub.o):在函数‘ddotsub_’中:
ddotsub.f:(.text+0x7):对‘ddot_’未定义的引用
/usr/local/lib/libcblas.a(dsdotsub.o):在函数‘dsdotsub_’中:
dsdotsub.f:(.text+0x7):对‘dsdot_’未定义的引用
/usr/local/lib/libcblas.a(dnrm2sub.o):在函数‘dnrm2sub_’中:
dnrm2sub.f:(.text+0x7):对‘dnrm2_’未定义的引用
/usr/local/lib/libcblas.a(dasumsub.o):在函数‘dasumsub_’中:
dasumsub.f:(.text+0x7):对‘dasum_’未定义的引用
/usr/local/lib/libcblas.a(idamaxsub.o):在函数‘idamaxsub_’中:
idamaxsub.f:(.text+0x7):对‘idamax_’未定义的引用
/usr/local/lib/libcblas.a(cblas_cswap.o):在函数‘cblas_cswap’中:
cblas_cswap.c:(.text+0x21):对‘cswap_’未定义的引用
/usr/local/lib/libcblas.a(cblas_cscal.o):在函数‘cblas_cscal’中:
cblas_cscal.c:(.text+0x17):对‘cscal_’未定义的引用
/usr/local/lib/libcblas.a(cblas_csscal.o):在函数‘cblas_csscal’中:
cblas_csscal.c:(.text+0x28):对‘csscal_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ccopy.o):在函数‘cblas_ccopy’中:
cblas_ccopy.c:(.text+0x21):对‘ccopy_’未定义的引用
/usr/local/lib/libcblas.a(cblas_caxpy.o):在函数‘cblas_caxpy’中:
cblas_caxpy.c:(.text+0x21):对‘caxpy_’未定义的引用
/usr/local/lib/libcblas.a(cdotcsub.o):在函数‘cdotcsub_’中:
cdotcsub.f:(.text+0xb):对‘cdotc_’未定义的引用
/usr/local/lib/libcblas.a(cdotusub.o):在函数‘cdotusub_’中:
cdotusub.f:(.text+0xb):对‘cdotu_’未定义的引用
/usr/local/lib/libcblas.a(icamaxsub.o):在函数‘icamaxsub_’中:
icamaxsub.f:(.text+0x7):对‘icamax_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zswap.o):在函数‘cblas_zswap’中:
cblas_zswap.c:(.text+0x21):对‘zswap_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zscal.o):在函数‘cblas_zscal’中:
cblas_zscal.c:(.text+0x17):对‘zscal_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zdscal.o):在函数‘cblas_zdscal’中:
cblas_zdscal.c:(.text+0x25):对‘zdscal_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zcopy.o):在函数‘cblas_zcopy’中:
cblas_zcopy.c:(.text+0x21):对‘zcopy_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zaxpy.o):在函数‘cblas_zaxpy’中:
cblas_zaxpy.c:(.text+0x21):对‘zaxpy_’未定义的引用
/usr/local/lib/libcblas.a(zdotcsub.o):在函数‘zdotcsub_’中:
zdotcsub.f:(.text+0x7):对‘zdotc_’未定义的引用
/usr/local/lib/libcblas.a(zdotusub.o):在函数‘zdotusub_’中:
zdotusub.f:(.text+0x7):对‘zdotu_’未定义的引用
/usr/local/lib/libcblas.a(dzasumsub.o):在函数‘dzasumsub_’中:
dzasumsub.f:(.text+0x7):对‘dzasum_’未定义的引用
/usr/local/lib/libcblas.a(dznrm2sub.o):在函数‘dznrm2sub_’中:
dznrm2sub.f:(.text+0x7):对‘dznrm2_’未定义的引用
/usr/local/lib/libcblas.a(izamaxsub.o):在函数‘izamaxsub_’中:
izamaxsub.f:(.text+0x7):对‘izamax_’未定义的引用
/usr/local/lib/libcblas.a(scasumsub.o):在函数‘scasumsub_’中:
scasumsub.f:(.text+0x7):对‘scasum_’未定义的引用
/usr/local/lib/libcblas.a(scnrm2sub.o):在函数‘scnrm2sub_’中:
scnrm2sub.f:(.text+0x7):对‘scnrm2_’未定义的引用
/usr/local/lib/libcblas.a(cblas_sgemv.o):在函数‘cblas_sgemv’中:
cblas_sgemv.c:(.text+0x124):对‘sgemv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_sger.o):在函数‘cblas_sger’中:
cblas_sger.c:(.text+0xab):对‘sger_’未定义的引用
cblas_sger.c:(.text+0xe3):对‘sger_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ssymv.o):在函数‘cblas_ssymv’中:
cblas_ssymv.c:(.text+0xb4):对‘ssymv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ssyr.o):在函数‘cblas_ssyr’中:
cblas_ssyr.c:(.text+0xa8):对‘ssyr_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ssyr2.o):在函数‘cblas_ssyr2’中:
cblas_ssyr2.c:(.text+0xb2):对‘ssyr2_’未定义的引用
/usr/local/lib/libcblas.a(cblas_strmv.o):在函数‘cblas_strmv’中:
cblas_strmv.c:(.text+0x141):对‘strmv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_strsv.o):在函数‘cblas_strsv’中:
cblas_strsv.c:(.text+0x141):对‘strsv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dgemv.o):在函数‘cblas_dgemv’中:
cblas_dgemv.c:(.text+0x120):对‘dgemv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dger.o):在函数‘cblas_dger’中:
cblas_dger.c:(.text+0xb3):对‘dger_’未定义的引用
cblas_dger.c:(.text+0xeb):对‘dger_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dsymv.o):在函数‘cblas_dsymv’中:
cblas_dsymv.c:(.text+0xb4):对‘dsymv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dsyr.o):在函数‘cblas_dsyr’中:
cblas_dsyr.c:(.text+0xa6):对‘dsyr_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dsyr2.o):在函数‘cblas_dsyr2’中:
cblas_dsyr2.c:(.text+0xb0):对‘dsyr2_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dtrmv.o):在函数‘cblas_dtrmv’中:
cblas_dtrmv.c:(.text+0x141):对‘dtrmv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dtrsv.o):在函数‘cblas_dtrsv’中:
cblas_dtrsv.c:(.text+0x141):对‘dtrsv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_cgemv.o):在函数‘cblas_cgemv’中:
cblas_cgemv.c:(.text+0x205):对‘cgemv_’未定义的引用
cblas_cgemv.c:(.text+0x290):对‘cgemv_’未定义的引用
cblas_cgemv.c:(.text+0x36d):对‘cgemv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_chemv.o):在函数‘cblas_chemv’中:
cblas_chemv.c:(.text+0x219):对‘chemv_’未定义的引用
cblas_chemv.c:(.text+0x2f0):对‘chemv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ctrmv.o):在函数‘cblas_ctrmv’中:
cblas_ctrmv.c:(.text+0x146):对‘ctrmv_’未定义的引用
cblas_ctrmv.c:(.text+0x200):对‘ctrmv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ctrsv.o):在函数‘cblas_ctrsv’中:
cblas_ctrsv.c:(.text+0x154):对‘ctrsv_’未定义的引用
cblas_ctrsv.c:(.text+0x210):对‘ctrsv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_cgeru.o):在函数‘cblas_cgeru’中:
cblas_cgeru.c:(.text+0xa6):对‘cgeru_’未定义的引用
cblas_cgeru.c:(.text+0xd9):对‘cgeru_’未定义的引用
/usr/local/lib/libcblas.a(cblas_cgerc.o):在函数‘cblas_cgerc’中:
cblas_cgerc.c:(.text+0x13d):对‘cgeru_’未定义的引用
cblas_cgerc.c:(.text+0x18f):对‘cgeru_’未定义的引用
cblas_cgerc.c:(.text+0x1ef):对‘cgerc_’未定义的引用
/usr/local/lib/libcblas.a(cblas_cher.o):在函数‘cblas_cher’中:
cblas_cher.c:(.text+0x10a):对‘cher_’未定义的引用
cblas_cher.c:(.text+0x1f7):对‘cher_’未定义的引用
/usr/local/lib/libcblas.a(cblas_cher2.o):在函数‘cblas_cher2’中:
cblas_cher2.c:(.text+0x17a):对‘cher2_’未定义的引用
cblas_cher2.c:(.text+0x281):对‘cher2_’未定义的引用
cblas_cher2.c:(.text+0x2bc):对‘cher2_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zgemv.o):在函数‘cblas_zgemv’中:
cblas_zgemv.c:(.text+0x20f):对‘zgemv_’未定义的引用
cblas_zgemv.c:(.text+0x298):对‘zgemv_’未定义的引用
cblas_zgemv.c:(.text+0x37c):对‘zgemv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zhemv.o):在函数‘cblas_zhemv’中:
cblas_zhemv.c:(.text+0x219):对‘zhemv_’未定义的引用
cblas_zhemv.c:(.text+0x2f0):对‘zhemv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ztrmv.o):在函数‘cblas_ztrmv’中:
cblas_ztrmv.c:(.text+0x155):对‘ztrmv_’未定义的引用
cblas_ztrmv.c:(.text+0x210):对‘ztrmv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ztrsv.o):在函数‘cblas_ztrsv’中:
cblas_ztrsv.c:(.text+0x155):对‘ztrsv_’未定义的引用
cblas_ztrsv.c:(.text+0x210):对‘ztrsv_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zgeru.o):在函数‘cblas_zgeru’中:
cblas_zgeru.c:(.text+0xa6):对‘zgeru_’未定义的引用
cblas_zgeru.c:(.text+0xd9):对‘zgeru_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zgerc.o):在函数‘cblas_zgerc’中:
cblas_zgerc.c:(.text+0x13e):对‘zgeru_’未定义的引用
cblas_zgerc.c:(.text+0x18f):对‘zgeru_’未定义的引用
cblas_zgerc.c:(.text+0x1ef):对‘zgerc_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zher.o):在函数‘cblas_zher’中:
cblas_zher.c:(.text+0x14b):对‘zher_’未定义的引用
cblas_zher.c:(.text+0x1a5):对‘zher_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zher2.o):在函数‘cblas_zher2’中:
cblas_zher2.c:(.text+0x17b):对‘zher2_’未定义的引用
cblas_zher2.c:(.text+0x281):对‘zher2_’未定义的引用
cblas_zher2.c:(.text+0x2bc):对‘zher2_’未定义的引用
/usr/local/lib/libcblas.a(cblas_sgemm.o):在函数‘cblas_sgemm’中:
cblas_sgemm.c:(.text+0x10f):对‘sgemm_’未定义的引用
cblas_sgemm.c:(.text+0x1a7):对‘sgemm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ssymm.o):在函数‘cblas_ssymm’中:
cblas_ssymm.c:(.text+0xe8):对‘ssymm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ssyrk.o):在函数‘cblas_ssyrk’中:
cblas_ssyrk.c:(.text+0xd7):对‘ssyrk_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ssyr2k.o):在函数‘cblas_ssyr2k’中:
cblas_ssyr2k.c:(.text+0xe5):对‘ssyr2k_’未定义的引用
/usr/local/lib/libcblas.a(cblas_strmm.o):在函数‘cblas_strmm’中:
cblas_strmm.c:(.text+0x12a):对‘strmm_’未定义的引用
cblas_strmm.c:(.text+0x1f0):对‘strmm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_strsm.o):在函数‘cblas_strsm’中:
cblas_strsm.c:(.text+0x12a):对‘strsm_’未定义的引用
cblas_strsm.c:(.text+0x1f0):对‘strsm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dgemm.o):在函数‘cblas_dgemm’中:
cblas_dgemm.c:(.text+0x10f):对‘dgemm_’未定义的引用
cblas_dgemm.c:(.text+0x1a7):对‘dgemm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dsymm.o):在函数‘cblas_dsymm’中:
cblas_dsymm.c:(.text+0xe8):对‘dsymm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dsyrk.o):在函数‘cblas_dsyrk’中:
cblas_dsyrk.c:(.text+0xd7):对‘dsyrk_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dsyr2k.o):在函数‘cblas_dsyr2k’中:
cblas_dsyr2k.c:(.text+0xe5):对‘dsyr2k_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dtrmm.o):在函数‘cblas_dtrmm’中:
cblas_dtrmm.c:(.text+0x122):对‘dtrmm_’未定义的引用
cblas_dtrmm.c:(.text+0x1e0):对‘dtrmm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_dtrsm.o):在函数‘cblas_dtrsm’中:
cblas_dtrsm.c:(.text+0x122):对‘dtrsm_’未定义的引用
cblas_dtrsm.c:(.text+0x1e0):对‘dtrsm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_cgemm.o):在函数‘cblas_cgemm’中:
cblas_cgemm.c:(.text+0x105):对‘cgemm_’未定义的引用
cblas_cgemm.c:(.text+0x19d):对‘cgemm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_csymm.o):在函数‘cblas_csymm’中:
cblas_csymm.c:(.text+0xe6):对‘csymm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_chemm.o):在函数‘cblas_chemm’中:
cblas_chemm.c:(.text+0xe6):对‘chemm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_cherk.o):在函数‘cblas_cherk’中:
cblas_cherk.c:(.text+0xd7):对‘cherk_’未定义的引用
/usr/local/lib/libcblas.a(cblas_cher2k.o):在函数‘cblas_cher2k’中:
cblas_cher2k.c:(.text+0x108):对‘cher2k_’未定义的引用
cblas_cher2k.c:(.text+0x185):对‘cher2k_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ctrmm.o):在函数‘cblas_ctrmm’中:
cblas_ctrmm.c:(.text+0x118):对‘ctrmm_’未定义的引用
cblas_ctrmm.c:(.text+0x1d6):对‘ctrmm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ctrsm.o):在函数‘cblas_ctrsm’中:
cblas_ctrsm.c:(.text+0x118):对‘ctrsm_’未定义的引用
cblas_ctrsm.c:(.text+0x1d6):对‘ctrsm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_csyrk.o):在函数‘cblas_csyrk’中:
cblas_csyrk.c:(.text+0xd5):对‘csyrk_’未定义的引用
/usr/local/lib/libcblas.a(cblas_csyr2k.o):在函数‘cblas_csyr2k’中:
cblas_csyr2k.c:(.text+0xe3):对‘csyr2k_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zgemm.o):在函数‘cblas_zgemm’中:
cblas_zgemm.c:(.text+0x105):对‘zgemm_’未定义的引用
cblas_zgemm.c:(.text+0x19d):对‘zgemm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zsymm.o):在函数‘cblas_zsymm’中:
cblas_zsymm.c:(.text+0xe6):对‘zsymm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zhemm.o):在函数‘cblas_zhemm’中:
cblas_zhemm.c:(.text+0xe6):对‘zhemm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zherk.o):在函数‘cblas_zherk’中:
cblas_zherk.c:(.text+0xd7):对‘zherk_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zher2k.o):在函数‘cblas_zher2k’中:
cblas_zher2k.c:(.text+0x109):对‘zher2k_’未定义的引用
cblas_zher2k.c:(.text+0x18d):对‘zher2k_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ztrmm.o):在函数‘cblas_ztrmm’中:
cblas_ztrmm.c:(.text+0x118):对‘ztrmm_’未定义的引用
cblas_ztrmm.c:(.text+0x1d6):对‘ztrmm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_ztrsm.o):在函数‘cblas_ztrsm’中:
cblas_ztrsm.c:(.text+0x118):对‘ztrsm_’未定义的引用
cblas_ztrsm.c:(.text+0x1d6):对‘ztrsm_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zsyrk.o):在函数‘cblas_zsyrk’中:
cblas_zsyrk.c:(.text+0xd5):对‘zsyrk_’未定义的引用
/usr/local/lib/libcblas.a(cblas_zsyr2k.o):在函数‘cblas_zsyr2k’中:
cblas_zsyr2k.c:(.text+0xe3):对‘zsyr2k_’未定义的引用
collect2: error: ld returned 1 exit status
CMakeFiles/demo.dir/build.make:96: recipe for target 'demo' failed
make[2]: *** [demo] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/demo.dir/all' failed
make[1]: *** [CMakeFiles/demo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed 
make: *** [all] Error 2

To determine how is the problem brought up, I also tried reproducing the error message with gcc. When compiling with this command :

$ gcc main.c -o demo -lm -lgsl -lcblas -lblas

it works well. When trying :

$ gcc main.c -o demo -lm -lgsl -lcblas # Ignoring BLAS library.

The error message is reproduced. So I guess the problem occurs when linking the BLAS library.

Here is the file main.c

// main.c
#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>
int main(void) {
  double x = 5.0;
  double y;
  y = gsl_sf_bessel_J0(x);
  printf("J0(%.4lf) = %.4le\n", x, y);
  return 0;

The expected outcome would be :

J0(5.0000) = -1.7760e-01
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.