vendredi 3 juin 2016

Shared methods split declared in header and defined in cpp file

I'm working on writing a library and I'm using another library within it (linking it). I have some shared methods, one being 'compare' for example. When I declare and define this compare method in the header using

 bool Compare(std::string s1, std::string s2, bool ignoreCase)

and then in the .cpp file using

 bool Compare(std::string s1, std::string s2, 
 bool ignoreCase){...}

this .cpp file also includes the corresponding header file. However, when test my library I'm getting:

./main: symbol lookup error: /..path to .so file/libmylibrary.so.0: undefined symbol: _Z7CompareSsSsb error.

I've tried declaring and defining within the header file using

inline bool Compare(std::string s1, std::string s2, bool ignoreCase){...}`, 

which compiled and then worked fine when I tested it. I've also used make clean during automake a few times, but I still keep getting the same error.

Any tips or suggestions would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire