Caffe: protoc: No such file or directory when running make all on MAC

Created on 4 Jul 2014  Â·  11Comments  Â·  Source: BVLC/caffe

I followed the instructions to install caffe on mac. But I have got the error while running make all. The error message is :

$ make all
protoc --proto_path=src --cpp_out=build/src src/caffe/proto/caffe.proto
make: protoc: No such file or directory
make: *** [build/src/caffe/proto/caffe.pb.cc] Error 1

Then I cd the directory , src/caffe/proto/caffe, checking if there is caffe.proto. There is.
I've installed prerequisites. Here is my brew list:

$ brew list
arpack      ctags       gmp4        mpfr2       python
boost       gdb             hdf5                openblas            readline
brew-cask   gdbm        isl011      openssl     snappy
cloog018            gflags      leveldb     pkg-config  sqlite
cmake       glog                libmpc08            protobuf             szip

Can anyone help me solve this ? Many thanks ~~

Most helpful comment

All 11 comments

What does which protoc give you? Make sure that your PATH includes
/usr/local/bin so that you can actually run your homebrew dependencies.

On Fri, Jul 4, 2014 at 10:19 AM, Coldmooon [email protected] wrote:

I followed the instructions to install caffe on mac. But I have got the
error while running "make all". The error message is :
$ make all
protoc --proto_path=src --cpp_out=build/src src/caffe/proto/caffe.proto
make: protoc: No such file or directory
make: *** [build/src/caffe/proto/caffe.pb.cc] Error 1

Then I cd the directory , "src/caffe/proto/caffe", checking if there is
caffe.proto. There is.
I've installed prerequisites. Here is my brew list:
$ brew list
arpack ctags gmp4 mpfr2 python
boost gdb hdf5 openblas readline
brew-cask gdbm isl011 openssl snappy
cloog018 gflags leveldb pkg-config sqlite
cmake glog libmpc08 protobuf szip

Can anyone help me solve this ? Many thanks ~~

—
Reply to this email directly or view it on GitHub
https://github.com/BVLC/caffe/issues/617.

Thank you, shelhamer. Inspired by you , I check the directory where protobuf installed and found protoc there. It was just because brew didn't make symbolic link of protoc. Then I typed brew link protobuf. The error message disappeared.

But, unfortunately, I've got a new error:

./include/caffe/util/mkl_alternate.hpp:13:10: fatal error: 'cblas.h' file not  found
#include <cblas.h>
1 error generated.
make: *** [build/src/caffe/blob.o] Error 1

I've found cblas.h is in /usr/local/Cellar/openblas/0.2.9-rc2/include. I try to use the same way to brew link openblas.
When I check the information about openblas, I got warning :

This formula is keg-only.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Should I continue to brew link openblas ??

cblas.h problem has been solved. I just edited two lines in makefile.config:

BLAS_INCLUDE := /usr/local/Cellar/openblas/0.2.9-rc2/include
BLAS_LIB := /usr/local/Cellar/openblas/0.2.9-rc2/lib

Now, I have a new error about cv:imread.

clang: warning: argument unused during compilation: '-pthread'
ld: warning: directory not found for option '-L/usr/local/cuda/lib64'
Undefined symbols for architecture x86_64:
  "cv::imread(std::string const&, int)", referenced from:
      void* caffe::WindowDataLayerPrefetch<float>(void*) in window_data_layer.o
      void* caffe::WindowDataLayerPrefetch<double>(void*) in window_data_layer.o
      caffe::ReadImageToDatum(std::string const&, int, int, int, caffe::Datum*) in io.o
ld: symbol(s) not found for architecture x86_64

Before installing caffe, I've installed opencv from source code and have been using opencv correctly in some projects. So , I didn't reinstall opencv using brew when installing caffe. Is this the main reason I got the error? If so , how can I uninstall opencv which is compiled from source code by myself?

My opencv's configuration is:

$ pkg-config --cflags opencv
-I/usr/local/include/opencv -I/usr/local/include 
$ pkg-config --libs opencv
/usr/local/lib/libopencv_calib3d.dylib /usr/local/lib/libopencv_contrib.dylib /usr/local/lib/libopencv_core.dylib /usr/local/lib/libopencv_features2d.dylib /usr/local/lib/libopencv_flann.dylib /usr/local/lib/libopencv_gpu.dylib /usr/local/lib/libopencv_highgui.dylib /usr/local/lib/libopencv_imgproc.dylib /usr/local/lib/libopencv_legacy.dylib /usr/local/lib/libopencv_ml.dylib /usr/local/lib/libopencv_nonfree.dylib /usr/local/lib/libopencv_objdetect.dylib /usr/local/lib/libopencv_ocl.dylib /usr/local/lib/libopencv_photo.dylib /usr/local/lib/libopencv_stitching.dylib /usr/local/lib/libopencv_superres.dylib /usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_video.dylib /usr/local/lib/libopencv_videostab.dylib

@Coldmooon
Hi, I have the same error as you do. I am using a Mac OS X, with boost 1.55

Undefined symbols for architecture x86_64:
"cv::imread(std::string const&, int)", referenced from:
void* caffe::WindowDataLayerPrefetch(void_) in window_data_layer.o
void_ caffe::WindowDataLayerPrefetch(void_) in window_data_layer.o
caffe::ReadImageToDatum(std::string const&, int, int, int, caffe::Datum_) in io.o
"google::protobuf::MessageLite::ParseFromString(std::string const&)", referenced from:
caffe::DataLayer::SetUp(std::vectorcaffe::Blob > const&, std::vectorcaffe::Blob >_) in data_layer.o
void_ caffe::DataLayerPrefetch(void_) in data_layer.o
caffe::DataLayer::SetUp(std::vectorcaffe::Blob

Were you able to fix it?

@Coldmooon glad you figured out the BLAS issue -- thanks for documenting your configuration here.

Your OpenCV error is because your original install of OpenCV is almost certainly not built with libstdc++ instead of libc++. libstdc++ is required for CUDA, but libc++ is the standard on OS X 10.9. You need to recompile OpenCV with libstdc++ for Caffe.

Refer to the installation guide for more details.

@shelhamer I am getting the same error as @Coldmooon despite that I brew installed OpenCV (2.4.10) with the modified formula to build with libstdc++. I am currently running Mac OSX Yosemite and buildling Caffe with cuDNN R2 and CUDA 7.0. Could you provide some help?

Here is a part of the error message:

Undefined symbols for architecture x86_64:
  "cv::imread(std::string const&, int)", referenced from:
      caffe::WindowDataLayer<float>::InternalThreadEntry() in window_data_layer.o
      caffe::WindowDataLayer<double>::InternalThreadEntry() in window_data_layer.o
      caffe::ReadImageToDatum(std::string const&, int, int, int, bool, caffe::Datum*) in io.o
  "caffe::PowerLayer<double>::LayerSetUp(std::__1::vector<caffe::Blob<double>*, std::__1::allocator<caffe::Blob<double>*> > const&, std::__1::vector<caffe::Blob<double>*, std::__1::allocator<caffe::Blob<double>*> >*)", referenced from:
      vtable for caffe::PowerLayer<double> in power_layer.cuo
  "caffe::PowerLayer<double>::Forward_cpu(std::__1::vector<caffe::Blob<double>*, std::__1::allocator<caffe::Blob<double>*> > const&, std::__1::vector<caffe::Blob<double>*, std::__1::allocator<caffe::Blob<double>*> >*)", referenced from:
      vtable for caffe::PowerLayer<double> in power_layer.cuo
  "caffe::PowerLayer<double>::Forward_gpu(std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> > const&, std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> >*)", referenced from:
      vtable for caffe::PowerLayer<double> in layer_factory.o
      vtable for caffe::PowerLayer<double> in lrn_layer.o
      vtable for caffe::PowerLayer<double> in power_layer.o

@kerkilchoi, if you are sure you built opencv with libstdc++, this error might be due to other dependences built with libc++. I've solved this problem by uninstalling all of related dependences and reinstalled them. You can run the following command in terminal to quickly uninstall dependences.
rm -rf /usr/local/Cellar && brew prune. I refer you to the issue #1740, #1310, #915, #1212, #1358, #454.

I've got the similar problem. I followed the installation instruction, which says that "CUDA 7 is strongly suggested. Older CUDA require libstdc++ while clang++ is the default compiler and libc++ the default standard library on OS X 10.9+. ". So I installed cuda7, by updating from cuda6.5. Then install opencv via brew install opencv after brew tap homebrew/science.
When I step to compilation, run make all at caffe root, I got this error message:

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
CXX src/caffe/blob.cpp
In file included from src/caffe/blob.cpp:4:
In file included from ./include/caffe/blob.hpp:10:
In file included from ./include/caffe/syncedmem.hpp:7:
In file included from ./include/caffe/util/math_functions.hpp:11:
./include/caffe/util/mkl_alternate.hpp:11:10: fatal error: 'cblas.h' file not found
#include <cblas.h>
         ^
1 error generated.
make: *** [.build_release/src/caffe/blob.o] Error 1

I've searched for solution, someone says that Makefile should be modified. But seems that solution is out of date.

I'm encountering error

Undefined symbols for architecture x86_64:
"cv::imread(std::string const&, int)", referenced from:
caffe::WindowDataLayer::InternalThreadEntry() in window_data_layer.o
caffe::WindowDataLayer::InternalThreadEntry() in window_data_layer.o

Though all packets were installed with brew

$ brew list:
boost
cmake
eigen
gcc
gflags
glog
gmp
hdf5
ilmbase
isl
jpeg
leveldb
libmpc
libpng
libtiff
lmdb
mpfr
numpy
openblas
opencv
openexr
openssl
protobuf
snappy
szip
wget

In response to the error

./include/caffe/util/mkl_alternate.hpp:13:10: fatal error: 'cblas.h' file not  found
#include <cblas.h>

I found simply running

brew install openblas

fixed it for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

erogol picture erogol  Â·  3Comments

sdemyanov picture sdemyanov  Â·  3Comments

dfotland picture dfotland  Â·  3Comments

vladislavdonchev picture vladislavdonchev  Â·  3Comments

inferrna picture inferrna  Â·  3Comments