Cannot find onnx/onnx.pb.h
See original GitHub issueWhenever I try to include onnx/onnx_pb.h, I get a compilation error stating /usr/local/include/onnx/onnx_pb.h:52:26: fatal error: onnx/onnx.pb.h: No such file or directory compilation terminated.
It works fine in python though, but I want to parse ONNX models in C++.
I have tried to follow the instructions in #418 and #1001 but I think a specific solution would be more helpful.
I have the protobuf library installed. I have tried installing ONNX by following the instructions and finally running sudo python3 setup.py install. In the folder /home/sreenik/onnx/.setuptools-cmake-build/ when I type cmake -LA I get the following output: (a part is shown)
Protobuf_INCLUDE_DIR:PATH=/usr/include Protobuf_LIBRARY:FILEPATH=Protobuf_LIBRARY-NOTFOUND Protobuf_LIBRARY_DEBUG:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotobuf.so Protobuf_LIBRARY_RELEASE:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotobuf.so Protobuf_LITE_LIBRARY_DEBUG:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotobuf-lite.so Protobuf_LITE_LIBRARY_RELEASE:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotobuf-lite.so Protobuf_PROTOC_EXECUTABLE:FILEPATH=/usr/bin/protoc Protobuf_PROTOC_LIBRARY:FILEPATH=Protobuf_PROTOC_LIBRARY-NOTFOUND Protobuf_PROTOC_LIBRARY_DEBUG:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotoc.so Protobuf_PROTOC_LIBRARY_RELEASE:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotoc.so pybind11_DIR:PATH=pybind11_DIR-NOTFOUND
As this didn’t work I tried to install it again by directly using cmake and make from the /onnx root directory. Even that did not work, however, cmake -LA showed the following: (a part is shown)
Protobuf_INCLUDE_DIR:PATH=/usr/local/include Protobuf_LIBRARY:FILEPATH=/usr/local/lib/libprotobuf.so Protobuf_LITE_LIBRARY_DEBUG:FILEPATH=/usr/local/lib/libprotobuf-lite.so Protobuf_LITE_LIBRARY_RELEASE:FILEPATH=/usr/local/lib/libprotobuf-lite.so Protobuf_PROTOC_EXECUTABLE:FILEPATH=/usr/local/bin/protoc Protobuf_PROTOC_LIBRARY:FILEPATH=/usr/local/lib/libprotoc.so
This detects the protobuf include dir path but still doesn’t solve the issue.
I have been trying to solve this for quite some time now, I think I might be missing something really simple, can someone please help me out?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11

Top Related StackOverflow Question
@sreenikSS
I was able to reproduce your error. A possible workaround could be including the -DONNX_ML=1 flag while compiling using g++ as well as including the
.setuptools-cmake-builddirectory. This looks like:g++ -DONNX_ML=1 test.cpp -o test -lprotobuf -I/path/to/onnx/repo/.setuptools-cmake-build/.To understand what is happening after adding the mentioned flag, you should observe the
onnx_pb.hfile.Since
onnx.pb.his not available, butonnx-ml.pb.his, setting the flag finds the required file.What I am concerned about however is the repercussions of the said flag. Check out these two issues #1017 and #465
Can anybody point out why there is a
onnx.protoandonnx-ml.proto? what’s the differences?am using onnx-ml seems by default, but I can not get
onnx::ModelProtoany longer.