davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.51k stars 3.37k forks source link

dlib Enum Naming Conflicts in CBLAS when using caffe #570

Closed Jim61C closed 7 years ago

Jim61C commented 7 years ago

Hi,

I am trying to use caffe and dlib together at the same time. However, whenever I wish to compile using the example "cmake" style. I came to this enum error in the matrix_lu and also several other places.

In file included from /home/yxing1/proj/dlib/dlib/../dlib/svm/../matrix/matrix_lu.h:11:0, from /home/yxing1/proj/dlib/dlib/../dlib/svm/../matrix/matrix_la.h:13, from /home/yxing1/proj/dlib/dlib/../dlib/svm/../matrix.h:11, from /home/yxing1/proj/dlib/dlib/../dlib/svm/ranking_tools.h:9, from /home/yxing1/proj/dlib/dlib/../dlib/svm/svm_rank_trainer.h:8, from /home/yxing1/proj/dlib/dlib/../dlib/svm.h:11, from /home/yxing1/proj/GOTURN_MDNet/src/helper/bounding_box_regressor.h:6, from /home/yxing1/proj/GOTURN_MDNet/src/tracker/tracker_gmd.h:13, from /home/yxing1/proj/GOTURN_MDNet/src/tracker/tracker_gmd.cpp:1: /home/yxing1/proj/dlib/dlib/../dlib/svm/../matrix/matrix_trsm.h:153:24: error: using typedef-name ‘CBLAS_ORDER’ after ‘enum’ const enum CBLAS_ORDER Order, ^ In file included from /home/yxing1/install/caffe-fast-rcnn/include/caffe/util/mkl_alternate.hpp:11:0, from /home/yxing1/install/caffe-fast-rcnn/include/caffe/util/math_functions.hpp:11, from /home/yxing1/install/caffe-fast-rcnn/include/caffe/filler.hpp:13, from /home/yxing1/install/caffe-fast-rcnn/include/caffe/caffe.hpp:9, from /home/yxing1/proj/GOTURN_MDNet/src/network/regressor.h:4, from /home/yxing1/proj/GOTURN_MDNet/src/tracker/tracker.h:10, from /home/yxing1/proj/GOTURN_MDNet/src/tracker/tracker_gmd.h:4, from /home/yxing1/proj/GOTURN_MDNet/src/tracker/tracker_gmd.cpp:1: /usr/include/cblas.h:25:22: note: ‘CBLAS_ORDER’ has a previous declaration here typedef CBLAS_LAYOUT CBLAS_ORDER; /* this for backward compatibility with CBLAS_ORDER */ ^ In file included from /home/yxing1/proj/dlib/dlib/../dlib/svm/../matrix/matrix_lu.h:11:0, from /home/yxing1/proj/dlib/dlib/../dlib/svm/../matrix/matrix_la.h:13, from /home/yxing1/proj/dlib/dlib/../dlib/svm/../matrix.h:11, from /home/yxing1/proj/dlib/dlib/../dlib/svm/ranking_tools.h:9, from /home/yxing1/proj/dlib/dlib/../dlib/svm/svm_rank_trainer.h:8, from /home/yxing1/proj/dlib/dlib/../dlib/svm.h:11, from /home/yxing1/proj/GOTURN_MDNet/src/helper/bounding_box_regressor.h:6, from /home/yxing1/proj/GOTURN_MDNet/src/tracker/tracker_gmd.h:13, from /home/yxing1/proj/GOTURN_MDNet/src/tracker/tracker_gmd.cpp:1: /home/yxing1/proj/dlib/dlib/../dlib/svm/../matrix/matrix_trsm.h:154:18: error: using typedef-name ‘CBLAS_SIDE’ after ‘enum’ enum CBLAS_SIDE Side, ^ In file included from /home/yxing1/install/caffe-fast-rcnn/include/caffe/util/mkl_alternate.hpp:11:0, from /home/yxing1/install/caffe-fast-rcnn/include/caffe/util/math_functions.hpp:11, from /home/yxing1/install/caffe-fast-rcnn/include/caffe/filler.hpp:13, from /home/yxing1/install/caffe-fast-rcnn/include/caffe/caffe.hpp:9, from /home/yxing1/proj/GOTURN_MDNet/src/network/regressor.h:4, from /home/yxing1/proj/GOTURN_MDNet/src/tracker/tracker.h:10, from /home/yxing1/proj/GOTURN_MDNet/src/tracker/tracker_gmd.h:4, from /home/yxing1/proj/GOTURN_MDNet/src/tracker/tracker_gmd.cpp:1: /usr/include/cblas.h:23:46: note: ‘CBLAS_SIDE’ has a previous declaration here typedef enum {CblasLeft=141, CblasRight=142} CBLAS_SIDE;

May I know what exactly is causing this problem? I am able to build the given examples in dlib though. And how do I resolve this, should I go ahead and change all the source files that have this enum issue?

Thanks!

davisking commented 7 years ago

Well, there should be a nice permanent solution. Maybe it's just to take the word enum out from the dlib header files so it doesn't complain about this inconsistent cblas API coming in here and causing this conflict. I don't get this error on any of my systems so it's hard for me to test it.

Jim61C commented 7 years ago

Thanks! That works! May I know what is the use of explicitly declare enum before those variables? As I believe the types of CBLAS_SIDE etc. are defined internally in dlib.

davisking commented 7 years ago

That's just how the syntax for enum usage is in C. I don't really think this should be a compiler error, but maybe C++ allows this to be parsed as ambiguous, I'm not sure. In any case, can you submit the change you made as a pull request? :)

Jim61C commented 7 years ago

I see. Sure!