ekiwi / cs267-tutorials

Materials to help you with the cs267 homework.
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Make error: undefined reference to `dgemm_' #2

Open Bagoum opened 5 years ago

Bagoum commented 5 years ago

make works on Cori but when I run it on vagrant or WSL I get the following output:


rm -f benchmark-naive benchmark-blocked benchmark-blas benchmark.o dgemm-naive.o dgemm-blocked.o dgemm-blas.o
cc  -c -Wall -std=gnu99 -O2 benchmark.c
cc  -c -Wall -std=gnu99 -O2 dgemm-naive.c
cc  -o benchmark-naive benchmark.o dgemm-naive.o -lrt
benchmark.o: In function `reference_dgemm':
benchmark.c:(.text+0x93): undefined reference to `dgemm_'
collect2: error: ld returned 1 exit status
Makefile:31: recipe for target 'benchmark-naive' failed
make: *** [benchmark-naive] Error 1```
Bagoum commented 5 years ago

Workaround that works on WSL and vagrant:

Install gfortran.

Download blas from here: http://www.netlib.org/blas/#_software

In the blas folder, run make, it should give you a blas_LINUX.a file. Put this in the folder {hw1}/lib.

Change the LDLIBS line of the hw1 makefile to: LDLIBS = -lrt -L lib -l:blas_LINUX.a -lgfortran.

make should work with this.

ekiwi commented 5 years ago

Just adding -lblas to explicitly link against the blas library should work.

ArjunNarayanan commented 5 years ago

Just adding -lblas to explicitly link against the blas library should work.

This worked for me.

Specifically, I edited the Makefile to

LDLIBS = -lrt -lblas
ekiwi commented 5 years ago

The latest hw1 files should contain a new Makefile that automatically selects the right flags for gcc and icc. Try redownloading the homework files and replacing your Makefile.