I am attempting to use the following method in a class and compile a library with the classes for use in ROOT later.
/**Checks the provided expression by use of a TTreeFormula.
*
* \param[in] expr The expression to check.
* \return True if valid.
*/
bool ClassName::ValidEvtExpr(const std::string &expr) {
TTreeFormula formula("ExprTest", expr.c_str(), tree_);
if (formula.GetNdim() == 0) return false;
return true;
}
The compilation is successful, but I receive the following error message at linking:
[100%] Linking CXX shared library libLibrary.dylib
Undefined symbols for architecture x86_64:
"TTreeFormula::TTreeFormula(char const*, char const*, TTree*)", referenced from:
ClassName::ValidEvtExpr(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in ClassName.cpp.o
"TTreeFormula::~TTreeFormula()", referenced from:
ClassName::ValidEvtExpr(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in ClassName.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [source/libLibrary.dylib] Error 1
make[1]: *** [source/CMakeFiles/Library.dir/all] Error 2
make: *** [all] Error 2
I am compiling on Mac OS 10.12, with ROOT 6.08.06 compiled on the local machine, cmake 3.7.2 and clang-802.0.38.