Tencent / ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform
Other
20.24k stars 4.15k forks source link

Error when making source code on Ubuntu 16.04 #1542

Closed jiayilee97 closed 4 years ago

jiayilee97 commented 4 years ago

i followed these instructions (for linux x86): https://github.com/Tencent/ncnn/wiki/how-to-build

when i tried to build the NCNN using sudo make -j4, i got these errors

image

The errors are very similar to this: /ncnn/tools/quantize/ncnn2table.cpp:820:26: error: passing ‘const cv::CommandLineParser’ as ‘this’ argument discards qualifiers [-fpermissive]

im using g++-5, gcc5 and opencv 2.4

nihui commented 4 years ago

fixed in https://github.com/Tencent/ncnn/commit/c089ddb3c235033f8da52b5d22639df5b0ff0824

please update the ncnn git code and try again :)

jiayilee97 commented 4 years ago

Thanks for the quick reply. There are still errors after running your updated git code.

Here are the screenshots of the error: Screenshot 1 image Screenshot 2 image

The full output is as follows: [ 71%] Linking CXX executable ncnnoptimize In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp: In function ‘int main(int, char)’: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:820:26: error: within this context if (parser.has("help")) ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:822:16: error: ‘class cv::CommandLineParser’ has no member named ‘printMessage’ parser.printMessage(); ^ In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:827:28: error: within this context if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("output") || !parser.has("mean") || !parser.has("norm")) ^ In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:827:50: error: within this context if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("output") || !parser.has("mean") || !parser.has("norm")) ^ In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:827:75: error: within this context if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("output") || !parser.has("mean") || !parser.has("norm")) ^ In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:827:100: error: within this context if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("output") || !parser.has("mean") || !parser.has("norm")) ^ In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:827:123: error: within this context if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("output") || !parser.has("mean") || !parser.has("norm")) ^ In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:827:146: error: within this context if (!parser.has("param") || !parser.has("bin") || !parser.has("images") || !parser.has("output") || !parser.has("mean") || !parser.has("norm")) ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:830:16: error: ‘class cv::CommandLineParser’ has no member named ‘printMessage’ parser.printMessage(); ^ In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:860:26: error: within this context if (parser.has("mean")) ^ In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:878:26: error: within this context if (parser.has("norm")) ^ In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:896:26: error: within this context if (parser.has("size")) ^ In file included from /usr/include/opencv2/opencv.hpp:47:0, from /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:30: /usr/include/opencv2/core/core.hpp:4744:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected bool has(const std::string& keys); ^ /media/leejiayi/DATA/ubuntu/Downloads/JobsApplication/BlackSesameTech/ncnn/ncnn/tools/quantize/ncnn2table.cpp:921:28: error: within this context if (parser.has("swapRB")) ^ [ 71%] Built target test_softmax tools/quantize/CMakeFiles/ncnn2table.dir/build.make:62: recipe for target 'tools/quantize/CMakeFiles/**

nihui commented 4 years ago

hmmm, the opencv api compatibility issue is not so easy to fix

For now, you can comment the quantize directory if you aren't eager to use the quantization tools.

https://github.com/Tencent/ncnn/blob/c089ddb3c235033f8da52b5d22639df5b0ff0824/tools/CMakeLists.txt#L6

johnnylecy commented 4 years ago

I have the same issue. Have you solved the problem?

helloworld77 commented 4 years ago

The default opencv version of Ubuntu 16.04 is too old, using opencv 3.+ could solve the problem. download and compile 3.x+ version of opencv, then setting the env like this: export PATH=xxx/opencv-3.xx/bin:$PATH then... cd build; cmake ../; make -j10 That works for me

mayflyfy commented 4 years ago

The default opencv version of Ubuntu 16.04 is too old, using opencv 3.+ could solve the problem. download and compile 3.x+ version of opencv, then setting the env like this: export PATH=xxx/opencv-3.xx/bin:$PATH then... cd build; cmake ../; make -j10 That works for me

重装一下opencv3就好了,感谢