虚函数 error LNK2001: 无法解析的外部符号 "public: virtual void __cdecl

时间:2024-08-06 10:04:32

在虚函数后面加一对大括号

#ifndef CAFFE_CONV_DW_LAYER_HPP_
#define CAFFE_CONV_DW_LAYER_HPP_ #include <vector>
#include "caffe/blob.hpp"
#include "caffe/layer.hpp"
#include "caffe/proto/caffe.pb.h" namespace caffe { template <typename Dtype>
class ConvolutionDepthwiseLayer : public Layer<Dtype> {
public:
explicit ConvolutionDepthwiseLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top){};
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top){};
virtual inline int ExactNumBottomBlobs() const { return ; }
virtual inline int ExactNumTopBlobs() const { return ; }
virtual inline const char* type() const { return "ConvolutionDepthwise"; }
protected:
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top){};
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top){};
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom){};
unsigned int kernel_h_;
unsigned int kernel_w_;
unsigned int stride_h_;
unsigned int stride_w_;
unsigned int pad_h_;
unsigned int pad_w_;
unsigned int dilation_h_;
unsigned int dilation_w_;
Blob<Dtype> weight_buffer_;
Blob<Dtype> weight_multiplier_;
Blob<Dtype> bias_buffer_;
Blob<Dtype> bias_multiplier_;
}; } // namespace caffe #endif // CAFFE_CONV_DW_LAYER_HPP_

$ sudo make pycaffe   出错
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
python/caffe/_caffe.cpp:10:31: fatal error: numpy/arrayobject.h: No such file or directory
compilation terminated.
Makefile:502: recipe for target 'python/caffe/_caffe.so' failed
make: *** [python/caffe/_caffe.so] Error 1

Makefile.config  中   加local

PYTHON_INCLUDE := /usr/include/python2. \
/usr/local/lib/python2./dist-packages/numpy/core/include
#/usr/lib/python2./dist-packages/numpy/core/include

重新 make pycaffe 就可以了