c++ - Error linking clang++ with dlib and intel mkl -


here small program incorporates call intel mkl library function , dlib's optimization routine find_min_using_approximate_derivatives.

the code runs when compiled intel c++ compiler: icpc using invocation:

    icpc main.cpp -i /users/username/code/dlib-18.16 -ddlib_use_blas -i$mklroot/include -l$mklroot/lib/ -lmkl_core -lmkl_intel_thread -lpthread -lm -lmkl_intel_lp64 -denable_dlib -ddlib_use_blas 

or disabling dlib related portion of code via:

clang++ main.cpp -i$mklroot/include -l$mklroot/lib/ -lmkl_core -lmkl_intel_thread -lpthread -lm -lmkl_intel_lp64 

c++ code

    // #define enable_dlib      #ifdef enable_dlib       #include "dlib/optimization.h"     #endif      #include <iostream>     #include <cmath>     #include <cstdio>     #include <cstdlib>     #include "mkl.h"      using namespace std;     #ifdef enable_dlib     using namespace dlib;     #endif      template<typename t>     void printarray(t *data, string name, int len){         cout << name << "\n";         for(int i=0;i<len;i++){             cout << data[i] << " ";         }         cout << "\n";     }      #ifdef enable_dlib     typedef matrix<double,0,1> column_vector;      double rosen (const column_vector& m)     {         const double x = m(0);         const double y = m(1);         return 100.0*pow(y - x*x,2) + pow(1 - x,2);     }     #endif      int main()     {     #ifdef enable_dlib         column_vector starting_point(2);         starting_point = 4, 8;          find_min_using_approximate_derivatives(bfgs_search_strategy(),                                                objective_delta_stop_strategy(1e-7),                                                rosen, starting_point, -1);         cout << "\nbfgs rosen minimum lies at:\n";         cout << "x = " << starting_point(0) << endl;         cout << "y = " << starting_point(1) << endl;     #endif          int len=10;         double *x=new double[len];         double *y=new double[len];         for(int i=0;i<len;i++){             x[i]=(double)std::rand()/rand_max;             y[i]=(double)std::rand()/rand_max;         }         printarray<double>(x, "x", len);         printarray<double>(y, "y", len);          //sum(x)         double x_sum=cblas_dasum(len,x,1);         cout<< "sum(x): "<< x_sum <<"\n";     } 

nevertheless, fails replacing icpc clang++ above multiple errors of following kind:

error

    in file included /opt/intel/composer_xe_2015.3.187/mkl/include/mkl.h:48:     /opt/intel/composer_xe_2015.3.187/mkl/include/mkl_cblas.h:584:6: error: conflicting types 'cblas_cgemm'     void cblas_cgemm(const  cblas_layout layout, const  cblas_transpose transa,          ^     /users/username/code/dlib-18.16/dlib/matrix/matrix_blas_bindings.h:75:18: note: previous declaration here                 void cblas_cgemm(const enum cblas_order order, const enum cblas_transpose transa, 

...suggesting conflict between cblas_* routines mirrored in mkl. documentation dlib suggests using dlib_use_blas preprocessor directive in order link mkl evidently doesn't seem using clang++.

how make work?


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -