今天编译caffe-ssd遇到编译错误:

1   Line 9690: 3>E:GitHubcaffe-ssd-windowssrccaffelayer_factory.cpp(141): error C2061: syntax error: identifier 'SliceLayer'
2     Line 9690: 3>E:GitHubcaffe-ssd-windowssrccaffelayer_factory.cpp(141): error C2061: syntax error: identifier 'SliceLayer'
3     Line 9696: 3>E:GitHubcaffe-ssd-windowssrccaffelayer_factory.cpp(262): error C2061: syntax error: identifier 'NormalizeLayer'
4     Line 9696: 3>E:GitHubcaffe-ssd-windowssrccaffelayer_factory.cpp(262): error C2061: syntax error: identifier 'NormalizeLayer'
5     Line 9702: 3>E:GitHubcaffe-ssd-windowssrccaffelayer_factory.cpp(272): error C2061: syntax error: identifier 'InnerProductLayer'
6     Line 9702: 3>E:GitHubcaffe-ssd-windowssrccaffelayer_factory.cpp(272): error C2061: syntax error: identifier 'InnerProductLayer'
7     Line 10141: 4>LINK : fatal error LNK1104: cannot open file '..libDebugcaffe-d.lib'

经查,是下面文件里没有添加上面对应的三个头文件。

Caffe编译错误整理

 

 

添加下面三行到layer_factory.cpp:

#include "caffe/layers/slice_layer.hpp"
#include "caffe/layers/normalize_layer.hpp"
#include "caffe/layers/inner_product_layer.hpp"

再次编译,报错:

E:GitHubcaffe-ssd-windowssrccaffelayer_factory.cpp(265): error C2955: 'caffe::NormalizeLayer': use of class template requires template argument list
E:GitHubcaffe-ssd-windowsincludecaffe/layers/normalize_layer.hpp(18): note: see declaration of 'caffe::NormalizeLayer'
E:GitHubcaffe-ssd-windowssrccaffelayer_factory.cpp(267): note: see reference to function template instantiation 'boost::shared_ptr<caffe::Layer<Dtype>> caffe::GetNormalizeLayer<float>(const caffe::LayerParameter &)' being compiled
 with
 [
 Dtype=float
 ]
E:GitHubcaffe-ssd-windowssrccaffelayer_factory.cpp(265): error C2514: 'caffe::NormalizeLayer': class has no constructors
E:GitHubcaffe-ssd-windowsincludecaffe/layers/normalize_layer.hpp(18): note: see declaration of 'caffe::NormalizeLayer'
E:GitHubcaffe-ssd-windowssrccaffelayer_factory.cpp(275): error C2514: 'caffe::InnerProductLayer': class has no constructors

查找原因:

 return shared_ptr<Layer<Dtype> >(new NormalizeLayer(param));

改为(添加了<Dtype>):

return shared_ptr<Layer<Dtype> >(new NormalizeLayer<Dtype>(param));

将:

return shared_ptr<Layer<Dtype> >(new InnerProductLayer(param));

改为(添加了<Dtype>):

return shared_ptr<Layer<Dtype> >(new InnerProductLayer<Dtype>(param));

然后就编译通过了。