im trying to call a c++ template function in objective c that looks like this:
template<typename T>
void test() {
...
std::cout << "hello world! \n";
}
Im getting the following error with calling test() :
Undefined symbols for architecture armv7:
"test()", referenced from:
-[viewController onNext] in ViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
if i take out template<typename T> it works fine, however, i need to use some functions from a c++ library that require templates and i cant get around it. any idea on whats happening?
I have no experience with c++ what so ever…
In C++, when you call a templated function, if the template parameter (i.e. T in your code) can’t be deduced from the parameter passed to the function (which is your case since your function doesn’t have any parameter), you shall call the function like this:
test< someType >();