patrikhuber / 4dface

Real-time 3D face tracking and reconstruction from 2D video
https://www.4dface.io
Apache License 2.0
793 stars 248 forks source link

Compilation error: Opencv undefined reference #19

Closed DatHuynh closed 7 years ago

DatHuynh commented 7 years ago

I follow the build&run process exactly on Ubuntu 16.04 and encounter the following error when execute the command in build folder:

make

Appreciate any help.

[ 50%] Building CXX object CMakeFiles/4dface.dir/apps/4dface.cpp.o
[100%] Linking CXX executable 4dface
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `cv::String::String(char const*) [clone .constprop.2718]':
4dface.cpp:(.text+0x1c69): undefined reference to `cv::String::allocate(unsigned long)'
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `cv::Mat::Mat(int, int, int, void*, unsigned long) [clone .constprop.2716]':
4dface.cpp:(.text+0x1d6a): undefined reference to `cv::String::allocate(unsigned long)'
4dface.cpp:(.text+0x1db7): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
4dface.cpp:(.text+0x1dbf): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text+0x1dec): undefined reference to `cv::String::deallocate()'
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `draw_wireframe(cv::Mat, eos::render::Mesh const&, glm::tmat4x4<float, (glm::precision)0>, glm::tmat4x4<float, (glm::precision)0>, glm::tvec4<float, (glm::precision)0>, cv::Scalar_<double>)':
4dface.cpp:(.text+0x29e0): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
4dface.cpp:(.text+0x2a84): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
4dface.cpp:(.text+0x2b05): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `rcr::draw_landmarks(cv::Mat, cv::Mat, cv::Scalar_<double>)':
4dface.cpp:(.text+0x2f59): undefined reference to `cv::circle(cv::_InputOutputArray const&, cv::Point_<int>, int, cv::Scalar_<double> const&, int, int, int)'
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `draw_axes_topright(float, float, float, cv::Mat)':
4dface.cpp:(.text+0x6559): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
4dface.cpp:(.text+0x65f8): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
4dface.cpp:(.text+0x6694): undefined reference to `cv::line(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `cv::String::String(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
4dface.cpp:(.text._ZN2cv6StringC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN2cv6StringC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x2f): undefined reference to `cv::String::allocate(unsigned long)'
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi4EEEv':
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi4EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi4EEEv]+0x63): undefined reference to `cv::String::allocate(unsigned long)'
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi4EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi4EEEv]+0x119): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi4EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi4EEEv]+0x121): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi4EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi4EEEv]+0x240): undefined reference to `cv::String::deallocate()'
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi3EEEv':
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi3EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi3EEEv]+0x63): undefined reference to `cv::String::allocate(unsigned long)'
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi3EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi3EEEv]+0x119): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi3EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi3EEEv]+0x121): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi3EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi3EEEv]+0x260): undefined reference to `cv::String::deallocate()'
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi2EEEv':
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi2EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi2EEEv]+0x63): undefined reference to `cv::String::allocate(unsigned long)'
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi2EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi2EEEv]+0x119): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi2EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi2EEEv]+0x121): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text._ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi2EEEv[_ZNK2cv3MatcvNS_3VecIT_XT0_EEEIfLi2EEEv]+0x22c): undefined reference to `cv::String::deallocate()'
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `rcr::HogTransform::operator()(cv::Mat, unsigned long, int)':
4dface.cpp:(.text._ZN3rcr12HogTransformclEN2cv3MatEmi[_ZN3rcr12HogTransformclEN2cv3MatEmi]+0x19d1): undefined reference to `cv::String::allocate(unsigned long)'
4dface.cpp:(.text._ZN3rcr12HogTransformclEN2cv3MatEmi[_ZN3rcr12HogTransformclEN2cv3MatEmi]+0x1a22): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
4dface.cpp:(.text._ZN3rcr12HogTransformclEN2cv3MatEmi[_ZN3rcr12HogTransformclEN2cv3MatEmi]+0x1a2e): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text._ZN3rcr12HogTransformclEN2cv3MatEmi[_ZN3rcr12HogTransformclEN2cv3MatEmi]+0x1dc4): undefined reference to `cv::String::deallocate()'
CMakeFiles/4dface.dir/apps/4dface.cpp.o: In function `main':
4dface.cpp:(.text.startup+0xa88): undefined reference to `cv::CascadeClassifier::load(cv::String const&)'
4dface.cpp:(.text.startup+0xa96): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0xcd6): undefined reference to `cv::VideoCapture::open(cv::String const&)'
4dface.cpp:(.text.startup+0xce2): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0xe9e): undefined reference to `cv::namedWindow(cv::String const&, int)'
4dface.cpp:(.text.startup+0xeaa): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0xed1): undefined reference to `cv::String::allocate(unsigned long)'
4dface.cpp:(.text.startup+0xeee): undefined reference to `cv::namedWindow(cv::String const&, int)'
4dface.cpp:(.text.startup+0xefa): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0x1390): undefined reference to `cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)'
4dface.cpp:(.text.startup+0x2a73): undefined reference to `cv::String::allocate(unsigned long)'
4dface.cpp:(.text.startup+0x2a95): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
4dface.cpp:(.text.startup+0x2aa1): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0x2af4): undefined reference to `cv::String::allocate(unsigned long)'
4dface.cpp:(.text.startup+0x2b11): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
4dface.cpp:(.text.startup+0x2b1d): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0x3295): undefined reference to `cv::String::allocate(unsigned long)'
4dface.cpp:(.text.startup+0x32dc): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
4dface.cpp:(.text.startup+0x32e8): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0x3477): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
4dface.cpp:(.text.startup+0x3483): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0x39f7): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0x3a21): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0x3b86): undefined reference to `cv::String::deallocate()'
4dface.cpp:(.text.startup+0x3d02): undefined reference to `cv::String::deallocate()'
CMakeFiles/4dface.dir/apps/4dface.cpp.o:4dface.cpp:(.text.startup+0x3d16): more undefined references to `cv::String::deallocate()' follow
collect2: error: ld returned 1 exit status
CMakeFiles/4dface.dir/build.make:101: recipe for target '4dface' failed
make[2]: *** [4dface] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/4dface.dir/all' failed
make[1]: *** [CMakeFiles/4dface.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
patrikhuber commented 7 years ago

Hi,

I'm not sure I've personally tested 4dface on 16.04 yet, but I think this is a problem with your local build setup and/or OpenCV and not 4dface. I would suggest you check your CMake and linker settings and seek for help in OpenCV forums / Stackoverflow or a page like that.

DatHuynh commented 7 years ago

Thank you. I release that I have install both opencv2 and opencv3 on my machine. I guess this mess up the compilation. Is there a way to specify the location or the version of Opencv in CMake? I think I would be better if you could provide a variable to specify this.

patrikhuber commented 7 years ago

OpenCV/CMake already provide this, see initial_cache.cmake, and/or the documentation of FindOpenCV.cmake (in the cmake system folder).

patrikhuber commented 7 years ago

I'm going to close this, as it does not look like it's a 4dface issue. Feel free to re-open if it is. Thanks.

nirabo commented 7 years ago

I experienced the same problem with a locally compiled and installed OpenCV 3.2 on Ubuntu 16.04. I went to my opencv build directory and ran sudo make uninstall which completely removed my opencv installation. Following the procedures described in the README then was successful.