Giter Site home page Giter Site logo

midas-cpp's Issues

Problem when link ld_libraries to inference_midas

Hi, I meet a problem during link

/usr/bin/ld: CMakeFiles/midas_inference.dir/src/inference_midas.cpp.o: in function main':
inference_midas.cpp:(.text.startup+0x6c): undefined reference to cv::imread(std::string const&, int)' /usr/bin/ld: inference_midas.cpp:(.text.startup+0x350): undefined reference to cv::namedWindow(std::string const&, int)'
/usr/bin/ld: inference_midas.cpp:(.text.startup+0x3a2): undefined reference to cv::imshow(std::string const&, cv::_InputArray const&)' collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/midas_inference.dir/build.make:155: midas_inference] Error 1 make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/midas_inference.dir/all] Error 2 make: *** [Makefile:84: all] Error 2

enviroment:
Ubuntu 20.04
opencv 4.5.2

What I have tried:
1.re-compile the opencv lib from source, and add the path to CMAKE_PREFIX_PATH, and output the include_dir of opencv, it seems alright, but I still meet the problem above, the output of cmake is

`-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found version "11.1")
-- Caffe2: CUDA detected: 11.1
-- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda
-- Caffe2: Header version is: 11.1
-- Found CUDNN: /usr/local/cuda/lib64/libcudnn.so
-- Found cuDNN: v8.0.4 (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so)
CMake Warning at /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/share/cmake/Caffe2/public/cuda.cmake:198 (message):
Failed to compute shorthash for libnvrtc.so
Call Stack (most recent call first):
/home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:88 (include)
/home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
CMakeLists.txt:18 (FIND_PACKAGE)

-- Autodetected CUDA architecture(s): 8.6
-- Added CUDA NVCC flags for: -gencode;arch=compute_86,code=sm_86
-- Found Torch: /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/lib/libtorch.so
-- Found OpenCV: /usr/local (found suitable version "4.5.2", minimum required is "4")
-- Found PythonLibs: /home/kunbpc/Installed/Anaconda3/lib/libpython3.8.so (found version "3.8.5")
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: python numpy
-- OpenCV_INCLUDE_DIRS : /usr/local/include/opencv4
-- TORCH_LIBRARIES : torchtorch_library/home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/lib/libc10.so/usr/local/cuda/lib64/stubs/libcuda.so/usr/local/cuda/lib64/libnvrtc.so/usr/local/cuda/lib64/libnvToolsExt.so/usr/local/cuda/lib64/libcudart.so/home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/lib/libc10_cuda.so
-- TORCH_INCLUDE_DIRS : /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/torch/csrc/api/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kunbpc/Codes/depth/MiDaS-cpp/build`

  1. I have tried to add a linker flag in cmakelist.txt, it is useless and I comments out it then.

SET(GGC_OPENCV_LINK_FLAG "-lopencv_highgui") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GGC_OPENCV_LINK_FLAG}")

make error: undefined reference to opencv

Hi, I'm trying to compile your code using c++17 and opencv4.2. But I've been encountering an linking error:


[100%] Linking CXX executable midas_inference
/usr/bin/ld: CMakeFiles/midas_inference.dir/src/inference_midas.cpp.o: in function `main':
inference_midas.cpp:(.text.startup+0x6c): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: inference_midas.cpp:(.text.startup+0x428): undefined reference to `cv::namedWindow(std::string const&, int)'
/usr/bin/ld: inference_midas.cpp:(.text.startup+0x47a): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
/usr/bin/ld: libmidas_lib.so: undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/midas_inference.dir/build.make:149: midas_inference] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/midas_inference.dir/all] Error 2
make: *** [Makefile:85: all] Error 2

Do you have any idea how to fix this?

error: ‘apply’ is not a member of ‘c10::maybe_real<true, c10::complex<double> >’

Hi,
I meet 2 problems

  1. during cmake, I received 2 warnings in ADD_EXECUTABLE

`CMake Warning at CMakeLists.txt:33 (ADD_EXECUTABLE):
Cannot generate a safe runtime search path for target midas_inference
because there is a cycle in the constraint graph:

dir 0 is [/home/kunbpc/Codes/depth/MiDaS-cpp/build]
dir 1 is [/home/kunbpc/Installed/Anaconda3/envs/pytorch/lib]
  dir 3 must precede it due to runtime library [libcufft.so.10]
dir 2 is [/home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/lib]
dir 3 is [/usr/local/cuda/lib64]
  dir 1 must precede it due to runtime library [libnvToolsExt.so.1]
dir 4 is [/usr/local/cuda/lib64/stubs]

Some of these libraries may not be found correctly.

CMake Warning at CMakeLists.txt:30 (ADD_LIBRARY):
Cannot generate a safe runtime search path for target midas_lib because
there is a cycle in the constraint graph:

dir 0 is [/home/kunbpc/Installed/Anaconda3/envs/pytorch/lib]
  dir 3 must precede it due to runtime library [libcudart.so.11.0]
dir 1 is [/home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/lib]
dir 2 is [/usr/local/cuda/lib64/stubs]
dir 3 is [/usr/local/cuda/lib64]
  dir 0 must precede it due to runtime library [libnvToolsExt.so.1]

Some of these libraries may not be found correctly.
`
2. In make, there are many errors, and the last one is

In file included from /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/core/Scalar.h:13, from /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/ATen/core/TensorBody.h:8, from /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/ATen/Tensor.h:3, from /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/ATen/Context.h:4, from /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/ATen/ATen.h:9, from /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/torch/csrc/api/include/torch/types.h:3, from /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/torch/script.h:3, from /home/kunbpc/Codes/depth/MiDaS-cpp/include/midas/midas.h:34, from /home/kunbpc/Codes/depth/MiDaS-cpp/src/midas.cpp:27: /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/util/TypeCast.h: In instantiation of ‘static dest_t c10::static_cast_with_inter_type<dest_t, src_t>::apply(src_t) [with dest_t = bool; src_t = c10::complex<double>]’: /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/util/TypeCast.h:157:54: required from ‘To c10::convert(From) [with To = bool; From = c10::complex<double>]’ /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/util/TypeCast.h:169:27: required from ‘To c10::checked_convert(From, const char*) [with To = bool; From = c10::complex<double>]’ /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/core/Scalar.h:63:3: required from here /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/util/TypeCast.h:39:62: error: ‘apply’ is not a member of ‘c10::maybe_real<true, c10::complex<double> >’ 39 | return static_cast<dest_t>(maybe_real<real, src_t>::apply(src)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/util/TypeCast.h: In instantiation of ‘static dest_t c10::static_cast_with_inter_type<dest_t, src_t>::apply(src_t) [with dest_t = c10::BFloat16; src_t = c10::complex<double>]’: /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/util/TypeCast.h:157:54: required from ‘To c10::convert(From) [with To = c10::BFloat16; From = c10::complex<double>]’ /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/util/TypeCast.h:169:27: required from ‘To c10::checked_convert(From, const char*) [with To = c10::BFloat16; From = c10::complex<double>]’ /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/core/Scalar.h:63:3: required from here /home/kunbpc/Installed/libtorch/libtorch-shared-with-deps-1.8.0+cu111/libtorch/include/c10/util/TypeCast.h:39:62: error: ‘apply’ is not a member of ‘c10::maybe_real<true, c10::complex<double> >’ make[2]: *** [CMakeFiles/midas_lib.dir/build.make:63: CMakeFiles/midas_lib.dir/src/midas.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/midas_lib.dir/all] Error 2 make: *** [Makefile:84: all] Error 2

How can I fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.