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

Boost Error #2

Open
RishabGargeya opened this issue Nov 6, 2016 · 6 comments
Open

Boost Error #2

RishabGargeya opened this issue Nov 6, 2016 · 6 comments

Comments

@RishabGargeya
Copy link

Hi,

I tried installing your converter, but I keep on running into the following error:

Linking: mxnet_to_caffe
g++ objs/mxnet_to_caffe.o objs/mxnet_my_c_predict_api.o  -lm -lboost_serialization -lboost_filesystem -fopenmp -Wl,--whole-archive /home/rg203/work/caffe/build/lib/libcaffe.a -Wl,--no-whole-archive -lprotobuf -lglog -lgflags -llmdb -lleveldb /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_hl.so -lboost_system -lboost_thread  -lopenblas  -L/usr/local/cuda/lib64 -lcudart -lcublas -lcurand -lcudnn  /home/rg203/work/mxnet/lib/libmxnet.so `pkg-config --libs opencv` -o "mxnet_to_caffe"
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::api::object::object()':
/usr/include/boost/python/object_core.hpp:504: undefined reference to `_Py_NoneStruct'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::api::const_attribute_policies::get(boost::python::api::object const&, char const*)':
/usr/include/boost/python/object_attributes.hpp:74: undefined reference to `boost::python::api::getattr(boost::python::api::object const&, char const*)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::str::str(char const*)':
/usr/include/boost/python/str.hpp:150: undefined reference to `boost::python::detail::str_base::str_base(char const*)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `_object* boost::python::expect_non_null<_object>(_object*)':
/usr/include/boost/python/errors.hpp:45: undefined reference to `boost::python::throw_error_already_set()'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::error_already_set::error_already_set(boost::python::error_already_set const&)':
/usr/include/boost/python/errors.hpp:17: undefined reference to `vtable for boost::python::error_already_set'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::shared_ptr<caffe::Layer<float> > caffe::GetPythonLayer<float>(caffe::LayerParameter const&)':
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:244: undefined reference to `Py_Initialize'
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:246: undefined reference to `boost::python::import(boost::python::str)'
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:250: undefined reference to `PyErr_Print'
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:249: undefined reference to `boost::python::error_already_set::~error_already_set()'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::shared_ptr<caffe::Layer<double> > caffe::GetPythonLayer<double>(caffe::LayerParameter const&)':
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:244: undefined reference to `Py_Initialize'
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:246: undefined reference to `boost::python::import(boost::python::str)'
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:250: undefined reference to `PyErr_Print'
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:249: undefined reference to `boost::python::error_already_set::~error_already_set()'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::converter::extract_rvalue<boost::shared_ptr<caffe::PythonLayer<float> > >::operator()() const':
/usr/include/boost/python/extract.hpp:186: undefined reference to `boost::python::converter::rvalue_from_python_stage2(_object*, boost::python::converter::rvalue_from_python_stage1_data&, boost::python::converter::registration const&)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::converter::extract_rvalue<boost::shared_ptr<caffe::PythonLayer<double> > >::operator()() const':
/usr/include/boost/python/extract.hpp:186: undefined reference to `boost::python::converter::rvalue_from_python_stage2(_object*, boost::python::converter::rvalue_from_python_stage1_data&, boost::python::converter::registration const&)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::detail::returnable<boost::python::api::object>::type boost::python::call<boost::python::api::object, caffe::LayerParameter>(_object*, caffe::LayerParameter const&, boost::type<boost::python::api::object>*)':
/usr/include/boost/python/call.hpp:66: undefined reference to `PyEval_CallFunction'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::converter::extract_rvalue<boost::shared_ptr<caffe::PythonLayer<float> > >::extract_rvalue(_object*)':
/usr/include/boost/python/extract.hpp:166: undefined reference to `boost::python::converter::rvalue_from_python_stage1(_object*, boost::python::converter::registration const&)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::converter::extract_rvalue<boost::shared_ptr<caffe::PythonLayer<double> > >::extract_rvalue(_object*)':
/usr/include/boost/python/extract.hpp:166: undefined reference to `boost::python::converter::rvalue_from_python_stage1(_object*, boost::python::converter::registration const&)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::converter::registration const& boost::python::converter::detail::registry_lookup2<boost::shared_ptr<caffe::PythonLayer<float> > const volatile>(boost::shared_ptr<caffe::PythonLayer<float> > const volatile& (*)())':
/usr/include/boost/python/converter/registered.hpp:87: undefined reference to `boost::python::converter::registry::lookup(boost::python::type_info)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::converter::registration const& boost::python::converter::detail::registry_lookup2<boost::shared_ptr<caffe::PythonLayer<double> > const volatile>(boost::shared_ptr<caffe::PythonLayer<double> > const volatile& (*)())':
/usr/include/boost/python/converter/registered.hpp:87: undefined reference to `boost::python::converter::registry::lookup(boost::python::type_info)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::converter::detail::value_arg_to_python<caffe::LayerParameter>::value_arg_to_python(caffe::LayerParameter const&)':
/usr/include/boost/python/converter/arg_to_python.hpp:209: undefined reference to `boost::python::converter::detail::arg_to_python_base::arg_to_python_base(void const volatile*, boost::python::converter::registration const&)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `void boost::python::converter::detail::register_shared_ptr0<caffe::PythonLayer<float> >(boost::shared_ptr<caffe::PythonLayer<float> >*)':
/usr/include/boost/python/converter/registered.hpp:72: undefined reference to `boost::python::converter::registry::lookup_shared_ptr(boost::python::type_info)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `void boost::python::converter::detail::register_shared_ptr0<caffe::PythonLayer<double> >(boost::shared_ptr<caffe::PythonLayer<double> >*)':
/usr/include/boost/python/converter/registered.hpp:72: undefined reference to `boost::python::converter::registry::lookup_shared_ptr(boost::python::type_info)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::converter::registration const& boost::python::converter::detail::registry_lookup2<caffe::LayerParameter const volatile>(caffe::LayerParameter const volatile& (*)())':
/usr/include/boost/python/converter/registered.hpp:87: undefined reference to `boost::python::converter::registry::lookup(boost::python::type_info)'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o):(.data.DW.ref._ZTIN5boost6python17error_already_setE[DW.ref._ZTIN5boost6python17error_already_setE]+0x0): undefined reference to `typeinfo for boost::python::error_already_set'
collect2: error: ld returned 1 exit status
Makefile:30: recipe for target 'mxnet_to_caffe' failed
make: *** [mxnet_to_caffe] Error 1

Is this an issue with my boost installation? My caffe install seems to be working fine though. I am working off of the latest caffe pull.

Any ideas? Thanks for the help!

@pertusa
Copy link
Owner

pertusa commented Nov 7, 2016

It seems that boost-python needs to be linked. Try to add -lboost_python to the CAFFE_DEPENDENCES in the Makefile, and please let me know if it works to update it.

@RishabGargeya
Copy link
Author

Thanks for the response. I added -lboost_python to the Makefile but ran into the same error.
I then tried installing boost from source, remaking caffe, and then running make but I get the following:

Linking: mxnet_to_caffe
g++ objs/mxnet_to_caffe.o objs/mxnet_my_c_predict_api.o  -lm -lboost_serialization -lboost_filesystem -fopenmp -Wl,--whole-archive /home/rg203/work/caffe/build/lib/libcaffe.a -Wl,--no-whole-archive -lprotobuf -lglog -lgflags -llmdb -lleveldb /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_hl.so -lboost_system -lboost_thread -lboost_python -I/home/rg203/work/boost_1_62_0 -lopenblas  -L/usr/local/cuda/lib64 -lcudart -lcublas -lcurand -lcudnn -L/home/rg203/work/boost_1_62_0/stage/lib  /home/rg203/work/mxnet/lib/libmxnet.so `pkg-config --libs opencv` -L/home/rg203/work/boost_1_62_0/stage/lib -lboost_python -o "mxnet_to_caffe"
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::api::object::object()':
/home/rg203/work/boost_1_62_0/boost/python/object_core.hpp:403: undefined reference to `_Py_NoneStruct'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::shared_ptr<caffe::Layer<float> > caffe::GetPythonLayer<float>(caffe::LayerParameter const&)':
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:244: undefined reference to `Py_Initialize'
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:250: undefined reference to `PyErr_Print'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::shared_ptr<caffe::Layer<double> > caffe::GetPythonLayer<double>(caffe::LayerParameter const&)':
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:244: undefined reference to `Py_Initialize'
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:250: undefined reference to `PyErr_Print'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::detail::returnable<boost::python::api::object>::type boost::python::call<boost::python::api::object, caffe::LayerParameter>(_object*, caffe::LayerParameter const&, boost::type<boost::python::api::object>*)':
/home/rg203/work/boost_1_62_0/boost/python/call.hpp:66: undefined reference to `PyEval_CallFunction'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_FromEncodedObject'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceDivide'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceRemainder'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PySlice_New'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyList_Sort'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PySequence_GetSlice'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_SetAttrString'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyType_IsSubtype'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyList_Insert'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyExc_RuntimeError'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyComplex_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_Copy'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_Size'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyString_Size'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyUnicode_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyStaticMethod_New'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyList_Reverse'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyErr_NoMemory'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyString_FromStringAndSize'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyBaseObject_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyList_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyModule_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceLshift'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_Keys'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyString_InternFromString'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_Subtract'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_DelItem'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceMultiply'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `_PyType_Lookup'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyErr_Clear'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyArg_ParseTupleAndKeywords'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyCallable_Check'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_Xor'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyLong_AsUnsignedLongLong'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyInt_AsLong'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyErr_ExceptionMatches'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyMethod_New'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_AsWideChar'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_Or'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceOr'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyExc_TypeError'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyComplex_RealAsDouble'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyErr_SetObject'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyLong_AsUnsignedLong'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PySequence_DelSlice'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyType_Ready'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_IsTrue'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_Add'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyTuple_GetItem'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_Clear'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_Size'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_RichCompare'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyLong_AsLongLong'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyBool_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_Multiply'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyErr_WarnEx'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyString_AsString'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_GetAttr'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyTuple_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyCFunction_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_GetItem'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyMethod_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyTuple_New'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceRshift'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyString_FromFormat'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyExc_ImportError'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyExc_AttributeError'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyErr_Occurred'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyWeakref_NewRef'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_Remainder'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyComplex_ImagAsDouble'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyExc_ValueError'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_And'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PySequence_SetSlice'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyImport_ImportModule'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyExc_OverflowError'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyClass_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyLong_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyString_FromString'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyRun_FileExFlags'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyFile_AsFile'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_CallFunction'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyErr_SetString'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_IsInstance'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `Py_InitModule4_64'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyList_Append'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyMem_Free'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyType_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyProperty_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_Values'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_ClearWeakRefs'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyInt_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `_PyObject_New'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyInt_FromLong'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_New'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyRun_StringFlags'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceAdd'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyImport_Import'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyFile_FromString'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyErr_NewException'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `_Py_NotImplementedStruct'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_GetItem'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyEval_GetGlobals'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyExc_ReferenceError'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_SetItem'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_Items'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `_PyEval_SliceIndex'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_GetItemString'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_Lshift'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyBool_FromLong'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_Divide'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyFloat_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyExc_IndexError'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_Rshift'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceSubtract'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyIter_Next'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyString_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyExc_StopIteration'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyType_GenericAlloc'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyDict_Update'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_CallMethod'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceAnd'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_GetAttrString'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyMem_Malloc'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyList_New'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyErr_Format'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyObject_SetAttr'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceXor'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyCFunction_NewEx'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyLong_FromUnsignedLong'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyStaticMethod_Type'
/home/rg203/work/boost_1_62_0/stage/lib/libboost_python.so: undefined reference to `PyTuple_Size'
collect2: error: ld returned 1 exit status
Makefile:30: recipe for target 'mxnet_to_caffe' failed
make: *** [mxnet_to_caffe] Error 1

Is this still an issue with linking boost-python?
Here is my Makefile for reference:

TARGET=./mxnet_to_caffe

include config.mk

OBJSCPP = \
objs/mxnet_to_caffe.o \
objs/mxnet_my_c_predict_api.o 

CC = g++
LINKER = g++

# CAFFE DEPS
CAFFE_DEPENDENCES= -Wl,--whole-archive $(LIBCAFFE)/build/lib/libcaffe.a -Wl,--no-whole-archive -lprotobuf -lglog -lgflags -llmdb -lleveldb /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_hl.so -lboost_system -lboost_thread -lboost_python -I/home/rg203/work/boost_1_62_0
CAFFE_DEPENDENCES+=-lopenblas # BLAS library
CAFFE_DEPENDENCES+= -L/usr/local/cuda/lib64 -lcudart -lcublas -lcurand -lcudnn -L/home/rg203/work/boost_1_62_0/stage/lib # If Caffe was compiled with GPU, this line is necessary 

# MXNet DEPS
MXNET_INCLUDE= -I$(MXNET_ROOT)/include -I$(MXNET_ROOT)/dmlc-core/include -I$(MXNET_ROOT)/mshadow -I$(MXNET_ROOT)/src/c_api

FLAGS_INCLUDE = `pkg-config --cflags opencv` -I$(LIBCAFFE)/include -I/usr/local/cuda/include $(MXNET_INCLUDE) -I/home/rg203/work/boost_1_62_0
FLAGS_COMPILER =  -c -g -Wall -Wno-deprecated -Wno-reorder -Wno-unused-function -fmessage-length=0 -std=c++0x $(FLAGS_INCLUDE) -Wno-unknown-pragmas
FLAGS_LINKER =  -lm -lboost_serialization -lboost_filesystem -fopenmp $(CAFFE_DEPENDENCES) $(MXNET_ROOT)/lib/libmxnet.so `pkg-config --libs opencv` -L/home/rg203/work/boost_1_62_0/stage/lib -lboost_python

############################################

all: $(TARGET)
    @echo 'Compilation finished!'

$(TARGET) : $(OBJSCPP) 
    @echo 'Linking: $@'
    $(LINKER) $(OBJSCPP) $(FLAGS_LINKER) -o "$@"
    @echo 'End linking: $@'
    @echo ' '

$(OBJSCPP): ./objs/%.o : ./src/%.cpp
    @echo 'Compiling $< ...'
    $(CC) $(FLAGS_COMPILER) -o "./$@" "./$<"
    @echo 'End compilation: $<'
    @echo ' '

clean: 
    @echo 'Cleaning '
    rm -f *.o
    @echo 'Cleaning '
    rm -f $(TARGET)

Thanks for the help!

@pertusa
Copy link
Owner

pertusa commented Nov 7, 2016

Ok, it seems from your Makefile that boost was not installed using apt-get or other package managers, but directly downloaded to a folder boost_1_62_0 and compiled there. The most straightforward solution to fix this problem is to install all required libboost-dev using apt-get instead.

However, if you wish to keep boost in a folder, you can try to add also -lboost_system and the path to that folder adding -DBOOST_DIR="boost installation location" to the CAFFE_DEPENDENCES.

This error may also arise if there is already a Boost install in /usr/lib/ that will be incompatible with your self-installed Python (GalSim-developers/GalSim#270).

@RishabGargeya
Copy link
Author

Hello,

I tried adding the -DBOOST_DIR flag, but I get the same error.
I also tried using a boost install from apt-get to see if that works instead. Unfortunately, I get the same error when using libboost-dev from apt-get.
I ran sudo apt-get install libboost-all-dev to install boost.
I then recompiled caffe to use that boost install instead of the boost version I downloaded to a folder.

Here is the error I get when running make to install this converter using apt-get boost:

Linking: mxnet_to_caffe
g++ objs/mxnet_to_caffe.o objs/mxnet_my_c_predict_api.o  -lm -lboost_serialization -lboost_filesystem -fopenmp -Wl,--whole-archive /home/rg203/work/caffe/build/lib/libcaffe.a -Wl,--no-whole-archive -lprotobuf -lglog -lgflags -llmdb -lleveldb /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_hl.so -lboost_system -lboost_thread -lboost_python  -lopenblas  -L/usr/local/cuda/lib64 -lcudart -lcublas -lcurand -lcudnn  /home/rg203/work/mxnet/lib/libmxnet.so `pkg-config --libs opencv`  -o "mxnet_to_caffe"
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::api::object::object()':
/usr/include/boost/python/object_core.hpp:504: undefined reference to `_Py_NoneStruct'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::shared_ptr<caffe::Layer<float> > caffe::GetPythonLayer<float>(caffe::LayerParameter const&)':
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:244: undefined reference to `Py_Initialize'
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:250: undefined reference to `PyErr_Print'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::shared_ptr<caffe::Layer<double> > caffe::GetPythonLayer<double>(caffe::LayerParameter const&)':
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:244: undefined reference to `Py_Initialize'
/home/rg203/work/caffe/src/caffe/layer_factory.cpp:250: undefined reference to `PyErr_Print'
/home/rg203/work/caffe/build/lib/libcaffe.a(layer_factory.o): In function `boost::python::detail::returnable<boost::python::api::object>::type boost::python::call<boost::python::api::object, caffe::LayerParameter>(_object*, caffe::LayerParameter const&, boost::type<boost::python::api::object>*)':
/usr/include/boost/python/call.hpp:66: undefined reference to `PyEval_CallFunction'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyUnicodeUCS4_FromEncodedObject'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_InPlaceDivide'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_InPlaceRemainder'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PySlice_New'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyList_Sort'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PySequence_GetSlice'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_SetAttrString'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyType_IsSubtype'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyList_Insert'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyExc_RuntimeError'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyComplex_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_Copy'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_Size'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyString_Size'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyUnicode_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyStaticMethod_New'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyList_Reverse'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyErr_NoMemory'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyString_FromStringAndSize'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyBaseObject_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyList_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyModule_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_InPlaceLshift'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_Keys'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyString_InternFromString'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_Subtract'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_DelItem'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_InPlaceMultiply'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `_PyType_Lookup'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyErr_Clear'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyArg_ParseTupleAndKeywords'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyCallable_Check'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_Xor'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyLong_AsUnsignedLongLong'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyInt_AsLong'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyErr_ExceptionMatches'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyMethod_New'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyUnicodeUCS4_AsWideChar'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_Or'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_InPlaceOr'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyExc_TypeError'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyComplex_RealAsDouble'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyErr_SetObject'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyLong_AsUnsignedLong'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PySequence_DelSlice'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyType_Ready'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_IsTrue'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_Add'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyTuple_GetItem'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_Clear'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_Size'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_RichCompare'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyLong_AsLongLong'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyBool_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_Multiply'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyErr_WarnEx'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyString_AsString'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_GetAttr'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyTuple_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyCFunction_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_GetItem'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyMethod_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyTuple_New'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_InPlaceRshift'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyString_FromFormat'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyExc_ImportError'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyExc_AttributeError'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyErr_Occurred'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyWeakref_NewRef'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_Remainder'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyComplex_ImagAsDouble'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyExc_ValueError'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_And'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PySequence_SetSlice'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyImport_ImportModule'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyExc_OverflowError'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyClass_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyLong_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyString_FromString'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyRun_FileExFlags'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyFile_AsFile'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_CallFunction'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyErr_SetString'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_IsInstance'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `Py_InitModule4_64'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyList_Append'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyMem_Free'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyType_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyProperty_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_Values'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_ClearWeakRefs'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyInt_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `_PyObject_New'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyInt_FromLong'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_New'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyRun_StringFlags'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_InPlaceAdd'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyImport_Import'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyFile_FromString'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyErr_NewException'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `_Py_NotImplementedStruct'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_GetItem'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyEval_GetGlobals'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyExc_ReferenceError'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_SetItem'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_Items'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `_PyEval_SliceIndex'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_GetItemString'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_Lshift'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyBool_FromLong'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_Divide'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyFloat_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyExc_IndexError'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_Rshift'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_InPlaceSubtract'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyIter_Next'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyString_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyExc_StopIteration'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyType_GenericAlloc'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyDict_Update'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_CallMethod'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_InPlaceAnd'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_GetAttrString'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyMem_Malloc'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyList_New'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyErr_Format'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyObject_SetAttr'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyNumber_InPlaceXor'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyCFunction_NewEx'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyLong_FromUnsignedLong'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyStaticMethod_Type'
/usr/lib/x86_64-linux-gnu/libboost_python.so: undefined reference to `PyTuple_Size'
collect2: error: ld returned 1 exit status
Makefile:30: recipe for target 'mxnet_to_caffe' failed
make: *** [mxnet_to_caffe] Error 1

As well, here is my Makefile:

TARGET=./mxnet_to_caffe

include config.mk

OBJSCPP = \
objs/mxnet_to_caffe.o \
objs/mxnet_my_c_predict_api.o 

CC = g++
LINKER = g++

# CAFFE DEPS
CAFFE_DEPENDENCES= -Wl,--whole-archive $(LIBCAFFE)/build/lib/libcaffe.a -Wl,--no-whole-archive -lprotobuf -lglog -lgflags -llmdb -lleveldb /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_hl.so -lboost_system -lboost_thread -lboost_python 
CAFFE_DEPENDENCES+=-lopenblas # BLAS library
CAFFE_DEPENDENCES+= -L/usr/local/cuda/lib64 -lcudart -lcublas -lcurand -lcudnn # If Caffe was compiled with GPU, this line is necessary 

# MXNet DEPS
MXNET_INCLUDE= -I$(MXNET_ROOT)/include -I$(MXNET_ROOT)/dmlc-core/include -I$(MXNET_ROOT)/mshadow -I$(MXNET_ROOT)/src/c_api

FLAGS_INCLUDE = `pkg-config --cflags opencv` -I$(LIBCAFFE)/include -I/usr/local/cuda/include $(MXNET_INCLUDE) 
FLAGS_COMPILER =  -c -g -Wall -Wno-deprecated -Wno-reorder -Wno-unused-function -fmessage-length=0 -std=c++0x $(FLAGS_INCLUDE) -Wno-unknown-pragmas
FLAGS_LINKER =  -lm -lboost_serialization -lboost_filesystem -fopenmp $(CAFFE_DEPENDENCES) $(MXNET_ROOT)/lib/libmxnet.so `pkg-config --libs opencv` 

############################################

all: $(TARGET)
    @echo 'Compilation finished!'

$(TARGET) : $(OBJSCPP) 
    @echo 'Linking: $@'
    $(LINKER) $(OBJSCPP) $(FLAGS_LINKER) -o "$@"
    @echo 'End linking: $@'
    @echo ' '

$(OBJSCPP): ./objs/%.o : ./src/%.cpp
    @echo 'Compiling $< ...'
    $(CC) $(FLAGS_COMPILER) -o "./$@" "./$<"
    @echo 'End compilation: $<'
    @echo ' '

clean: 
    @echo 'Cleaning '
    rm -f *.o
    @echo 'Cleaning '
    rm -f $(TARGET)

Any ideas? Not sure why I'm still getting this undefined reference error. Thanks for the help!

@pertusa
Copy link
Owner

pertusa commented Nov 10, 2016

The Caffe Makefile has the following definition:

PYTHON_LIBRARIES ?= boost_python python2.7

So I would try to add -lpython2.7 (or the version you have) to the CAFFE_DEPENDENCES. If you can't find it, check this link: http://stackoverflow.com/questions/8400272/usr-bin-ld-cannot-find-lpython2-7. The linking order matters, so it should be included after boost_python.

@lzx1413
Copy link

lzx1413 commented Dec 5, 2016

@pertusa that works!

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

3 participants