jeudi 9 avril 2020

Undefined reference error when trying to pass reference to vector

I have a method I've defined like this:

int generate(const char* infile, std::vector<uint8_t> &detection, int another_flag);

I wanted detection to be a reference to the vector passed into it (hence the &), so that changes in this method happens to the original and hang around when the method exits.

I'm calling it like this:

    const char* infile = argv[1];
    std::vector<uint8_t> detection;
    int ret;
    ret = generate(infile, detection, 0); 

But it won't compile, and complains:

undefined reference to `generate(char const*, std::vector<unsigned char, std::allocator<unsigned char> >&, int)'

How should I be doing it?

Aucun commentaire:

Enregistrer un commentaire