flappie icon indicating copy to clipboard operation
flappie copied to clipboard

Compilation errors: layers.c collect2: ld returned 1 exit; "undefined reference to `cblas_sgemv'"

Open Rashadx86 opened this issue 6 years ago • 12 comments

Hi flappie community,

I'm getting compilation errors when compiling on CentOS6.8 servers with errors referring to cblas_*. Here is the compiler output:

[rahmed@cel flappie]$ make flappie
cd build && \
	cmake .. -DCMAKE_BUILD_TYPE=Release && \
	make
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rahmed/cunit/flappie/build
make[1]: Entering directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
make[2]: Entering directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
make[3]: Entering directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
make[3]: Leaving directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
[ 39%] Built target flappie_objects
make[3]: Entering directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
make[3]: Leaving directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
[ 43%] Built target flappie_static
make[3]: Entering directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
make[3]: Leaving directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
make[3]: Entering directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
[ 47%] Linking C executable flappie
CMakeFiles/flappie.dir/src/fast5_interface.c.o: In function `set_compression':
fast5_interface.c:(.text+0x34e): undefined reference to `H5P_CLS_DATASET_CREATE_ID_g'
CMakeFiles/flappie.dir/src/fast5_interface.c.o: In function `write_trace':
fast5_interface.c:(.text+0xfc5): undefined reference to `H5P_CLS_DATASET_CREATE_ID_g'
CMakeFiles/flappie.dir/src/fast5_interface.c.o: In function `write_signal':
fast5_interface.c:(.text+0x113e): undefined reference to `H5P_CLS_DATASET_CREATE_ID_g'
libflappie.a(layers.c.o): In function `lstm_step':
layers.c:(.text+0x21c): undefined reference to `cblas_sgemv'
libflappie.a(layers.c.o): In function `gru_step':
layers.c:(.text+0x7c4): undefined reference to `cblas_sgemv'
layers.c:(.text+0x98f): undefined reference to `cblas_sgemv'
layers.c:(.text+0xb61): undefined reference to `cblas_sgemv'
libflappie.a(layers.c.o): In function `grumod_step':
layers.c:(.text+0xdda): undefined reference to `cblas_sgemv'
libflappie.a(layers.c.o):layers.c:(.text+0x2294): more undefined references to `cblas_sgemv' follow
libflappie.a(layers.c.o): In function `convolution':
layers.c:(.text+0x3010): undefined reference to `cblas_sgemm'
layers.c:(.text+0x3172): undefined reference to `cblas_sgemv'
libflappie.a(flappie_matrix.c.o): In function `affine_map2':
flappie_matrix.c:(.text+0x169a): undefined reference to `cblas_sgemm'
flappie_matrix.c:(.text+0x16fa): undefined reference to `cblas_sgemm'
libflappie.a(flappie_matrix.c.o): In function `affine_map':
flappie_matrix.c:(.text+0x1833): undefined reference to `cblas_sgemm'
collect2: ld returned 1 exit status
make[3]: *** [flappie] Error 1
make[3]: Leaving directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
make[2]: *** [CMakeFiles/flappie.dir/all] Error 2
make[2]: Leaving directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/pbtech_mounts/homes024/rahmed/cunit/flappie/build'
make: *** [build/flappie] Error 2

flappie was cloned with git-lfs with cblas.h present in system library locations as well as openblas, openblas-devel for good measure.

The versions of the dependencies used are: cmake: 3.11.2 cunit: 2.1.3 hdf5: 1.10.2 openblas: 0.2.20

openmpi was loaded after previous errors and that resolved a previous error that is now good. I also tried compiling with glibc2.14 as some lines in the "LD_DEBUG=all make flappie" error log looked like that might have been the culprit. That didn't help either.

Here is the "LD_DEBUG=all make flappie" cmake log. It's quite large.

CMakeOutput.log

The "undefined reference" errors lead me to suspect that there may be some missing files that weren't downloaded. Any help is appreciated.

Thanks, Rashad

Rashadx86 avatar Dec 04 '18 16:12 Rashadx86

I'll investigate further later but the undefined reference are due to not being linked against a library with the cblas interface compiled in. This is a BLAS issue rather than a Flappie issue.

tmassingham-ont avatar Dec 05 '18 17:12 tmassingham-ont

Use -lopenblas instead of -lblas.

ahcm avatar Dec 05 '18 20:12 ahcm

Thank you. I'll leave this issue until I've the updated the documentation.

tmassingham-ont avatar Dec 06 '18 15:12 tmassingham-ont

I have a similar issue here. Although openblas is installed in /usr/include/openblas, I cannot compile it. The first error message (cblas.h No such file or directory) I could fix by replacing the lines in src/layers.c & src/flappie_matrix.c by # include "/usr/include/openblas/cblas.h" However, when I execute make flappie, I get the error:

[ 69%] Built target flappie_objects
[ 76%] Built target flappie_static
[ 84%] Linking C executable flappie
libflappie.a(layers.c.o): In function `convolution':
layers.c:(.text+0x10ae): undefined reference to `cblas_sgemv'
layers.c:(.text+0x122d): undefined reference to `cblas_sgemm'
layers.c:(.text+0x1392): undefined reference to `cblas_sgemv'
libflappie.a(layers.c.o): In function `gru_step':
layers.c:(.text+0x1820): undefined reference to `cblas_sgemv'
layers.c:(.text+0x19d3): undefined reference to `cblas_sgemv'
layers.c:(.text+0x1ffb): undefined reference to `cblas_sgemv'
libflappie.a(layers.c.o): In function `grumod_step':
layers.c:(.text+0x2593): undefined reference to `cblas_sgemv'
libflappie.a(layers.c.o):layers.c:(.text+0x3350): more undefined references to `cblas_sgemv' follow
libflappie.a(flappie_matrix.c.o): In function `affine_map':
flappie_matrix.c:(.text+0xd52): undefined reference to `cblas_sgemm'
libflappie.a(flappie_matrix.c.o): In function `affine_map2':
flappie_matrix.c:(.text+0xe72): undefined reference to `cblas_sgemm'
flappie_matrix.c:(.text+0xed4): undefined reference to `cblas_sgemm'
collect2: error: ld returned 1 exit status
make[3]: *** [flappie] Error 1
make[2]: *** [CMakeFiles/flappie.dir/all] Error 2
make[1]: *** [CMakeFiles/flappie.dir/rule] Error 2
make: *** [flappie] Error 2

sarah872 avatar Dec 07 '18 17:12 sarah872

Hello. This looks like a similar error to that originally reported. Which platform are you using please?

It looks like the failing to find the cblas_* functions in the BLAS library being linked against. As suggested by @ahcm, could you try changing line 65 of CMakeLists.txt from set (BLAS "blas") to set (BLAS "openblas") please?

tmassingham-ont avatar Dec 08 '18 19:12 tmassingham-ont

Platform: CentOS Linux 7 (Core)

Applying the suggested change in line 65 plus the modifications in src/layers.c & src/flappie_matrix.c worked! Thanks!

sarah872 avatar Dec 08 '18 19:12 sarah872

With the newest version I am there is a new error:

[ 56%] Linking C executable flappie
make[3]: Leaving directory `/scratch/user/flappy/flappie/build'
[ 56%] Built target flappie
make[3]: Entering directory `/scratch/user/flappy/flappie/build'
Scanning dependencies of target flappie_unittest
make[3]: Leaving directory `/scratch/user/flappy/flappie/build'
make[3]: Entering directory `/scratch/user/flappy/flappie/build'
[ 60%] Building C object CMakeFiles/flappie_unittest.dir/src/test/flappie_test_runner.c.o
/scratch/user/flappy/flappie/src/test/flappie_test_runner.c:11:25: fatal error: CUnit/Basic.h: No such file or directory
 #include <CUnit/Basic.h>
                         ^
compilation terminated.
make[3]: *** [CMakeFiles/flappie_unittest.dir/src/test/flappie_test_runner.c.o] Error 1
make[3]: Leaving directory `/scratch/user/flappy/flappie/build'
make[2]: *** [CMakeFiles/flappie_unittest.dir/all] Error 2
make[2]: Leaving directory `/scratch/user/flappy/flappie/build'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/scratch/user/flappy/flappie/build'
make: *** [build/flappie] Error 2

sarah872 avatar Jan 26 '19 10:01 sarah872

Hello @sarah872 This is to do with the unit testing library 'Cunit' not being installed but this should only be necessary for testing, not running. I've pushed change so the testing is not built by default.

I've also fixed an addition potential problem, where the HDF5 library cannot be found. On my machine the library and header file is install under /usr/local and compilation is like:

hdf5Root=/usr/local/ make flappie

tmassingham-ont avatar Feb 01 '19 13:02 tmassingham-ont

Thanks, it worked now. Not sure if this is related, but will flappie support multi-read fast5 files in the future?

sarah872 avatar Feb 01 '19 15:02 sarah872

Multi-read support for Flappie will come eventually but, since it is a research tool rather than a product, this isn’t a priority. Features proto-typed in Flappie will eventually be released into Guppy, which is our production basecaller, and this does support multi-read fast5.

There is a script available in the ont_fast5_api package (conversion_tools/multi_to_single_fast5.py) to convert a multi-read file into the old-style single-read files that are supported.

tmassingham-ont avatar Feb 01 '19 15:02 tmassingham-ont

I think I have similar issue:

[ 84%] Linking C executable flappie
/usr/bin/ld: cannot find -lblas
collect2: ld returned 1 exit status
make[4]: *** [flappie] Error 1

Any clue how to fix it?

MeHelmy avatar Jun 07 '19 15:06 MeHelmy

Use ccmake, instead of just cmake, google to advanced mode with t, then edit CMAKE_EXE_LINKER_FLAGS and add -lopenblas, like: CMAKE_EXE_LINKER_FLAGS -lopenblas

ahcm avatar Aug 17 '19 09:08 ahcm