Alan Vitullo
Alan Vitullo

Reputation: 30

PyCaffe build fails, lboost_python not found

I am on MacOS 10.13.3 (17D47) with Python 2.7.14. I am in the process of building caffe w/ python. The project is CPU only. I am able to build caffe through make run test however, after attempting make pycaffe I get an error. This is the result:

touch python/caffe/proto/__init__.py
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
PROTOC (python) src/caffe/proto/caffe.proto
In file included from python/caffe/_caffe.cpp:17:
In file included from ./include/caffe/caffe.hpp:12:
./include/caffe/net.hpp:41:5: warning: unused typedef 'INVALID_REQUESTED_LOG_SEVERITY' [-Wunused-local-typedef]
    LOG_EVERY_N(WARNING, 1000) << "DEPRECATED: ForwardPrefilled() "
    ^
/usr/local/include/glog/logging.h:943:30: note: expanded from macro 'LOG_EVERY_N'
                             INVALID_REQUESTED_LOG_SEVERITY);           \
                             ^
1 warning generated.
ld: library not found for -lboost_python
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [python/caffe/_caffe.so] Error 1

I have a Makefile.config that calls out boost-python from the brew install set as:

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/local/Cellar/boost-python/1.67.0/lib

My two initial questions are: 1)Am I not allowed to link to the boost library using the system python? 2)What is the correct way to tell make to grab boost-python?

Upvotes: 1

Views: 1257

Answers (2)

Bob
Bob

Reputation: 177

I was actually having the same problem and couldn't find any answers for days. However, I found this question: Build caffe with Python ( cannot find -lboost_python3 ) .

That question is for python3, but I'm using python2.7 . Basically, I went into the Makefile (not Makefile.config), searched for boost_python, and changed it to boost_python27 . I did the following steps:

  1. vim Makefile
  2. use vim command :?boost_python (there should only be 1 occurrence)
  3. changed PYTHON_LIBRARIES ?= boost_python python2.7 to PYTHON_LIBRARIES ?= boost_python27 python2.7
  4. ran the command sudo make pycaffe

I hope this helps you!

Upvotes: 4

Rounak Saha
Rounak Saha

Reputation: 21

Goto Makefile (and not the .config file) and change the name of the ld library to python27.

Upvotes: 2

Related Questions