我在Ubunutu 17.10上安装Caffe。我在cmake编译期间遇到错误:
[ 72%] Building CXX object
src/caffe/CMakeFiles/caffe.dir/util/signal_handler.cpp.o
[ 72%] Building CXX object
src/caffe/CMakeFiles/caffe.dir/util/upgrade_proto.cpp.o
[ 74%] Linking CXX shared library ../../lib/libcaffe.so
/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_hl.so: error adding symbols:
File in wrong format
collect2: error: ld returned 1 exit status
src/caffe/CMakeFiles/caffe.dir/build.make:2745: recipe for target
'lib/libcaffe.so.1.0.0' failed
make[2]: *** [lib/libcaffe.so.1.0.0] Error 1
CMakeFiles/Makefile2:267: recipe for target
'src/caffe/CMakeFiles/caffe.dir/all'
failed
make[1]: *** [src/caffe/CMakeFiles/caffe.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
来自cmake的输出-- Boost version: 1.62.0
-- Found the following Boost libraries:
-- system
-- thread
-- filesystem
-- chrono
-- date_time
-- atomic
-- Found gflags (include: /usr/local/include, library:
/usr/local/lib/libgflags.so)
-- Found glog (include: /usr/local/include, library: /usr/local/lib/libglog.so)
-- Found PROTOBUF Compiler: /usr/bin/protoc
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
-- HDF5: Using hdf5 compiler wrapper to determine CXX configuration
-- Found lmdb (include: /usr/local/include, library: /usr/local/lib/liblmdb.so)
-- Found LevelDB (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libleveldb.so)
-- Found Snappy (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libsnappy.so)
CMake Warning at cmake/Dependencies.cmake:82 (message):
-- CUDA is not detected by cmake. Building without it...
Call Stack (most recent call first):
CMakeLists.txt:46 (include)
-- OpenCV found (/usr/share/OpenCV)
-- Found Atlas (include: /usr/include/x86_64-linux-gnu library: /usr/lib/x86_64-linux-gnu/libatlas.so lapack: /usr/lib/x86_64-linux-gnu/liblapack.so
-- NumPy ver. 1.12.1 found (include: /usr/lib/python2.7/dist-packages/numpy/core/include)
-- Boost version: 1.62.0
-- Found the following Boost libraries:
-- python
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
--
-- ******************* Caffe Configuration Summary *******************
-- General:
-- Version : 1.0.0
-- Git : 1.0-87-g5c6a2905-dirty
-- System : Linux
-- C++ compiler : /usr/bin/c++
-- Release CXX flags : -O3 -DNDEBUG -fPIC -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
-- Debug CXX flags : -g -fPIC -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
-- Build type : Release
-- BUILD_SHARED_LIBS : ON
-- BUILD_python : ON
-- BUILD_matlab : OFF
-- BUILD_docs : ON
-- CPU_ONLY : ON
-- USE_OPENCV : ON
-- USE_LEVELDB : ON
-- USE_LMDB : ON
-- USE_NCCL : OFF
-- ALLOW_LMDB_NOLOCK : OFF
-- Dependencies:
-- BLAS : Yes (Atlas)
-- Boost : Yes (ver. 1.62)
-- glog : Yes
-- gflags : Yes
-- protobuf : Yes (ver. 3.0.0)
-- lmdb : Yes (ver. 0.9.70)
-- LevelDB : Yes (ver. 1.20)
-- Snappy : Yes (ver. ..)
-- OpenCV : Yes (ver. 3.1.0)
-- CUDA : No
-- Python:
-- Interpreter : /usr/bin/python2.7 (ver. 2.7.14)
-- Libraries : /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.14)
-- NumPy : /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.12.1)
-- Documentaion:
-- Doxygen : No
-- config_file :
-- Install:
-- Install path : /home/caffe/build/install
-- Configuring done
-- Generating done
-- Build files have been written to: /home/caffe/build
CPU_ONLY := 1
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
# ---[ Includes
set(${CMAKE_CXX_FLAGS} "-D_FORCE_INLINES ${CMAKE_CXX_FLAGS}")
BUILD_SHARED_LIBS:BOOL = ON CMAKE_CXX_FLAGS:STRING = -fPIC
如果我尝试使用make all命令构建caffe - 获取错误:
LD -o .build_release/lib/libcaffe.so.1.0.0
g++ -shared -o .build_release/lib/libcaffe.so.1.0.0 .build_release/src/caffe/proto/caffe.pb.o .build_release/src/caffe/layer_factory.o .build_release/src/caffe/net.o .build_release/src/caffe/layers/lrn_layer.o.build_release/src/caffe/layers/hdf5_data_layer.o .build_release/src/caffe/layers/image_data_layer.o .build_release/src/caffe/layers/eltwise_layer.o .build_release/src/caffe/layers/memory_data_layer.o .build_release/src/caffe/layers/dummy_data_layer.o .build_release/src/caffe/layers/reduction_layer.o .build_release/src/caffe/layers/silence_layer.o .build_release/src/caffe/layers/neuron_layer.o .build_release/src/caffe/layers/elu_layer.o .build_release/src/caffe/layers/slice_layer.o .build_release/src/caffe/layers/hdf5_output_layer.o .build_release/src/caffe/layers/cudnn_sigmoid_layer.o .build_release/src/caffe/layers/absval_layer.o .build_release/src/caffe/layers/window_data_layer.o .build_release/src/caffe/layers/cudnn_softmax_layer.o .build_release/src/caffe/layers/relu_layer.o .build_release/src/caffe/layers/recurrent_layer.o .build_release/src/caffe/layers/cudnn_lcn_layer.o .build_release/src/caffe/layers/infogain_loss_layer.o .build_release/src/caffe/layers/threshold_layer.o .build_release/src/caffe/layers/embed_layer.o .build_release/src/caffe/layers/cudnn_tanh_layer.o .build_release/src/caffe/layers/spp_layer.o .build_release/src/caffe/layers/cudnn_conv_layer.o .build_release/src/caffe/layers/sigmoid_cross_entropy_loss_layer.o .build_release/src/caffe/layers/argmax_layer.o .build_release/src/caffe/layers/input_layer.o .build_release/src/caffe/layers/cudnn_relu_layer.o .build_release/src/caffe/layers/lstm_unit_layer.o .build_release/src/caffe/layers/inner_product_layer.o .build_release/src/caffe/layers/batch_reindex_layer.o .build_release/src/caffe/layers/flatten_layer.o .build_release/src/caffe/layers/cudnn_lrn_layer.o .build_release/src/caffe/layers/base_conv_layer.o .build_release/src/caffe/layers/batch_norm_layer.o .build_release/src/caffe/layers/im2col_layer.o .build_release/src/caffe/layers/concat_layer.o .build_release/src/caffe/layers/tanh_layer.o .build_release/src/caffe/layers/cudnn_deconv_layer.o .build_release/src/caffe/layers/dropout_layer.o .build_release/src/caffe/layers/power_layer.o .build_release/src/caffe/layers/bias_layer.o .build_release/src/caffe/layers/hinge_loss_layer.o .build_release/src/caffe/layers/contrastive_loss_layer.o .build_release/src/caffe/layers/loss_layer.o .build_release/src/caffe/layers/prelu_layer.o .build_release/src/caffe/layers/conv_layer.o .build_release/src/caffe/layers/parameter_layer.o .build_release/src/caffe/layers/sigmoid_layer.o .build_release/src/caffe/layers/tile_layer.o .build_release/src/caffe/layers/reshape_layer.o .build_release/src/caffe/layers/pooling_layer.o .build_release/src/caffe/layers/rnn_layer.o .build_release/src/caffe/layers/log_layer.o .build_release/src/caffe/layers/cudnn_pooling_layer.o .build_release/src/caffe/layers/mvn_layer.o .build_release/src/caffe/layers/split_layer.o .build_release/src/caffe/layers/scale_layer.o .build_release/src/caffe/layers/bnll_layer.o .build_release/src/caffe/layers/accuracy_layer.o .build_release/src/caffe/layers/filter_layer.o .build_release/src/caffe/layers/base_data_layer.o .build_release/src/caffe/layers/lstm_layer.o .build_release/src/caffe/layers/multinomial_logistic_loss_layer.o .build_release/src/caffe/layers/euclidean_loss_layer.o .build_release/src/caffe/layers/exp_layer.o .build_release/src/caffe/layers/data_layer.o .build_release/src/caffe/layers/softmax_layer.o .build_release/src/caffe/layers/softmax_loss_layer.o .build_release/src/caffe/layers/deconv_layer.o .build_release/src/caffe/layers/crop_layer.o .build_release/src/caffe/common.o .build_release/src/caffe/solvers/adam_solver.o .build_release/src/caffe/solvers/adadelta_solver.o .build_release/src/caffe/solvers/sgd_solver.o .build_release/src/caffe/solvers/rmsprop_solver.o .build_release/src/caffe/solvers/adagrad_solver.o .build_release/src/caffe/solvers/nesterov_solver.o .build_release/src/caffe/internal_thread.o .build_release/src/caffe/parallel.o .build_release/src/caffe/blob.o .build_release/src/caffe/layer.o .build_release/src/caffe/solver.o .build_release/src/caffe/data_transformer.o .build_release/src/caffe/syncedmem.o .build_release/src/caffe/util/db.o .build_release/src/caffe/util/math_functions.o .build_release/src/caffe/util/insert_splits.o .build_release/src/caffe/util/signal_handler.o .build_release/src/caffe/util/cudnn.o .build_release/src/caffe/util/db_leveldb.o .build_release/src/caffe/util/upgrade_proto.o .build_release/src/caffe/util/hdf5.o .build_release/src/caffe/util/benchmark.o .build_release/src/caffe/util/blocking_queue.o .build_release/src/caffe/util/io.o .build_release/src/caffe/util/im2col.o .build_release/src/caffe/util/db_lmdb.o -Wl,-soname,libcaffe.so.1.0.0 -Wl,-rpath,\$ORIGIN/../lib -pthread -fPIC -DCAFFE_VERSION=1.0.0 -DNDEBUG -O2 -DUSE_OPENCV -DUSE_LEVELDB -DUSE_LMDB -DCPU_ONLY -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include -I/usr/include/hdf5/serial -I.build_release/src -I./src -I./include -Wall -Wno-sign-compare -L/usr/lib -L/usr/local/lib -L/usr/lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/hdf5/serial -L.build_release/lib -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_hdf -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_viz -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core -lglog -lgflags -lprotobuf -lboost_system -lboost_filesystem -lm -lhdf5_serial_hl -lhdf5_serial -lleveldb -lsnappy -llmdb -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lboost_thread -lstdc++ -lcblas -latlas
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libhdf5_serial_hl.so when searching for -lhdf5_serial_hl
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libhdf5_serial_hl.a(H5LTanalyze.o): relocation R_X86_64_PC32 against symbol `H5LTyyin' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Makefile:572: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1
我不明白如何解决此错误。任何帮助将不胜感激!