Ncnn: ubuntu编译报错

Created on 25 May 2018  ·  8Comments  ·  Source: Tencent/ncnn

OS:Ubuntu 16.04 LTS
在安装好了Opencv之后执行下面的

$ cd <ncnn-root-dir>

uncomment add_subdirectory(examples)
 in CMakeLists.txt with your favourite editor

$ mkdir -p build
$ cd build
$ cmake ..
$ make -j4

到了make -j4这里出现了下面的错误:

collect2: error: ld returned 1 exit status
examples/CMakeFiles/fasterrcnn.dir/build.make:99: recipe for target 'examples/fasterrcnn' failed
make[2]: *** [examples/fasterrcnn] Error 1
CMakeFiles/Makefile2:89: recipe for target 'examples/CMakeFiles/fasterrcnn.dir/all' failed
make[1]: *** [examples/CMakeFiles/fasterrcnn.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

求助这是什么问题?

Most helpful comment

Same to me.
Usemake to see full log. -j4means using multiple threads to build the target.
This is my log.

[ 89%] Built target ncnn
[ 91%] Built target ncnn2mem
make[2]: *** No rule to make target '../tools/caffe/PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND', needed by 'tools/caffe/caffe.pb.cc'。 停止。
CMakeFiles/Makefile2:200: recipe for target 'tools/caffe/CMakeFiles/caffe2ncnn.dir/all' failed
make[1]: *** [tools/caffe/CMakeFiles/caffe2ncnn.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Then I found it hung on at Caffe and ONNX.
Taken advise of @kyo055 , I commented the add_subdirectory(caffe)and #add_subdirectory(onnx)out in the file~/ncnn/tools/CMakeLists.txt. It finally succeeded.:

[  8%] Linking CXX static library libncnn.a
[ 94%] Built target ncnn
[ 95%] Linking CXX executable ncnn2mem
[ 97%] Built target ncnn2mem
[100%] Built target mxnet2ncnn

Hope it can help you.

All 8 comments

upgrade protobuf to 2.6.1 or higher
or you can disable onnx2ncnn tool by commenting it out in tools/CMakeLists.txt

uncomment add_subdirectory(examples)的时候即使 upgrade protobuf to 2.6.1 or higher
or you can disable onnx2ncnn tool by commenting it out in tools/CMakeLists.txt 这样也不行,只有注释掉add_subdirectory(examples)才能成功编译过,请问为什么?

我也遇到了这种情况,应该是protobuf的问题,我发现其他的都还好,只有和protobuf相关的examples会报错

[email protected]

发件人: wangweilai
发送时间: 2018-07-03 12:48
收件人: Tencent/ncnn
抄送: kyo055; Comment
主题: Re: [Tencent/ncnn] ubuntu编译报错 (#421)
uncomment add_subdirectory(examples)的时候即使 upgrade protobuf to 2.6.1 or higher
or you can disable onnx2ncnn tool by commenting it out in tools/CMakeLists.txt 这样也不行,只有注释掉add_subdirectory(examples)才能成功编译过,请问为什么?

You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

可是我把protobuf升级到2.6.1了也还是不行,不知道怎么回事。

白天要上班, 周末试一下看看 再跟你交流

[email protected]

发件人: wangweilai
发送时间: 2018-07-06 11:45
收件人: Tencent/ncnn
抄送: kyo055; Comment
主题: Re: [Tencent/ncnn] ubuntu编译报错 (#421)
可是我把protobuf升级到2.6.1了也还是不行,不知道怎么回事。

You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Same to me.
Usemake to see full log. -j4means using multiple threads to build the target.
This is my log.

[ 89%] Built target ncnn
[ 91%] Built target ncnn2mem
make[2]: *** No rule to make target '../tools/caffe/PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND', needed by 'tools/caffe/caffe.pb.cc'。 停止。
CMakeFiles/Makefile2:200: recipe for target 'tools/caffe/CMakeFiles/caffe2ncnn.dir/all' failed
make[1]: *** [tools/caffe/CMakeFiles/caffe2ncnn.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Then I found it hung on at Caffe and ONNX.
Taken advise of @kyo055 , I commented the add_subdirectory(caffe)and #add_subdirectory(onnx)out in the file~/ncnn/tools/CMakeLists.txt. It finally succeeded.:

[  8%] Linking CXX static library libncnn.a
[ 94%] Built target ncnn
[ 95%] Linking CXX executable ncnn2mem
[ 97%] Built target ncnn2mem
[100%] Built target mxnet2ncnn

Hope it can help you.

已针对新 protobuf 需要 c++11 编译问题做了更新

Same to me.
Usemake to see full log. -j4means using multiple threads to build the target.
This is my log.

[ 89%] Built target ncnn
[ 91%] Built target ncnn2mem
make[2]: *** No rule to make target '../tools/caffe/PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND', needed by 'tools/caffe/caffe.pb.cc'。 停止。
CMakeFiles/Makefile2:200: recipe for target 'tools/caffe/CMakeFiles/caffe2ncnn.dir/all' failed
make[1]: *** [tools/caffe/CMakeFiles/caffe2ncnn.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Then I found it hung on at Caffe and ONNX.
Taken advise of @kyo055 , I commented the add_subdirectory(caffe)and #add_subdirectory(onnx)out in the file~/ncnn/tools/CMakeLists.txt. It finally succeeded.:

[  8%] Linking CXX static library libncnn.a
[ 94%] Built target ncnn
[ 95%] Linking CXX executable ncnn2mem
[ 97%] Built target ncnn2mem
[100%] Built target mxnet2ncnn

Hope it can help you.
But I do it as you said, and fact is, if you uncommented "add_subdirectory(onnx)" and " "add_subdirectory(caffe)", you actually haven't install the tools onnx2ncnn and caffe2ncnn, which is I need. So it just pass by the two important steps...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mychina75 picture mychina75  ·  4Comments

wanzghen0123 picture wanzghen0123  ·  3Comments

zsliaoming picture zsliaoming  ·  3Comments

lovehuanhuan picture lovehuanhuan  ·  3Comments

Abel119 picture Abel119  ·  4Comments