xtensor-stack / xtensor-blas

BLAS extension to xtensor
BSD 3-Clause "New" or "Revised" License
157 stars 55 forks source link

compiling error undefined reference to `cblas_ddot' etc #166

Open mfouesneau opened 4 years ago

mfouesneau commented 4 years ago

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

wolfv commented 4 years ago

You might have to reorder your -l linker flags?

mfouesneau commented 4 years ago

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

I tried multiple and it did not work better

wolfv commented 4 years ago

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?