I have a class called Metadata, which is declared within the namespace A::B::C, which also contains the struct copyInfo, which holds the info about a metadata.
So, Metadata has only its default contructor / destructor, and when I try to use a member function from Metadata called
importMetadata(vector<copyInfo> &info, const string &src, const string &dst, const int &job:
I’m getting the following error:
import_helper.cpp:(.text+0x246): undefined reference to
A::B::C::Metadata::importMetadata(std::vector<A::B::C::copyInfo, std::allocator<A::B::C::copyInfo> >&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int const&)
namespace A{
namespace B{
namespace C{
class Metadata{
Metadata();
~Metadata();
importMetadata(vector<copyInfo> &seq, const string &src,
const string &dst, const int &job);
/* more code down here */
};
}
}
}
Now, in Metadata I have:
That function is being called from a wrapper c++ function called wrapperMetadataImport, which belongs to import_helper.cpp.
#include "Metadata.h"
using namespace A::B::C;
int wrapperMetadataImport(const char * src, const char * dest, const int * jobid){
Metadata mtd;
string src = srcName;
string dest = destName;
vector<copyInfo> sequence;
/* add elemens to the vector sequence */
if((ret = mtd.importMetadata(sequence,
src, dest, *jobid)) == EC_success){
/* more code down here */
I have no clue why I’m getting that. I have checked the .h and .cpp file, everything sounds ok to me. I suppose it’s a runtime linking problem. The namespacing should be as is: A::B::C. Any thoughts?
This is a linker error, and indicates that the implementation of the function can’t be found. Either you haven’t written the function, or you haven’t included the source file containing it in your build.
You have declared it in the class definition, but without a full definition the function can’t be called.