1,以Visual Studio为例
2,下载CLAPACK的包,地址
3,打开cmake设置生成编译文件,步骤如官方图示
4,按照上图生成的编译文件,打开visual studio编译,会生成几个lib文件,默认会在 C:Program Files (x86)CLAPACK下找到
5,新建一个项目,用下面的测试代码
1 #include < stdio.h> 2 #include "f2c.h" 3 #include "clapack.h" 4 5 int 6 main(void) 7 { 8 /* 3x3 matrix A 9 * 76 25 11 10 * 27 89 51 11 * 18 60 32 12 */ 13 doublereal A[9] = {76, 27, 18, 25, 89, 60, 11, 51, 32}; 14 doublereal b[3] = {10, 7, 43}; 15 16 integer N = 3; 17 integer nrhs = 1; 18 integer lda = 3; 19 integer ipiv[3]; 20 integer ldb = 3; 21 integer info; 22 23 dgesv_(&N, &nrhs, A, &lda, ipiv, b, &ldb, &info); 24 25 if(info == 0) /* succeed */ 26 printf("The solution is %lf %lf %lf ", b[0], b[1], b[2]); 27 else 28 fprintf(stderr, "dgesv_ fails %d ", info); 29 30 31 return info; 32 }
6,打开属性设置,将生成的.h头文件路径输入到C/C++ -> 常规 ->附加包含目录中
lib文件路径输入到 链接器 ->常规 ->附加库目录
7,将需要的lib名输入到链接器的附加依赖项,注意debug和release模式下名称相差一个d!
8,运行可得结果!