xtensor-blas icon indicating copy to clipboard operation
xtensor-blas copied to clipboard

compiling error undefined reference to `cblas_ddot' etc

Open mfouesneau opened this issue 4 years ago • 3 comments

I ported my code working fine on my laptop (mac) to a Linux machine.

However I cannot compile the code and get many undefined reference error related to cblas_...

on the machine that works (it uses clang) g++ -I. -std=c++1y -O3 -I./include -lhdf5 -o main ./main.cpp -framework Accelerate this works fine.

but on the Linux machine what I thought the equivalent would be does not work

g++ -I. -std=c++1y -O3 -I./include -lhdf5 -o main ./main.cpp -llapack -lblas -lm undefined reference to `cblas_ddot'

/tmp/ccyLIeC0.o: In function `auto xt::linalg::dot<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>, xt::xstrided_view<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, (xt::layout_type)0, xt::detail::inner_storage_getter<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&> > >(xt::xexpression<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag> > const&, xt::xexpression<xt::xstrided_view<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, (xt::layout_type)0, xt::detail::inner_storage_getter<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<unsigned long, 4ul, std::allocator<unsigned long>, true>, xt::xtensor_expression_tag>&> > > const&)':
main.cpp:(.text._ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE[_ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE]+0x64b): undefined reference to `cblas_ddot'
main.cpp:(.text._ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE[_ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE]+0x1009): undefined reference to `cblas_dgemv'
main.cpp:(.text._ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE[_ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE]+0x121e): undefined reference to `cblas_dgemm'
main.cpp:(.text._ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE[_ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE]+0x14f6): undefined reference to `cblas_dgemv'
main.cpp:(.text._ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE[_ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE]+0x1800): undefined reference to `cblas_dsyrk'
main.cpp:(.text._ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE[_ZN2xt6linalg3dotINS_16xarray_containerINS_7uvectorIdSaIdEEELNS_11layout_typeE1ENS_7svectorImLm4ESaImELb1EEENS_22xtensor_expression_tagEEENS_13xstrided_viewIRSB_S9_LS6_0ENS_6detail20inner_storage_getterISD_EEEEEEDaRKNS_11xexpressionIT_EERKNSI_IT0_EE]+0x1a39): undefined reference to `cblas_ddot'
collect2: error: ld returned 1 exit status

Any obvious thing I'm doing wrong? thanks in advance

mfouesneau avatar Jun 09 '20 15:06 mfouesneau

You might have to reorder your -l linker flags?

wolfv avatar Jun 10 '20 06:06 wolfv

It's not like xt is part of that and linked first?

I tried multiple and it did not work better

mfouesneau avatar Jun 10 '20 06:06 mfouesneau

the symbols that are undefined are part of BLAS. So if you link to a correct blas implementation, these symbols should be defined.

Maybe change the order of lapack and blas?

wolfv avatar Jun 10 '20 10:06 wolfv