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

Compile error in cv2 python3 binding. multiple definition of caffe::... libopencv_dnn.a(caffe.pb.cc.o):caffe.pb.cc:(...): first defined here #8973

Closed
stablum opened this issue Jun 23, 2017 · 4 comments

Comments

@stablum
Copy link

stablum commented Jun 23, 2017

System information (version)
  • OpenCV => >3.2.0 (actually latest git snapshot)
  • Operating System / Platform => Ubuntu 17.04
  • Compiler => likely the Gnu/gcc/g++ compiler
Detailed description
[ 95%] Linking CXX shared module ../../lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so
../../lib/libopencv_dnn_modern.a(caffe_converter.cpp.o): In function `caffe::BlobShape::SetCachedSize(int) const':
caffe_converter.cpp:(.text._ZNK5caffe9BlobShape13SetCachedSizeEi+0x0): multiple definition of `caffe::BlobShape::SetCachedSize(int) const'
../../lib/libopencv_dnn.a(caffe.pb.cc.o):caffe.pb.cc:(.text._ZNK5caffe9BlobShape13SetCachedSizeEi+0x0): first defined here
../../lib/libopencv_dnn_modern.a(caffe_converter.cpp.o): In function `caffe::BlobShape::IsInitialized() const':
caffe_converter.cpp:(.text._ZNK5caffe9BlobShape13IsInitializedEv+0x0): multiple definition of `caffe::BlobShape::IsInitialized() const'
../../lib/libopencv_dnn.a(caffe.pb.cc.o):caffe.pb.cc:(.text._ZNK5caffe14NormalizedBBox13IsInitializedEv+0x0): first defined here
../../lib/libopencv_dnn_modern.a(caffe_converter.cpp.o): In function `caffe::BlobProto::SetCachedSize(int) const':
caffe_converter.cpp:(.text._ZNK5caffe9BlobProto13SetCachedSizeEi+0x0): multiple definition of `caffe::BlobProto::SetCachedSize(int) const'
../../lib/libopencv_dnn.a(caffe.pb.cc.o):caffe.pb.cc:(.text._ZNK5caffe9BlobProto13SetCachedSizeEi+0x0): first defined here
../../lib/libopencv_dnn_modern.a(caffe_converter.cpp.o): In function `caffe::BlobProto::IsInitialized() const':

(it goes on with hundreds of similar messages)

../../lib/libopencv_dnn_modern.a(caffe_converter.cpp.o):(.rodata+0x4e94): multiple definition of `caffe::BlobShape::kDimFieldNumber'
../../lib/libopencv_dnn.a(caffe.pb.cc.o):(.rodata+0x5794): first defined here
../../lib/libopencv_dnn_modern.a(caffe_converter.cpp.o):(.bss+0x208): multiple definition of `caffe::static_descriptor_initializer_caffe_2eproto_'
../../lib/libopencv_dnn.a(caffe.pb.cc.o):(.bss+0x1a58): first defined here
collect2: error: ld returned 1 exit status
modules/python3/CMakeFiles/opencv_python3.dir/build.make:464: recipe for target 'lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so' failed
make[2]: *** [lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so] Error 1
CMakeFiles/Makefile2:5090: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/all' failed
make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

Steps to reproduce
export CPATH=$CPATH:/usr/include/x86_64-linux-gnu/
cmake \
    --with-ffmpeg \
    -D BUILD_opencv_python3=ON \
    -D HAVE_opencv_python3=ON \
    -D PYTHON3LIBS_VERSION_STRING=3.6m \
    -D PYTHON3_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython3.6m.so \
    -D PYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6im.so \
    -D PYTHON3_INCLUDE_PATH=/usr/include/python3.6m \
    -D PYTHON3_INCLUDE_DIR=/usr/include/python3.6m \
    -D PYTHON3_INCLUDE_DIRS=/usr/include/python3.6m \
    -D PYTHON3_EXECUTABLE=/usr/bin/python3.6m \
    -D PYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython3.6m.so \
    -D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6im.so \
    -D PYTHON_INCLUDE_PATH=/usr/include/python3.6m \
    -D PYTHON_INCLUDE_DIR=/usr/include/python3.6m \
    -D PYTHON_INCLUDE_DIRS=/usr/include/python3.6m \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D BUILD_NEW_PYTHON_SUPPORT=OFF \
    -D INSTALL_C_EXAMPLES=OFF \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=OFF \
    -D ENABLE_PRECOMPILED_HEADERS=OFF \
    -D WITH_FFMPEG=ON \
    -D WITH_TBB=ON \
    -D BUILD_SHARED_LIBS=OFF \
    -D BUILD_TESTS=OFF \
    -D BUILD_PERF_TESTS=OFF \
    -D CUDA_NVCC_FLAGS="-ccbin gcc-5" \
    -D OPENCV_EXTRA_MODULES_PATH=$HOME/Downloads/opencv_contrib/modules \
    -D FFMPEG_INCLUDEDIR=/usr/include/x86_64-linux-gnu/ \
    -D FFMPEG_INCLUDE_DIRS="/usr/local/include;/usr/include/x86_64-linux-gnu/" \
    -D FFMPEG_CFLAGS="-I/usr/local/include -I/usr/include/x86_64-linux-gnu" \
    .. 2>&1 | tee my_cmake.log

@alalek
Copy link
Member

alalek commented Jun 23, 2017

Try to disable dnn_modern module:

cmake -DBUILD_opencv_dnn_modern=OFF ...

@stablum
Copy link
Author

stablum commented Jun 23, 2017

@alalek thank you for the suggestion! Will try and let you know if it worked.

@stablum
Copy link
Author

stablum commented Jun 23, 2017

@alalek it did indeed work! thanks! :)
Anyways, I feel that this issue should stay open because it should be detected by cmake instead of make.

@mshabunin mshabunin added the bug label Jul 24, 2017
@alalek
Copy link
Member

alalek commented Nov 23, 2017

#10092 #10139

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

No branches or pull requests

3 participants