libtorch-yolov3 icon indicating copy to clipboard operation
libtorch-yolov3 copied to clipboard

error in main.cpp

Open a819411321 opened this issue 5 years ago • 6 comments

I downlown the code and run in Ubuntu16.06 my cmakelist is ` cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(yolo-app)

set(CMAKE_CXX_STANDARD 14) set(Torch_DIR /home/zyy/libtorch/share/cmake/Torch) set(OpenCV_DIR /home/tusvision/Downloads/opencv-3.4/opencv/build)

find_package(Torch REQUIRED) find_package(OpenCV REQUIRED)

add_executable(yolo-app main.cpp) target_link_libraries(yolo-app "${TORCH_LIBRARIES}" "${OpenCV_LIBS}") set_property(TARGET yolo-app PROPERTY CXX_STANDARD 11) ` My folder is yolo-app/main.cpp 、darknet.h darknet.cpp

cmake . Usage

cmake [options] cmake [options]

Specify a source directory to (re-)generate a build system for it in the current working directory. Specify an existing build directory to re-generate its build system.

Run 'cmake --help' for more information.

zyy@TusVision:~/yolo-app$ cmake . -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- 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 suitable version "9.0", minimum required is "7.0") -- Caffe2: CUDA detected: 9.0 -- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc -- Caffe2: CUDA toolkit directory: /usr/local/cuda -- Caffe2: Header version is: 9.0 -- Found CUDNN: /usr/local/cuda/include
-- Found cuDNN: v7.2.1 (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so) -- Autodetected CUDA architecture(s): 6.1;6.1 -- Added CUDA NVCC flags for: -gencode;arch=compute_61,code=sm_61 -- Found torch: /home/zyy/libtorch/lib/libtorch.so
-- Found OpenCV: /home/tusvision/Downloads/opencv-3.4/opencv/build (found version "3.4.1") -- Configuring done -- Generating done -- Build files have been written to: /home/zyy/yolo-app

make zyy@TusVision:~/yolo-app$ make Scanning dependencies of target yolo-app [ 50%] Building CXX object CMakeFiles/yolo-app.dir/main.cpp.o [100%] Linking CXX executable yolo-app CMakeFiles/yolo-app.dir/main.cpp.o: In function main': main.cpp:(.text+0xc1b): undefined reference to Darknet::Darknet(char const*, c10::Device*)' main.cpp:(.text+0xc2a): undefined reference to Darknet::get_net_info()' main.cpp:(.text+0xd09): undefined reference to Darknet::load_weights(char const*)' main.cpp:(.text+0x11ab): undefined reference to Darknet::forward(at::Tensor)' main.cpp:(.text+0x1205): undefined reference to Darknet::write_results(at::Tensor, int, float, float)' collect2: error: ld returned 1 exit status CMakeFiles/yolo-app.dir/build.make:168: recipe for target 'yolo-app' failed make[2]: *** [yolo-app] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/yolo-app.dir/all' failed make[1]: *** [CMakeFiles/yolo-app.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

the main.cpp error

a819411321 avatar Apr 29 '19 02:04 a819411321

I met the same error, did you solve it ?

Arctanxy avatar Jun 20 '19 03:06 Arctanxy

I met the same error, did you solve it ?

Yes I have solved it My cmakelist is error

a819411321 avatar Jun 20 '19 05:06 a819411321

I met the same error, did you solve it ?

Yes I have solved it My cmakelist is error

What's wrong with your cmakelist?

Arctanxy avatar Jun 20 '19 07:06 Arctanxy

I met the same error, did you solve it ?

Yes I have solved it My cmakelist is error

What's wrong with your cmakelist?

首先 不能用opencv4和libtorch cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(yolo-app) find_package(OpenCV REQUIRED) include_directories(${OpenCV _INCLUDE_DIRS}) find_package(Torch REQUIRED) aux_source_directory(. DIR_sRCS) add_executable(yolo-app main.cpp)#注 main.cpp可以换成路径xxx/xxx.cpp target_link_libraries(yolo-app "${TORCH_LIBRARIES}" "${OpenCV_LIBS}") set_property(TARGET yolo-app PROPERTY CXX_STANDARD 11)

a819411321 avatar Jun 20 '19 08:06 a819411321

I met the same error, did you solve it ?

Yes I have solved it My cmakelist is error

What's wrong with your cmakelist?

首先 不能用opencv4和libtorch cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(yolo-app) find_package(OpenCV REQUIRED) include_directories(${OpenCV _INCLUDE_DIRS}) find_package(Torch REQUIRED) aux_source_directory(. DIR_sRCS) add_executable(yolo-app main.cpp)#注 main.cpp可以换成路径xxx/xxx.cpp target_link_libraries(yolo-app "${TORCH_LIBRARIES}" "${OpenCV_LIBS}") set_property(TARGET yolo-app PROPERTY CXX_STANDARD 11)

谢啦,我按你的CMakeList.txt改了下,还是有问题,后来又把main.cpp 改成了 ${DIR_SRCS} 才解决这个问题。

Arctanxy avatar Jun 23 '19 13:06 Arctanxy

I met the same error, did you solve it ?

Yes I have solved it My cmakelist is error

是用-DCMAKE。。。传入Torch的路径吗

sunanlin13174 avatar Jul 12 '20 13:07 sunanlin13174