Tencent / ncnn

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

clang: error: linker command failed with exit code 1 #5252

Closed CheungBH closed 1 month ago

CheungBH commented 8 months ago

Hello. Thanks for your great work. I am building ncnn for Macos. However, some error occurs while building with "cmake --build . -j 4"

clang: error: linker command failed with exit code 1 (use -v to see invocation) "google::protobuf::Message::InitializationErrorString() const", referenced from: vtable for caffe::Yolov3DetectionOutputParameter in caffe.pb.cc.o vtable for caffe::YoloDetectionOutputParameter in caffe.pb.cc.o vtable for caffe::WindowDataParameter in caffe.pb.cc.o vtable for caffe::TransformationParameter in caffe.pb.cc.o vtable for caffe::TileParameter in caffe.pb.cc.o vtable for caffe::ThresholdParameter in caffe.pb.cc.o vtable for caffe::TanHParameter in caffe.pb.cc.o ... "google::protobuf::Message::MaybeComputeUnknownFieldsSize(unsigned long, google::protobuf::internal::CachedSize) const", referenced from: caffe::BlobShape::ByteSizeLong() const in caffe.pb.cc.o caffe::BlobProto::ByteSizeLong() const in caffe.pb.cc.o caffe::BlobProtoVector::ByteSizeLong() const in caffe.pb.cc.o caffe::Datum::ByteSizeLong() const in caffe.pb.cc.o caffe::FillerParameter::ByteSizeLong() const in caffe.pb.cc.o caffe::NetParameter::ByteSizeLong() const in caffe.pb.cc.o caffe::SolverParameter::ByteSizeLong() const in caffe.pb.cc.o ... "google::protobuf::internal::TaggedStringPtr::ForceCopy(google::protobuf::Arena) const", referenced from: caffe::Datum::Datum(google::protobuf::Arena, caffe::Datum const&) in caffe.pb.cc.o caffe::FillerParameter::FillerParameter(google::protobuf::Arena, caffe::FillerParameter const&) in caffe.pb.cc.o caffe::FillerParameter::FillerParameter(google::protobuf::Arena, caffe::FillerParameter const&) in caffe.pb.cc.o caffe::NetParameter::NetParameter(google::protobuf::Arena, caffe::NetParameter const&) in caffe.pb.cc.o caffe::SolverParameter::SolverParameter(google::protobuf::Arena, caffe::SolverParameter const&) in caffe.pb.cc.o caffe::SolverState::SolverState(google::protobuf::Arena, caffe::SolverState const&) in caffe.pb.cc.o caffe::SolverState::SolverState(google::protobuf::Arena*, caffe::SolverState const&) in caffe.pb.cc.o ... "typeinfo for google::protobuf::Message", referenced from: typeinfo for caffe::Yolov3DetectionOutputParameter in caffe.pb.cc.o typeinfo for caffe::YoloDetectionOutputParameter in caffe.pb.cc.o typeinfo for caffe::WindowDataParameter in caffe.pb.cc.o typeinfo for caffe::TransformationParameter in caffe.pb.cc.o typeinfo for caffe::TileParameter in caffe.pb.cc.o typeinfo for caffe::ThresholdParameter in caffe.pb.cc.o typeinfo for caffe::TanHParameter in caffe.pb.cc.o ... ld: symbol(s) not found for architecture x86_64 make[2]: [tools/onnx/onnx2ncnn] Error 1 make[1]: [tools/onnx/CMakeFiles/onnx2ncnn.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [tools/caffe/caffe2ncnn] Error 1 make[1]: [tools/caffe/CMakeFiles/caffe2ncnn.dir/all] Error 2 [ 65%] Built target glslang [ 66%] Built target SPIRV make: [all] Error 2

Are there any suggestions for solving it?

CheungBH commented 8 months ago

I am building it with macOS using A1 chip. And I downloaded protobuf using "brew install protobuf"

sxj731533730 commented 7 months ago

https://github.com/Tencent/ncnn/wiki/faq

nihui commented 5 months ago

You can skip building tools via cmake option -DNCNN_BUILD_TOOLS=OFF and use the prebuilt pnnx tools here for converting torch model to ncnn ---> https://github.com/pnnx/pnnx

nihui commented 1 month ago

针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn

pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]

详细参考文档 Detailed reference documentation https://github.com/pnnx/pnnx https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx