OS:
[frank@apollo CBLAS]$ uname -a
Linux apollo.leadtek.com.cn 2.6.35.11-83.fc14.i686 #1 SMP Mon Feb 7 07:04:18 UTC 2011 i686 i686 i386 GNU/Linux
从http://www.netlib.org/blas/下载BLAS (cblas.tgz)
根据README内容
$ rm Makefile.in; ln -s Makefile.LINUX Makefile.in
[frank@apollo CBLAS]$ make
( cd src && make all)
make[1]: Entering directory `/home/frank/Downloads/CBLAS/src'
gcc -O3 -DADD_ -I../include -c cblas_srotg.c
gcc -O3 -DADD_ -I../include -c cblas_srotmg.c
gcc -O3 -DADD_ -I../include -c cblas_srot.c
gcc -O3 -DADD_ -I../include -c cblas_srotm.c
gcc -O3 -DADD_ -I../include -c cblas_sswap.c
gcc -O3 -DADD_ -I../include -c cblas_sscal.c
gcc -O3 -DADD_ -I../include -c cblas_scopy.c
gcc -O3 -DADD_ -I../include -c cblas_saxpy.c
gcc -O3 -DADD_ -I../include -c cblas_sdot.c
gcc -O3 -DADD_ -I../include -c cblas_sdsdot.c
gcc -O3 -DADD_ -I../include -c cblas_snrm2.c
gcc -O3 -DADD_ -I../include -c cblas_sasum.c
gcc -O3 -DADD_ -I../include -c cblas_isamax.c
gfortran -O3 -c sdotsub.f
gfortran -O3 -c sdsdotsub.f
gfortran -O3 -c snrm2sub.f
gfortran -O3 -c sasumsub.f
gfortran -O3 -c isamaxsub.f
gcc -O3 -DADD_ -I../include -c cblas_drotg.c
gcc -O3 -DADD_ -I../include -c cblas_drotmg.c
gcc -O3 -DADD_ -I../include -c cblas_drot.c
gcc -O3 -DADD_ -I../include -c cblas_drotm.c
gcc -O3 -DADD_ -I../include -c cblas_dswap.c
gcc -O3 -DADD_ -I../include -c cblas_dscal.c
gcc -O3 -DADD_ -I../include -c cblas_dcopy.c
gcc -O3 -DADD_ -I../include -c cblas_daxpy.c
gcc -O3 -DADD_ -I../include -c cblas_ddot.c
gcc -O3 -DADD_ -I../include -c cblas_dsdot.c
gcc -O3 -DADD_ -I../include -c cblas_dnrm2.c
gcc -O3 -DADD_ -I../include -c cblas_dasum.c
gcc -O3 -DADD_ -I../include -c cblas_idamax.c
gfortran -O3 -c ddotsub.f
gfortran -O3 -c dsdotsub.f
gfortran -O3 -c dnrm2sub.f
gfortran -O3 -c dasumsub.f
gfortran -O3 -c idamaxsub.f
gcc -O3 -DADD_ -I../include -c cblas_cswap.c
gcc -O3 -DADD_ -I../include -c cblas_cscal.c
gcc -O3 -DADD_ -I../include -c cblas_csscal.c
gcc -O3 -DADD_ -I../include -c cblas_ccopy.c
gcc -O3 -DADD_ -I../include -c cblas_caxpy.c
gcc -O3 -DADD_ -I../include -c cblas_cdotu_sub.c
gcc -O3 -DADD_ -I../include -c cblas_cdotc_sub.c
gcc -O3 -DADD_ -I../include -c cblas_icamax.c
gfortran -O3 -c cdotcsub.f
gfortran -O3 -c cdotusub.f
gfortran -O3 -c icamaxsub.f
gcc -O3 -DADD_ -I../include -c cblas_zswap.c
gcc -O3 -DADD_ -I../include -c cblas_zscal.c
gcc -O3 -DADD_ -I../include -c cblas_zdscal.c
gcc -O3 -DADD_ -I../include -c cblas_zcopy.c
gcc -O3 -DADD_ -I../include -c cblas_zaxpy.c
gcc -O3 -DADD_ -I../include -c cblas_zdotu_sub.c
gcc -O3 -DADD_ -I../include -c cblas_zdotc_sub.c
gcc -O3 -DADD_ -I../include -c cblas_dznrm2.c
gcc -O3 -DADD_ -I../include -c cblas_dzasum.c
gcc -O3 -DADD_ -I../include -c cblas_izamax.c
gfortran -O3 -c zdotcsub.f
gfortran -O3 -c zdotusub.f
gfortran -O3 -c dzasumsub.f
gfortran -O3 -c dznrm2sub.f
gfortran -O3 -c izamaxsub.f
gcc -O3 -DADD_ -I../include -c cblas_scasum.c
gfortran -O3 -c scasumsub.f
gcc -O3 -DADD_ -I../include -c cblas_scnrm2.c
gfortran -O3 -c scnrm2sub.f
gcc -O3 -DADD_ -I../include -c cblas_sgemv.c
gcc -O3 -DADD_ -I../include -c cblas_sgbmv.c
gcc -O3 -DADD_ -I../include -c cblas_sger.c
gcc -O3 -DADD_ -I../include -c cblas_ssbmv.c
gcc -O3 -DADD_ -I../include -c cblas_sspmv.c
gcc -O3 -DADD_ -I../include -c cblas_sspr.c
gcc -O3 -DADD_ -I../include -c cblas_sspr2.c
gcc -O3 -DADD_ -I../include -c cblas_ssymv.c
gcc -O3 -DADD_ -I../include -c cblas_ssyr.c
gcc -O3 -DADD_ -I../include -c cblas_ssyr2.c
gcc -O3 -DADD_ -I../include -c cblas_stbmv.c
gcc -O3 -DADD_ -I../include -c cblas_stbsv.c
gcc -O3 -DADD_ -I../include -c cblas_stpmv.c
gcc -O3 -DADD_ -I../include -c cblas_stpsv.c
gcc -O3 -DADD_ -I../include -c cblas_strmv.c
gcc -O3 -DADD_ -I../include -c cblas_strsv.c
gcc -O3 -DADD_ -I../include -c cblas_dgemv.c
gcc -O3 -DADD_ -I../include -c cblas_dgbmv.c
gcc -O3 -DADD_ -I../include -c cblas_dger.c
gcc -O3 -DADD_ -I../include -c cblas_dsbmv.c
gcc -O3 -DADD_ -I../include -c cblas_dspmv.c
gcc -O3 -DADD_ -I../include -c cblas_dspr.c
gcc -O3 -DADD_ -I../include -c cblas_dspr2.c
gcc -O3 -DADD_ -I../include -c cblas_dsymv.c
gcc -O3 -DADD_ -I../include -c cblas_dsyr.c
gcc -O3 -DADD_ -I../include -c cblas_dsyr2.c
gcc -O3 -DADD_ -I../include -c cblas_dtbmv.c
gcc -O3 -DADD_ -I../include -c cblas_dtbsv.c
gcc -O3 -DADD_ -I../include -c cblas_dtpmv.c
gcc -O3 -DADD_ -I../include -c cblas_dtpsv.c
gcc -O3 -DADD_ -I../include -c cblas_dtrmv.c
gcc -O3 -DADD_ -I../include -c cblas_dtrsv.c
gcc -O3 -DADD_ -I../include -c cblas_cgemv.c
gcc -O3 -DADD_ -I../include -c cblas_cgbmv.c
gcc -O3 -DADD_ -I../include -c cblas_chemv.c
gcc -O3 -DADD_ -I../include -c cblas_chbmv.c
gcc -O3 -DADD_ -I../include -c cblas_chpmv.c
gcc -O3 -DADD_ -I../include -c cblas_ctrmv.c
gcc -O3 -DADD_ -I../include -c cblas_ctbmv.c
gcc -O3 -DADD_ -I../include -c cblas_ctpmv.c
gcc -O3 -DADD_ -I../include -c cblas_ctrsv.c
gcc -O3 -DADD_ -I../include -c cblas_ctbsv.c
gcc -O3 -DADD_ -I../include -c cblas_ctpsv.c
gcc -O3 -DADD_ -I../include -c cblas_cgeru.c
gcc -O3 -DADD_ -I../include -c cblas_cgerc.c
gcc -O3 -DADD_ -I../include -c cblas_cher.c
gcc -O3 -DADD_ -I../include -c cblas_cher2.c
gcc -O3 -DADD_ -I../include -c cblas_chpr.c
gcc -O3 -DADD_ -I../include -c cblas_chpr2.c
gcc -O3 -DADD_ -I../include -c cblas_zgemv.c
gcc -O3 -DADD_ -I../include -c cblas_zgbmv.c
gcc -O3 -DADD_ -I../include -c cblas_zhemv.c
gcc -O3 -DADD_ -I../include -c cblas_zhbmv.c
gcc -O3 -DADD_ -I../include -c cblas_zhpmv.c
gcc -O3 -DADD_ -I../include -c cblas_ztrmv.c
gcc -O3 -DADD_ -I../include -c cblas_ztbmv.c
gcc -O3 -DADD_ -I../include -c cblas_ztpmv.c
gcc -O3 -DADD_ -I../include -c cblas_ztrsv.c
gcc -O3 -DADD_ -I../include -c cblas_ztbsv.c
gcc -O3 -DADD_ -I../include -c cblas_ztpsv.c
gcc -O3 -DADD_ -I../include -c cblas_zgeru.c
gcc -O3 -DADD_ -I../include -c cblas_zgerc.c
gcc -O3 -DADD_ -I../include -c cblas_zher.c
gcc -O3 -DADD_ -I../include -c cblas_zher2.c
gcc -O3 -DADD_ -I../include -c cblas_zhpr.c
gcc -O3 -DADD_ -I../include -c cblas_zhpr2.c
gcc -O3 -DADD_ -I../include -c cblas_sgemm.c
gcc -O3 -DADD_ -I../include -c cblas_ssymm.c
gcc -O3 -DADD_ -I../include -c cblas_ssyrk.c
gcc -O3 -DADD_ -I../include -c cblas_ssyr2k.c
gcc -O3 -DADD_ -I../include -c cblas_strmm.c
gcc -O3 -DADD_ -I../include -c cblas_strsm.c
gcc -O3 -DADD_ -I../include -c cblas_dgemm.c
gcc -O3 -DADD_ -I../include -c cblas_dsymm.c
gcc -O3 -DADD_ -I../include -c cblas_dsyrk.c
gcc -O3 -DADD_ -I../include -c cblas_dsyr2k.c
gcc -O3 -DADD_ -I../include -c cblas_dtrmm.c
gcc -O3 -DADD_ -I../include -c cblas_dtrsm.c
gcc -O3 -DADD_ -I../include -c cblas_cgemm.c
gcc -O3 -DADD_ -I../include -c cblas_csymm.c
gcc -O3 -DADD_ -I../include -c cblas_chemm.c
gcc -O3 -DADD_ -I../include -c cblas_cherk.c
gcc -O3 -DADD_ -I../include -c cblas_cher2k.c
gcc -O3 -DADD_ -I../include -c cblas_ctrmm.c
gcc -O3 -DADD_ -I../include -c cblas_ctrsm.c
gcc -O3 -DADD_ -I../include -c cblas_csyrk.c
gcc -O3 -DADD_ -I../include -c cblas_csyr2k.c
gcc -O3 -DADD_ -I../include -c cblas_zgemm.c
gcc -O3 -DADD_ -I../include -c cblas_zsymm.c
gcc -O3 -DADD_ -I../include -c cblas_zhemm.c
gcc -O3 -DADD_ -I../include -c cblas_zherk.c
gcc -O3 -DADD_ -I../include -c cblas_zher2k.c
gcc -O3 -DADD_ -I../include -c cblas_ztrmm.c
gcc -O3 -DADD_ -I../include -c cblas_ztrsm.c
gcc -O3 -DADD_ -I../include -c cblas_zsyrk.c
gcc -O3 -DADD_ -I../include -c cblas_zsyr2k.c
gcc -O3 -DADD_ -I../include -c cblas_globals.c
gcc -O3 -DADD_ -I../include -c cblas_xerbla.c
gcc -O3 -DADD_ -I../include -c xerbla.c
ar r ../lib/cblas_LINUX.a cblas_srotg.o cblas_srotmg.o cblas_srot.o cblas_srotm.o cblas_sswap.o cblas_sscal.o cblas_scopy.o cblas_saxpy.o cblas_sdot.o cblas_sdsdot.o cblas_snrm2.o cblas_sasum.o cblas_isamax.o sdotsub.o sdsdotsub.o snrm2sub.o sasumsub.o isamaxsub.o cblas_drotg.o cblas_drotmg.o cblas_drot.o cblas_drotm.o cblas_dswap.o cblas_dscal.o cblas_dcopy.o cblas_daxpy.o cblas_ddot.o cblas_dsdot.o cblas_dnrm2.o cblas_dasum.o cblas_idamax.o ddotsub.o dsdotsub.o dnrm2sub.o dasumsub.o idamaxsub.o cblas_cswap.o cblas_cscal.o cblas_csscal.o cblas_ccopy.o cblas_caxpy.o cblas_cdotu_sub.o cblas_cdotc_sub.o cblas_icamax.o cdotcsub.o cdotusub.o icamaxsub.o cblas_zswap.o cblas_zscal.o cblas_zdscal.o cblas_zcopy.o cblas_zaxpy.o cblas_zdotu_sub.o cblas_zdotc_sub.o cblas_dznrm2.o cblas_dzasum.o cblas_izamax.o zdotcsub.o zdotusub.o dzasumsub.o dznrm2sub.o izamaxsub.o cblas_scasum.o scasumsub.o cblas_scnrm2.o scnrm2sub.o cblas_sgemv.o cblas_sgbmv.o cblas_sger.o cblas_ssbmv.o cblas_sspmv.o cblas_sspr.o cblas_sspr2.o cblas_ssymv.o cblas_ssyr.o cblas_ssyr2.o cblas_stbmv.o cblas_stbsv.o cblas_stpmv.o cblas_stpsv.o cblas_strmv.o cblas_strsv.o cblas_dgemv.o cblas_dgbmv.o cblas_dger.o cblas_dsbmv.o cblas_dspmv.o cblas_dspr.o cblas_dspr2.o cblas_dsymv.o cblas_dsyr.o cblas_dsyr2.o cblas_dtbmv.o cblas_dtbsv.o cblas_dtpmv.o cblas_dtpsv.o cblas_dtrmv.o cblas_dtrsv.o cblas_cgemv.o cblas_cgbmv.o cblas_chemv.o cblas_chbmv.o cblas_chpmv.o cblas_ctrmv.o cblas_ctbmv.o cblas_ctpmv.o cblas_ctrsv.o cblas_ctbsv.o cblas_ctpsv.o cblas_cgeru.o cblas_cgerc.o cblas_cher.o cblas_cher2.o cblas_chpr.o cblas_chpr2.o cblas_zgemv.o cblas_zgbmv.o cblas_zhemv.o cblas_zhbmv.o cblas_zhpmv.o cblas_ztrmv.o cblas_ztbmv.o cblas_ztpmv.o cblas_ztrsv.o cblas_ztbsv.o cblas_ztpsv.o cblas_zgeru.o cblas_zgerc.o cblas_zher.o cblas_zher2.o cblas_zhpr.o cblas_zhpr2.o cblas_sgemm.o cblas_ssymm.o cblas_ssyrk.o cblas_ssyr2k.o cblas_strmm.o cblas_strsm.o cblas_dgemm.o cblas_dsymm.o cblas_dsyrk.o cblas_dsyr2k.o cblas_dtrmm.o cblas_dtrsm.o cblas_cgemm.o cblas_csymm.o cblas_chemm.o cblas_cherk.o cblas_cher2k.o cblas_ctrmm.o cblas_ctrsm.o cblas_csyrk.o cblas_csyr2k.o cblas_zgemm.o cblas_zsymm.o cblas_zhemm.o cblas_zherk.o cblas_zher2k.o cblas_ztrmm.o cblas_ztrsm.o cblas_zsyrk.o cblas_zsyr2k.o cblas_globals.o cblas_xerbla.o xerbla.o
ar: creating ../lib/cblas_LINUX.a
echo ../lib/cblas_LINUX.a
../lib/cblas_LINUX.a
make[1]: Leaving directory `/home/frank/Downloads/CBLAS/src'
( cd testing && make all )
make[1]: Entering directory `/home/frank/Downloads/CBLAS/testing'
gcc -I../include -O3 -DADD_ -c c_sblas1.c
gfortran -O3 -c c_sblat1.f
gfortran -o xscblat1 c_sblat1.o c_sblas1.o ../lib/cblas_LINUX.a libblas.a
gfortran: libblas.a: No such file or directory
make[1]: *** [xscblat1] Error 1
make[1]: Leaving directory `/home/frank/Downloads/CBLAS/testing'
make: *** [alltst] Error 2
[frank@apollo CBLAS]$
为什么cblas还要编译fortran?
从网站下载fortran77的blas: http://www.netlib.org/blas/blas.tgz
file blas.tgz
for Fortran77 reference implementation of the LEVEL 1, 2, and 3
, BLAS routines in all precisions
, (If only a specific precision or level is desired, please
, see the appropriate section of this index for details.)
prec single, double, complex, doublecomplex
需要安装compat-gcc-34-g77
编译blas, 得到blas_LINUX.a
放到CBLAS/lib/目录中
修改Makefile.in
#BLLIB = libblas.a
BLLIB = ../lib/blas_$(PLAT).a
然后执行make, 即可成功编译
执行"make example"发生错误:
[frank@apollo CBLAS]$ make example
( cd src && make all)
make[1]: Entering directory `/home/frank/Downloads/CBLAS/src'
ar r ../lib/cblas_LINUX.a cblas_srotg.o cblas_srotmg.o cblas_srot.o cblas_srotm.o cblas_sswap.o cblas_sscal.o cblas_scopy.o cblas_saxpy.o cblas_sdot.o cblas_sdsdot.o cblas_snrm2.o cblas_sasum.o cblas_isamax.o sdotsub.o sdsdotsub.o snrm2sub.o sasumsub.o isamaxsub.o cblas_drotg.o cblas_drotmg.o cblas_drot.o cblas_drotm.o cblas_dswap.o cblas_dscal.o cblas_dcopy.o cblas_daxpy.o cblas_ddot.o cblas_dsdot.o cblas_dnrm2.o cblas_dasum.o cblas_idamax.o ddotsub.o dsdotsub.o dnrm2sub.o dasumsub.o idamaxsub.o cblas_cswap.o cblas_cscal.o cblas_csscal.o cblas_ccopy.o cblas_caxpy.o cblas_cdotu_sub.o cblas_cdotc_sub.o cblas_icamax.o cdotcsub.o cdotusub.o icamaxsub.o cblas_zswap.o cblas_zscal.o cblas_zdscal.o cblas_zcopy.o cblas_zaxpy.o cblas_zdotu_sub.o cblas_zdotc_sub.o cblas_dznrm2.o cblas_dzasum.o cblas_izamax.o zdotcsub.o zdotusub.o dzasumsub.o dznrm2sub.o izamaxsub.o cblas_scasum.o scasumsub.o cblas_scnrm2.o scnrm2sub.o cblas_sgemv.o cblas_sgbmv.o cblas_sger.o cblas_ssbmv.o cblas_sspmv.o cblas_sspr.o cblas_sspr2.o cblas_ssymv.o cblas_ssyr.o cblas_ssyr2.o cblas_stbmv.o cblas_stbsv.o cblas_stpmv.o cblas_stpsv.o cblas_strmv.o cblas_strsv.o cblas_dgemv.o cblas_dgbmv.o cblas_dger.o cblas_dsbmv.o cblas_dspmv.o cblas_dspr.o cblas_dspr2.o cblas_dsymv.o cblas_dsyr.o cblas_dsyr2.o cblas_dtbmv.o cblas_dtbsv.o cblas_dtpmv.o cblas_dtpsv.o cblas_dtrmv.o cblas_dtrsv.o cblas_cgemv.o cblas_cgbmv.o cblas_chemv.o cblas_chbmv.o cblas_chpmv.o cblas_ctrmv.o cblas_ctbmv.o cblas_ctpmv.o cblas_ctrsv.o cblas_ctbsv.o cblas_ctpsv.o cblas_cgeru.o cblas_cgerc.o cblas_cher.o cblas_cher2.o cblas_chpr.o cblas_chpr2.o cblas_zgemv.o cblas_zgbmv.o cblas_zhemv.o cblas_zhbmv.o cblas_zhpmv.o cblas_ztrmv.o cblas_ztbmv.o cblas_ztpmv.o cblas_ztrsv.o cblas_ztbsv.o cblas_ztpsv.o cblas_zgeru.o cblas_zgerc.o cblas_zher.o cblas_zher2.o cblas_zhpr.o cblas_zhpr2.o cblas_sgemm.o cblas_ssymm.o cblas_ssyrk.o cblas_ssyr2k.o cblas_strmm.o cblas_strsm.o cblas_dgemm.o cblas_dsymm.o cblas_dsyrk.o cblas_dsyr2k.o cblas_dtrmm.o cblas_dtrsm.o cblas_cgemm.o cblas_csymm.o cblas_chemm.o cblas_cherk.o cblas_cher2k.o cblas_ctrmm.o cblas_ctrsm.o cblas_csyrk.o cblas_csyr2k.o cblas_zgemm.o cblas_zsymm.o cblas_zhemm.o cblas_zherk.o cblas_zher2k.o cblas_ztrmm.o cblas_ztrsm.o cblas_zsyrk.o cblas_zsyr2k.o cblas_globals.o cblas_xerbla.o xerbla.o
echo ../lib/cblas_LINUX.a
../lib/cblas_LINUX.a
make[1]: Leaving directory `/home/frank/Downloads/CBLAS/src'
( cd examples && make all )
make[1]: Entering directory `/home/frank/Downloads/CBLAS/examples'
gcc -c -O3 -DADD_ -I../src -I../include cblas_example1.c
gfortran -o cblas_ex1 cblas_example1.o ../lib/cblas_LINUX.a ../lib/blas_LINUX.a
../lib/blas_LINUX.a(xerbla.o): In function `xerbla_':
xerbla.f:(.text+0xe): undefined reference to `s_wsfe'
xerbla.f:(.text+0x2a): undefined reference to `do_fio'
xerbla.f:(.text+0x46): undefined reference to `do_fio'
xerbla.f:(.text+0x4b): undefined reference to `e_wsfe'
xerbla.f:(.text+0x5d): undefined reference to `s_stop'
collect2: ld returned 1 exit status
make[1]: *** [example1] Error 1
make[1]: Leaving directory `/home/frank/Downloads/CBLAS/examples'
make: *** [example] Error 2
[frank@apollo CBLAS]$
编译时既需要cblas库, 也需要blas fortran库, 将lib/cblas_LINUX.a改为libcblas, 然后执行下面的命令, 即可编译.
$ gcc cblas_example1.c -o test -L../lib -lcblas -lblas -lm
执行testing中的测试程序:
[frank@apollo CBLAS]$ make runtst -i
( cd testing && make run )
make[1]: Entering directory `/home/frank/Downloads/CBLAS/testing'
--> TESTING BLAS 1 - SINGLE PRECISION <--
--> TESTING BLAS 1 - DOUBLE PRECISION <--
--> TESTING BLAS 1 - COMPLEX PRECISION <--
/bin/sh: line 1: 23933 Segmentation fault (core dumped) ./xccblat1 > ctest1.out
make[1]: [run] Error 139 (ignored)
--> TESTING BLAS 1 - DOUBLE COMPLEX PRECISION <--
--> TESTING BLAS 2 - SINGLE PRECISION <--
--> TESTING BLAS 2 - DOUBLE PRECISION <--
--> TESTING BLAS 2 - COMPLEX PRECISION <--
--> TESTING BLAS 2 - DOUBLE COMPLEX PRECISION <--
--> TESTING BLAS 3 - SINGLE PRECISION <--
--> TESTING BLAS 3 - DOUBLE PRECISION <--
--> TESTING BLAS 3 - COMPLEX PRECISION <--
--> TESTING BLAS 3 - DOUBLE COMPLEX PRECISION <--
make[1]: Leaving directory `/home/frank/Downloads/CBLAS/testing'
[frank@apollo CBLAS]$
结论: example中的编译方法需要做修改才能编译. 不知运行结果是否正确, 有时间再研究一下.
CBLAS应该是比较成熟的代码, 为什么我编译的时候会有这么多问题? 是不是因为OS不匹配?