Undefined reference to process(std::__cxx11::basic_string … ) when compiling affdex linux sample applications

折月煮酒 提交于 2019-11-27 02:24:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!