lundi 2 juillet 2018

Why is std::string and std::vector not being passed to my constructor how I would expect?

This is my error when trying to compile:

Undefined symbols for architecture x86_64:
    "Model::Model(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<int, std::__1::allocator<int> >)", referenced from: ____C_A_T_C_H____T_E_S_T____4() in tests.cpp.o

I have read that std::string is a typedef of std::basic_string and I'm guess that std::vector is a typedef of... std::vector and std::allocator? or something...

Anyway. I have a Settings class that holds my settings and a Model class that contains my model. The code I am attempting to run is as below, and I am unable to compile it. the issue is with it not recognising my model constructor.

Settings s = Settings("../config/settings.json");
std::string mf = s.get_model_file();
std::vector<int> vec = s.get_input_shape();
Model m = Model(mf, vec);

For reference here is my Model class header:

class Model {
public:
  Model(std::string model_file, std::vector<int> input_shape);
  ~Model();
  double* get_ref_to_input_buffer();
  std::string predict();

private:
  std::string _model_file;
  fdeep::model _model;

  fdeep::shape3 _input_shape;
  int _input_size;
  double* _input_buffer;
  fdeep::tensor3s _result;

  void _load_model();
  void _set_input_size(std::vector<int> input_shape);
  void _set_input_shape(std::vector<int> input_shape);
  void _create_input_buffer();
  std::string _result_to_string();
};

and my Model class constructor:

Model::Model(std::string model_file, std::vector<int> input_shape)
    : _model(fdeep::load_model(model_file)),
    _input_shape(fdeep::shape3(_input_shape)){
}

If anyone could point out where I'm going wrong or send me in the direction of what I need to read / learn that would be great. Thank you!

Aucun commentaire:

Enregistrer un commentaire