计算化学公社

 找回密码 Forget password
 注册 Register
Views: 3627|回复 Reply: 3
打印 Print 上一主题 Last thread 下一主题 Next thread

[make相关] 调用cblas makefile 怎么写?

[复制链接 Copy URL]

93

帖子

0

威望

415

eV
积分
508

Level 4 (黑子)

跳转到指定楼层 Go to specific reply
楼主
我的makefile如下
CXX=g++
CFLAGS= -O3
GF=gfortran
BLLIB=lib/libblas.a
CBLIB=lib/cblas_LINUX.a
Objects=Main.o\
        Matrix.o\

mycode:$(Objects)
                $(CXX) $(CFLAGS) -o mycode $(Objects)
Main.o:Main.cpp
                $(CXX) $(CFLAGS) -c Main.cpp -o Main.o
Matrix:Matrix.cpp Matrix.h
                $(CXX) $(CFLAGS) -c -Iinclude Matrix.cpp
                gfortran -o cblas Matrix.o $(CBLIB) $(BLLIB)

请问怎么正确链接cblas的静态库?用上面的makefile编译得到以下的错误提示:
g++ -O3 -o mycode Main.o Matrix.o
Matrix.o: In function `CMatrix::operator*(CMatrix const&) const':
Matrix.cpp:(.text+0xbb8): undefined reference to `cblas_dgemm'
collect2: error: ld returned 1 exit status
Makefile:10: recipe for target 'mycode' failed

文件说明:
cblas.h 在 ./include/
cblas_LINUX.a 和libblas.a在 ./lib/
其他cpp文件和makefile 文件在 ./

174

帖子

0

威望

5199

eV
积分
5373

Level 6 (一方通行)

2#
发表于 Post on 2019-3-19 14:58:41 | 只看该作者 Only view this author
当成.o文件直接写在后面即可,
$(CBLIB) $(BLLIB) => $(CBLIB)/cblas_LINUX.a  $(BLLIB)/libblas.a

93

帖子

0

威望

415

eV
积分
508

Level 4 (黑子)

3#
 楼主 Author| 发表于 Post on 2019-3-19 15:36:08 | 只看该作者 Only view this author
bluewhale 发表于 2019-3-19 14:58
当成.o文件直接写在后面即可,
$(CBLIB) $(BLLIB) => $(CBLIB)/cblas_LINUX.a  $(BLLIB)/libblas.a

谢谢。但是我的BLLIB 和CBLIB已经制定了静态库,不只是路径。

93

帖子

0

威望

415

eV
积分
508

Level 4 (黑子)

4#
 楼主 Author| 发表于 Post on 2019-3-19 20:26:40 | 只看该作者 Only view this author
调通了。
改成一下即可。
CXX=g++
CFLAGS= -O3
GF=gfortran
BLLIB=lib/libblas.a
CBLIB=lib/cblas_LINUX.a
Objects=Main.o\
        Matrix.o\

mycode:$(Objects)
                $(CXX) $(CFLAGS) -o mycode $(Objects) $(CBLIB) $(BLLIB)
Main.o:Main.cpp
                $(CXX) $(CFLAGS) -c Main.cpp -o Main.o
Matrix:Matrix.cpp Matrix.h
                $(CXX) $(CFLAGS) -c -Iinclude Matrix.cpp
              

本版积分规则 Credits rule

手机版 Mobile version|北京科音自然科学研究中心 Beijing Kein Research Center for Natural Sciences|京公网安备 11010502035419号|计算化学公社 — 北京科音旗下高水平计算化学交流论坛 ( 京ICP备14038949号-1 )|网站地图

GMT+8, 2025-8-13 19:04 , Processed in 0.153516 second(s), 20 queries , Gzip On.

快速回复 返回顶部 返回列表 Return to list