Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find #include "caffe/proto/caffe.pb.h" #1761

Closed
ghost opened this issue Jan 20, 2015 · 7 comments
Closed

cannot find #include "caffe/proto/caffe.pb.h" #1761

ghost opened this issue Jan 20, 2015 · 7 comments

Comments

@ghost
Copy link

ghost commented Jan 20, 2015

I don't understand how to create this file from google proto buffers? I've tried three time to reinstall caffe? From reading other threads it seems that it should be built when I compile caffe?

I'm trying to compile a project with a CMakeLists.txt, and I keep getting this error. I just don't get it?

@ghost
Copy link
Author

ghost commented Jan 21, 2015

Here's the exact output I get,

ajay@ajay-h8-1170uk:$ cd /home/ajay/CppProjects/dqn_caffe/build
ajay@ajay-h8-1170uk:
/CppProjects/dqn_caffe/build$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ajay/CppProjects/dqn_caffe/build
ajay@ajay-h8-1170uk:~/CppProjects/dqn_caffe/build$ make
[ 50%] Building CXX object CMakeFiles/dqn.dir/dqn_main.cpp.o
In file included from /home/ajay/bin/caffe/include/caffe/caffe.hpp:7:0,
from /home/ajay/CppProjects/dqn_caffe/dqn.hpp:10,
from /home/ajay/CppProjects/dqn_caffe/dqn_main.cpp:7:
/home/ajay/bin/caffe/include/caffe/blob.hpp:5:34: fatal error: caffe/proto/caffe.pb.h: No such file or directory
#include "caffe/proto/caffe.pb.h"
^
compilation terminated.
make[2]: *** [CMakeFiles/dqn.dir/dqn_main.cpp.o] Error 1
make[1]: *** [CMakeFiles/dqn.dir/all] Error 2
make: *** [all] Error 2

and the CMakeLists.txt I using for cmake

cmake_minimum_required (VERSION 2.6)
project(dqn)

option(CPU_ONLY "Use CPU only for Caffe" ON)
option(USE_CUDNN "Use cuDNN for Caffe" OFF)
option(USE_SDL "Use SDL for ALE" ON)

#include_directories(/usr/local/caffe/include)
#include_directories(/usr/local/ale_cpp/ale_0.4.4/ale_0_4/src)
#link_directories(/usr/local/caffe/build/lib)
#link_directories(/usr/local/ale_cpp/ale_0.4.4/ale_0_4)

include_directories(/home/ajay/bin/caffe/include)
include_directories(/usr/local/ale_cpp/ale_0.4.4/ale_0_4/src)
link_directories(/home/ajay/bin/caffe/build/lib)
link_directories(/usr/local/ale_cpp/ale_0.4.4/ale_0_4)

if(USE_CUDNN)
link_directories(~/cudnn-6.5-linux-R1)
endif()

add_executable(dqn dqn_main.cpp dqn.cpp)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -march=native")

target_link_libraries(dqn caffe)
target_link_libraries(dqn glog)
target_link_libraries(dqn gflags)
target_link_libraries(dqn ale)

It definitely seems like its a problem with how I'm installing caffe, but it passes all the tests, and works for MNIST?

@ghost
Copy link
Author

ghost commented Jan 21, 2015

SOLVED BY MUUPAN!!

You need to generate caffe.pb.h manually using protoc as follows.

In the directory you installed Caffe to

protoc src/caffe/proto/caffe.proto --cpp_out=.
mkdir include/caffe/proto
mv src/caffe/proto/caffe.pb.h include/caffe/proto

@ghost ghost closed this as completed Jan 21, 2015
@watts4speed
Copy link

I still get this issue and need to refer back to the above fix. I'm on ubuntu 15.10 if that matters. Seems like this should be fixed since it's an old problem and easy to run into. Kinda makes the system seem flakey in my view.

anguelos added a commit to anguelos/opencv_contrib that referenced this issue Jun 27, 2016
Fix Segmaentation fault on GPU
Add Back-ends
Improve preprocessing efficiency
Fix issu with #include "caffe/proto/caffe.pb.h"  in caffe, BVLC/caffe#1761
@iFreilicht
Copy link

For anyone who still encounters this issue: Building with cmake, only use the files in the build/install directory for installation. In that folder, include/caffe/proto/caffe.pb.h is already properly generated and you can install with $ sudo cp -r install/* /usr, possibly replacing /usr with the directory you want to install into.

@hana9090
Copy link

Thank you @AjayTalati 👍

@suikammd
Copy link

@AjayTalati When I tried to generate this file, I got an error "Expected field name". How can I save this problem? Should I upgrade protobuf?

@imyhxy
Copy link

imyhxy commented May 28, 2020

Wow, good job! Save my time.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants