patrikhuber / eos

A lightweight 3D Morphable Face Model library in modern C++
Apache License 2.0
1.89k stars 596 forks source link

Build issues #224

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hello. I'm having trouble to build eos for a while. Can you give me a light in how to proceed to solve this kind of issue?

I followed the instructions exactly like that:

git clone --recursive https://github.com/patrikhuber/eos.git mkdir build && cd build cmake -G "Unix Makefiles" ../eos -DCMAKE_INSTALL_PREFIX=../install/ make

My first problem was with CV_BGR2BGRA ("undefined reference"). After searching a little bit, I found issue https://github.com/patrikhuber/4dface/issues/40 of another repo and tried replacing this constant with 0. The installation went forward. Then it stopped with undefined reference to 'cv::imread'. I compiled and installed sucessfully opencv from the latest release. The full error trace is bellow:

fit-model.cpp:(.text+0x9e2): undefined reference to cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' fit-model.cpp:(.text+0xfc0): undefined reference tocv::rectangle(cv::InputOutputArray const&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)' fit-model.cpp:(.text+0x1409): undefined reference to cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)' fit-model.cpp:(.text+0x1583): undefined reference tocv::imwrite(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&, std::vector<int, std::allocator > const&)' CMakeFiles/fit-model.dir/fit-model.cpp.o: In function eos::render::draw_wireframe(cv::Mat, eos::core::Mesh const&, glm::tmat4x4<float, (glm::precision)0>, glm::tmat4x4<float, (glm::precision)0>, glm::tvec4<float, (glm::precision)0>, cv::Scalar_<double>)': fit-model.cpp:(.text._ZN3eos6render14draw_wireframeEN2cv3MatERKNS_4core4MeshEN3glm7tmat4x4IfLNS7_9precisionE0EEESA_NS7_5tvec4IfLS9_0EEENS1_7Scalar_IdEE[_ZN3eos6render14draw_wireframeEN2cv3MatERKNS_4core4MeshEN3glm7tmat4x4IfLNS7_9precisionE0EEESA_NS7_5tvec4IfLS9_0EEENS1_7Scalar_IdEE]+0x4f2): undefined reference tocv::line(cv::InputOutputArray const&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)' fit-model.cpp:(.text._ZN3eos6render14draw_wireframeEN2cv3MatERKNS_4core4MeshEN3glm7tmat4x4IfLNS7_9precisionE0EEESA_NS7_5tvec4IfLS9_0EEENS1_7Scalar_IdEE[_ZN3eos6render14draw_wireframeEN2cv3MatERKNS_4core4MeshEN3glm7tmat4x4IfLNS7_9precisionE0EEESA_NS7_5tvec4IfLS9_0EEENS1_7Scalar_IdEE]+0x59d): undefined reference to cv::line(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)' fit-model.cpp:(.text._ZN3eos6render14draw_wireframeEN2cv3MatERKNS_4core4MeshEN3glm7tmat4x4IfLNS7_9precisionE0EEESA_NS7_5tvec4IfLS9_0EEENS1_7Scalar_IdEE[_ZN3eos6render14draw_wireframeEN2cv3MatERKNS_4core4MeshEN3glm7tmat4x4IfLNS7_9precisionE0EEESA_NS7_5tvec4IfLS9_0EEENS1_7Scalar_IdEE]+0x648): undefined reference tocv::line(cv::InputOutputArray const&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)' collect2: error: ld returned 1 exit status examples/CMakeFiles/fit-model.dir/build.make:98: recipe for target 'examples/fit-model' failed make[2]: [examples/fit-model] Error 1 CMakeFiles/Makefile2:123: recipe for target 'examples/CMakeFiles/fit-model.dir/all' failed make[1]: [examples/CMakeFiles/fit-model.dir/all] Error 2 Makefile:151: recipe for target 'all' failed make: *** [all] Error 2

patrikhuber commented 5 years ago

Hi, Without knowing more details, this looks like some issue with OpenCV to me. Make sure that OpenCV is found correctly and that it's being linked to. You seem to be building on Linux probably, so you could have a look at the .travis.yml at the root of the repo for one exact way to successfully build it. It also works well on Arch Linux's OpenCV >3 though and with self-built OpenCV versions (apart from the CV_BGR2BGRA issue though but that's easy enough to fix, that constant is in the cv:: namespace since 3.x or so). Maybe it's also possible you need to link to opencv_imgcodecs or something like that, you can check their docu in which module the imread and the other functions reside in the latest version (or in the version you're using).

zsw667291 commented 5 years ago

Hello, I'm also having trouble in building this project. I'm looking forward to your reply soon. Many thanks for your help.

I had already installed boost 1.67 and used CMAKE-gui to instead of : mkdir build && cd build cmake -G "Unix Makefiles" ../eos -DCMAKE_INSTALL_PREFIX=../install/

Selecting Windows SDK version 10.0.17134.0 to target Windows 6.1.7601. The CXX compiler identification is MSVC 19.15.26730.0 Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe -- works Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Detecting CXX compile features Detecting CXX compile features - done Options: EOS_BUILD_EXAMPLES: ON EOS_BUILD_CERES_EXAMPLE: OFF EOS_BUILD_UTILS: OFF EOS_BUILD_DOCUMENTATION: OFF EOS_GENERATE_PYTHON_BINDINGS: OFF EOS_GENERATE_MATLAB_BINDINGS: OFF Eigen3 found: TRUE, version: 3.3.4 Eigen3 include dir found at D:/FromCtrix/3D-FACE/eos/3rdparty/eigen OpenCV ARCH: x64 OpenCV RUNTIME: vc15 OpenCV STATIC: ON Found OpenCV: C:/opencv3.4/opencv/build (found version "3.4.0") found components: core Found OpenCV 3.4.0 in C:/opencv3.4/opencv/build/x64/vc15/lib You might need to add C:\opencv3.4\opencv\build\x64\vc15\bin to your PATH to be able to run your applications. OpenCV 3.x detected - including imgcodecs for compatibility OpenCV ARCH: x64 OpenCV RUNTIME: vc15 OpenCV STATIC: ON Found OpenCV: C:/opencv3.4/opencv/build (found suitable version "3.4.0", minimum required is "3") found components: core imgproc imgcodecs Found OpenCV 3.4.0 in C:/opencv3.4/opencv/build/x64/vc15/lib You might need to add C:\opencv3.4\opencv\build\x64\vc15\bin to your PATH to be able to run your applications. Boost version: 1.67.0 Found the following Boost libraries: system filesystem program_options Boost found at D:/software/boost_1_67_0 Configuring done Generating done

but when i run the project in VS2017, it has error like:

Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "declspec(dllimport) void cdecl boost::filesystem::path_traits::convert(char const ,char const ,class std::basic_string<wchar_t,struct std::char_traits,class std::allocator > &,class std::codecvt<wchar_t,char,struct _Mbstatet> const &)" (imp_?convert@path_traits@filesystem@boost@@YAXPEBD0AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEBV?$codecvt@_WDU_Mbstatet@@@5@@Z) referenced in function "void cdecl boost::filesystem::path_traits::convert(char const ,char const ,class std::basic_string<wchar_t,struct std::char_traits,class std::allocator > &)" (?convert@path_traits@filesystem@boost@@YAXPEBD0AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) generate-obj D:\FromCtrix\3D-FACE\eos\build\examples\generate-obj.obj 1
Error LNK2019 unresolved external symbol "
declspec(dllimport) public: class boost::filesystem::path & __cdecl boost::filesystem::path::replace_extension(class boost::filesystem::path const &)" (
imp_?replace_extension@path@filesystem@boost@@QEAAAEAV123@AEBV123@@Z) referenced in function main generate-obj D:\FromCtrix\3D-FACE\eos\build\examples\generate-obj.obj 1
Error LNK2019 unresolved external symbol "declspec(dllimport) public: class std::basic_string<char,struct std::char_traits,class std::allocator > const cdecl boost::filesystem::path::string(void)const " (imp_?string@path@filesystem@boost@@QEBA?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function main generate-obj D:\FromCtrix\3D-FACE\eos\build\examples\generate-obj.obj 1
Error LNK2019 unresolved external symbol "declspec(dllimport) public: static class std::codecvt<wchar_t,char,struct _Mbstatet> const & cdecl boost::filesystem::path::codecvt(void)" (_imp?codecvt@path@filesystem@boost@@SAAEBV?$codecvt@_WDU_Mbstatet@@@std@@XZ) referenced in function "void
cdecl boost::filesystem::path_traits::convert(char const ,char const ,class std::basic_string<wchar_t,struct std::char_traits,class std::allocator > &)" (?convert@path_traits@filesystem@boost@@YAXPEBD0AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) generate-obj D:\FromCtrix\3D-FACE\eos\build\examples\generate-obj.obj 1

patrikhuber commented 5 years ago

@zsw667291 It seems like you're using the CMake Makefile generator with Visual Studio. I don't have any experience with that. It does look like a boost problem, something with linking, maybe it's not linking to the boost libraries, or to an incompatible build. You could always check the compiler/linker command-line (perhaps with make VERBOSE=1). This is a question more suited for a site like StackOverflow.

Note that you only need boost for the example app, not for the library. You can integrate eos into your own apps without having to use boost or OpenCV.

ghost commented 5 years ago

Hi,

I did a new build of OpenCV, in a new system, and everything went fine. I think the main difference is that I was before trying to directly reference the opencv local build directory with some flags passed to cmake, while now I actually installed OpenCV to the system. Besides "sudo make install", I did "sudo ldconfig", which was something I did not know about before. Summarizing, the build issues were related with OpenCV not being properly installed. Cmake was something I didn't use before and I had to take some time to familiarize with it. My fault.

Thanks again for your help Patrik.

patrikhuber commented 5 years ago

Hi @davidmoseler, I see, glad it works. Just for future reference, note that local OpenCV installations are no issue at all, OpenCV_DIR in CMake just has to be pointed at OpenCV's share/ directory where its cmake-config files are, and everything works completely smoothly. That's much better than messing with the system packages via sudo make install.