TadasBaltrusaitis / OpenFace

OpenFace – a state-of-the art tool intended for facial landmark detection, head pose estimation, facial action unit recognition, and eye-gaze estimation.
Other
6.93k stars 1.85k forks source link

Compilling error with clang++ #101

Closed gsfish closed 7 years ago

gsfish commented 7 years ago

My OS is Ubuntu 16.04. I followed the installation guide and changed -stdlib=libc++, which had caused error while building, into -stdlib=libstdc++. Here is my command.

cmake -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_CXX_FLAGS="-std=c++11 -stdlib=libstdc++ -I/usr/include/libcxxabi" -D CMAKE_EXE_LINKER_FLAGS="-std=c++11 -stdlib=libstdc++ -lc++abi" -D CMAKE_BUILD_TYPE=RELEASE .. && cmake -j3

But I got the following error message in the final step and I don't know how to fix it:

[ 94%] Linking CXX executable ../../bin/FaceLandmarkVid
../../lib/local/LandmarkDetector/libLandmarkDetector.a(LandmarkDetectorUtils.cpp.o):在函数‘LandmarkDetector::DetectFaces(std::vector<cv::Rect_<double>, std::allocator<cv::Rect_<double> > >&, cv::Mat_<unsigned char> const&, cv::CascadeClassifier&)’中:
/home/gsfish/OpenFace/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp:(.text+0x11c6e):对‘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>)’未定义的引用
clang: error: linker command failed with exit code 1 (use -v to see invocation)
exe/FaceLandmarkVid/CMakeFiles/FaceLandmarkVid.dir/build.make:126: recipe for target 'bin/FaceLandmarkVid' failed
make[2]: *** [bin/FaceLandmarkVid] Error 1
CMakeFiles/Makefile2:309: recipe for target 'exe/FaceLandmarkVid/CMakeFiles/FaceLandmarkVid.dir/all' failed
make[1]: *** [exe/FaceLandmarkVid/CMakeFiles/FaceLandmarkVid.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
[ 96%] Linking CXX executable ../../bin/FaceLandmarkVidMulti
../../lib/local/LandmarkDetector/libLandmarkDetector.a(LandmarkDetectorUtils.cpp.o):在函数‘LandmarkDetector::DetectFaces(std::vector<cv::Rect_<double>, std::allocator<cv::Rect_<double> > >&, cv::Mat_<unsigned char> const&, cv::CascadeClassifier&)’中:
/home/gsfish/OpenFace/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp:(.text+0x11c6e):对‘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>)’未定义的引用
clang: error: linker command failed with exit code 1 (use -v to see invocation)
exe/FaceLandmarkVidMulti/CMakeFiles/FaceLandmarkVidMulti.dir/build.make:125: recipe for target 'bin/FaceLandmarkVidMulti' failed
make[2]: *** [bin/FaceLandmarkVidMulti] Error 1
CMakeFiles/Makefile2:365: recipe for target 'exe/FaceLandmarkVidMulti/CMakeFiles/FaceLandmarkVidMulti.dir/all' failed
make[1]: *** [exe/FaceLandmarkVidMulti/CMakeFiles/FaceLandmarkVidMulti.dir/all] Error 2
[ 97%] Linking CXX executable ../../bin/FaceLandmarkImg
CMakeFiles/FaceLandmarkImg.dir/FaceLandmarkImg.cpp.o:在函数‘main’中:
/home/gsfish/OpenFace/exe/FaceLandmarkImg/FaceLandmarkImg.cpp:(.text+0x8a0c):对‘cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)’未定义的引用
/home/gsfish/OpenFace/exe/FaceLandmarkImg/FaceLandmarkImg.cpp:(.text+0x9a2a):对‘cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)’未定义的引用
../../lib/local/LandmarkDetector/libLandmarkDetector.a(LandmarkDetectorUtils.cpp.o):在函数‘LandmarkDetector::DetectFaces(std::vector<cv::Rect_<double>, std::allocator<cv::Rect_<double> > >&, cv::Mat_<unsigned char> const&, cv::CascadeClassifier&)’中:
/home/gsfish/OpenFace/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp:(.text+0x11c6e):对‘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>)’未定义的引用
clang: error: linker command failed with exit code 1 (use -v to see invocation)
exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/build.make:126: recipe for target 'bin/FaceLandmarkImg' failed
make[2]: *** [bin/FaceLandmarkImg] Error 1
CMakeFiles/Makefile2:252: recipe for target 'exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all' failed
make[1]: *** [exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
TadasBaltrusaitis commented 7 years ago

The issue seems to be the linker, maybe not all the libraries that the code depends on were installed? It's hard to tell without knowing what the code can't link to (as the error indicates you can use -v to find out more.

gsfish commented 7 years ago

I have installed all the depends in Wiki, but it still doesn't work. Here is the output by using -v in CMAKE_EXE_LINKER_FLAGS. How to find out what libraries I need to install?

[ 97%] Linking CXX executable ../../bin/FaceLandmarkImg
clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/6.0.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.0.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/usr/bin/ld" -export-dynamic -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o ../../bin/FaceLandmarkImg /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../.. -L/usr/lib/llvm-3.8/bin/../lib -L/lib -L/usr/lib -lc++abi CMakeFiles/FaceLandmarkImg.dir/FaceLandmarkImg.cpp.o ../../lib/local/LandmarkDetector/libLandmarkDetector.a ../../lib/local/FaceAnalyser/libFaceAnalyser.a ../../lib/3rdParty/dlib/libdlib.a /usr/local/lib/libopencv_videostab.so.3.1.0 /usr/local/lib/libopencv_superres.so.3.1.0 /usr/local/lib/libopencv_stitching.so.3.1.0 /usr/local/lib/libopencv_shape.so.3.1.0 /usr/local/lib/libopencv_photo.so.3.1.0 /usr/local/lib/libopencv_objdetect.so.3.1.0 /usr/local/lib/libopencv_calib3d.so.3.1.0 -lboost_filesystem -lboost_system -ltbb -lpthread -lnsl -lSM -lICE -lX11 -lXext -lpng -ljpeg -lblas -llapack /usr/local/lib/libopencv_features2d.so.3.1.0 /usr/local/lib/libopencv_ml.so.3.1.0 /usr/local/lib/libopencv_highgui.so.3.1.0 /usr/local/lib/libopencv_videoio.so.3.1.0 /usr/local/lib/libopencv_imgcodecs.so.3.1.0 /usr/local/lib/libopencv_flann.so.3.1.0 /usr/local/lib/libopencv_video.so.3.1.0 /usr/local/lib/libopencv_imgproc.so.3.1.0 /usr/local/lib/libopencv_core.so.3.1.0 -rpath /usr/local/lib: -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/crtn.o
../../lib/local/LandmarkDetector/libLandmarkDetector.a(LandmarkDetectorUtils.cpp.o):在函数‘LandmarkDetector::DetectFaces(std::vector<cv::Rect_<double>, std::allocator<cv::Rect_<double> > >&, cv::Mat_<unsigned char> const&, cv::CascadeClassifier&)’中:
/home/gsfish/OpenFace/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp:(.text+0x11c6e):对‘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>)’未定义的引用
clang: error: linker command failed with exit code 1 (use -v to see invocation)
exe/FaceLandmarkVid/CMakeFiles/FaceLandmarkVid.dir/build.make:126: recipe for target 'bin/FaceLandmarkVid' failed
make[2]: *** [bin/FaceLandmarkVid] Error 1
CMakeFiles/Makefile2:309: recipe for target 'exe/FaceLandmarkVid/CMakeFiles/FaceLandmarkVid.dir/all' failed
make[1]: *** [exe/FaceLandmarkVid/CMakeFiles/FaceLandmarkVid.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
../../lib/local/LandmarkDetector/libLandmarkDetector.a(LandmarkDetectorUtils.cpp.o):在函数‘LandmarkDetector::DetectFaces(std::vector<cv::Rect_<double>, std::allocator<cv::Rect_<double> > >&, cv::Mat_<unsigned char> const&, cv::CascadeClassifier&)’中:
/home/gsfish/OpenFace/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp:(.text+0x11c6e):对‘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>)’未定义的引用
clang: error: linker command failed with exit code 1 (use -v to see invocation)
exe/FaceLandmarkVidMulti/CMakeFiles/FaceLandmarkVidMulti.dir/build.make:125: recipe for target 'bin/FaceLandmarkVidMulti' failed
make[2]: *** [bin/FaceLandmarkVidMulti] Error 1
CMakeFiles/Makefile2:365: recipe for target 'exe/FaceLandmarkVidMulti/CMakeFiles/FaceLandmarkVidMulti.dir/all' failed
make[1]: *** [exe/FaceLandmarkVidMulti/CMakeFiles/FaceLandmarkVidMulti.dir/all] Error 2
CMakeFiles/FaceLandmarkImg.dir/FaceLandmarkImg.cpp.o:在函数‘main’中:
/home/gsfish/OpenFace/exe/FaceLandmarkImg/FaceLandmarkImg.cpp:(.text+0x8a0c):对‘cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)’未定义的引用
/home/gsfish/OpenFace/exe/FaceLandmarkImg/FaceLandmarkImg.cpp:(.text+0x9a2a):对‘cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)’未定义的引用
../../lib/local/LandmarkDetector/libLandmarkDetector.a(LandmarkDetectorUtils.cpp.o):在函数‘LandmarkDetector::DetectFaces(std::vector<cv::Rect_<double>, std::allocator<cv::Rect_<double> > >&, cv::Mat_<unsigned char> const&, cv::CascadeClassifier&)’中:
/home/gsfish/OpenFace/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp:(.text+0x11c6e):对‘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>)’未定义的引用
clang: error: linker command failed with exit code 1 (use -v to see invocation)
exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/build.make:126: recipe for target 'bin/FaceLandmarkImg' failed
make[2]: *** [bin/FaceLandmarkImg] Error 1
CMakeFiles/Makefile2:252: recipe for target 'exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all' failed
make[1]: *** [exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
TadasBaltrusaitis commented 7 years ago

It seems like the cv::CascadeClassifier::detectMultiScale is causing issues, this might be due to failure to link to OpenCV, make sure that OpenCV is correctly installed and can be found by the compiler.

Thanks, Tadas

gsfish commented 7 years ago

Got it, thanks for your help. I found that there are warnings when I build OpenCV, it need to add -Wno-deprecated-register in cmake flags to disable the warning. The install process seems has little difference between Ubuntu 16.04 and 15.04 in building OpenCV and OpenFace. Maybe it should be added to Wiki.

pgnaleen commented 7 years ago

[ 97%] Linking CXX executable ../../bin/soci_oracle_test_static Undefined first referenced symbol in file 1cGCrunKpure_error6Fv /root/nalin/instantclient_10_2/libocci.so 1cDstdbCRTTI__1nDstdMlength_error__ /root/nalin/instantclient_10_2/libocci.so .................

i got this error when compiling soci with oracle on solaris 11.7 please help me.

TadasBaltrusaitis commented 7 years ago

This does not seem to be an OpenFace issue, as it does not use a libocci library, it might be related to something else you are linking to.

filosofisto commented 6 years ago

This issue evolved? I have same issue in Solaris 11.

voletiv commented 6 years ago

Same issue in Ubuntu 16.04 with OpenCV 3.4.0 installed without any errors. Please help.

TadasBaltrusaitis commented 6 years ago

Can you provide more details about the issue?

filosofisto commented 6 years ago

In my case I am linking that form:

/usr/gcc/4.8/bin/g++ -o dist/Debug/GNU-Solaris-Sparc/occitest build/Debug/GNU-Solaris-Sparc/main.o -L/home/f780333/paineldaemon/lib -L/home/f780333/paineldaemon/lib/instantclient_11_2 -R'/home/f780333/paineldaemon/lib' -R'/home/f780333/paineldaemon/lib/instantclient_11_2' -locci -lclntsh -m64 -lrt -liostream -lCrun

The -liostream and -lCrun was inserted to resolve similar problems, and I had have to create a symbolic link with bellow commands:

ln -s /usr/lib/sparcv9/libiostream.so.1 libiostream.so ln -s /usr/lib/sparcv9/libCrun.so.1 libCrun.so

But now I have this other symbols problem:

ld: warning: symbol 'clog' has differing types: (file /home/f780333/paineldaemon/lib/libiostream.so type=OBJT; file /lib/sparcv9/libm.so type=FUNC); /home/f780333/paineldaemon/lib/libiostream.so definition taken Undefined first referenced symbol in file 1cDstdbCRTTI1nDstdMlength_error /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMout_of_range2T6Mv /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_2G6Mpkcr1 /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdLlogic_error2t6Mrkn0AMbasic_string4Ccn0ALchartraits4Ccn0AJallocator4Ccv_ /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_2G6Mrk1r1 /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_2t6MpkcLrkn0Cv_ /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cHrwstdRexcept_msg_string2t6MIEv /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_2t6Mpkcrkn0Cv_ /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_2T6Mv /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_Hreplace6MLLpkcLLLpc /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cHrwstdbCrwseStringIndexOutOfRange /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cHrwstdXrwseInvalidSizeParam /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_Efind6kMpkcLLL /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_J_nullref /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cHrwstdUInterlockedDecrement6Fpll /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cHrwstdUInterlockedIncrement6Fpll /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdbCRTTI1nDstdMout_of_range /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_Gassign6Mrk1LLr1 /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdLlogic_error2T6Mv /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cHrwstdTInterlockedExchange6Fplll /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_IgetRep6MLL_pnHrwstdMstring_ref4Ccn0B_n0C__ /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdJallocator4Cc_2t6Mv /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so __1cDstdMlength_error2t6Mrkn0AMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc__v /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cHrwstdYrwseUnexpectedNullPtr /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_2t6Mrk1LLrkn0C_v /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMlength_error2T6Mv /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMout_of_range2t6Mrkn0AMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc__v /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cHrwstdXrwseResultLenInvalid /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdMbasic_string4Ccn0ALchar_traits4Ccn0AJallocator4Cc_IunLink6Mv /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so 1cDstdbBRTTI1nDstdLlogic_error /home/f780333/paineldaemon/lib/instantclient_11_2/libocci.so ld: fatal: symbol referencing errors collect2: error: ld returned 1 exit status gmake[2]: [dist/Debug/GNU-Solaris-Sparc/occitest] Error 1 gmake[2]: Leaving directory `/home/f780333/.netbeans/remote/172.16.160.172/sylvia-Linux-x86_64/home/eduardo/Indra/Cartoes/repo/misc/OCCITest' gmake[1]: [.build-conf] Error 2 gmake[1]: Leaving directory `/home/f780333/.netbeans/remote/172.16.160.172/sylvia-Linux-x86_64/home/eduardo/Indra/Cartoes/repo/misc/OCCITest' gmake: *** [.build-impl] Error 2