问题
I encountered the following error when I tried to compile affdex sdk sample applications
Linking CXX executable video-demo
CMakeFiles/video-demo.dir/video-demo.cpp.o: In function 'main':
video-demo.cpp:(.text+0x11cb): undefined reference to
affdex::VideoDetector::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
collect2: error: ld returned 1 exit status
I'm using GCC 5.2.1
回答1:
My initial suspicion was that the problem is attempting to compile the apps using a newer GCC or rather GLIBCXX than what the sdk is compiled with (gcc v4.8).
The error msg refers to an undefined function that the compiler is unable to find ..
undefined reference to `affdex::VideoDetector::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
The problem here is actually the type definition of the parameter (an std::string) .. the compiler is looking for:
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
But, the actual definition type of parameter in the compiled library is..
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
As it turns out, GCC 5 introduced new implementations of std::string and std::list. You can try the workaround here to see if you can get the linking process to complete successfully, but the safest option is to fall back to using GCC 4.8.
Note, GCC 4.8 can be retrieved from ubuntu repos ..
来源:https://stackoverflow.com/questions/37004976/undefined-reference-to-processstd-cxx11basic-string-when-compiling-a