Open Cuzny opened 2 years ago
附上CMake文件,感激不尽! cmake_minimum_required(VERSION 2.6)
project(plate)
add_definitions(-std=c++11) add_definitions(-DAPI_EXPORTS) set(CMAKE_CXX_STANDARD 11)
find_package(CUDA REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O3 -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")
include_directories(/usr/local/cuda/include) link_directories(/usr/local/cuda/lib64)
set(OpenCV_INCLUDE_DIRS /home/nvidia/opencv-4.3.0/install/include/opencv4) include_directories(${OpenCV_INCLUDE_DIRS}) set(OpenCV_LIBS /home/nvidia/opencv-4.3.0/install/lib) link_directories(${OpenCV_LIBS})
set(NCNN_INCLUDE_DIRS /home/nvidia/ncnn/build/install/include/ncnn) include_directories(${NCNN_INCLUDE_DIRS}) set(NCNN_LIBS /home/nvidia/ncnn/build/install/lib) link_directories(${NCNN_LIBS})
set(Freetype_INCLUDE_DIRS /usr/local/freetype/include/freetype2/) include_directories(${Freetype_INCLUDE_DIRS}) set(Freetype_LIBS /usr/local/freetype/lib/) link_directories(${Freetype_LIBS})
include_directories(${PROJECT_SOURCE_DIR}/../) set(Plate_DIRS /home/nvidia/5.0/sdk_api/src/identify) cuda_add_library(plate1 SHARED ${PROJECT_SOURCE_DIR}/plateocr.cpp ${PROJECT_SOURCE_DIR}/sideparking_plate.cpp)
add_executable(plate ${PROJECT_SOURCE_DIR}/main.cpp ${PROJECT_SOURCE_DIR}/CvxText/CvxText.cpp)
target_link_libraries(plate plate1) target_link_libraries(plate opencv_dnn opencv_core opencv_imgproc opencv_imgcodecs opencv_highgui opencv_videoio opencv_objdetect) target_link_libraries(plate ncnn -lpthread -lm -fopenmp) target_link_libraries(plate freetype)
https://github.com/Tencent/ncnn/wiki/use-ncnn-with-own-project 参考这里的 cmake 写法 我尝试了这样写cmake,但是还是会出现上述的错误,不知道是什么情况 set(ncnn_DIR "/home/nvidia/ncnn/build/install/lib/cmake/ncnn") find_package(ncnn REQUIRED) include_directories("/home/nvidia/ncnn/build/install/include/ncnn") 通过find_package可以连接到lib,但是无法做到include,所以我手动include了一下
https://github.com/Tencent/ncnn/wiki/use-ncnn-with-own-project 参考这里的 cmake 写法 我尝试了这样写cmake,但是还是会出现上述的错误,不知道是什么情况 set(ncnn_DIR "/home/nvidia/ncnn/build/install/lib/cmake/ncnn") find_package(ncnn REQUIRED) include_directories("/home/nvidia/ncnn/build/install/include/ncnn") 通过find_package可以连接到lib,但是无法做到include,所以我手动include了一下
可以这样
add_subdirectory($(NCNN_PROJECT_DIR))
@Cuzny 在使用
set(ncnn_DIR "/home/nvidia/ncnn/build/install/lib/cmake/ncnn")
find_package(ncnn REQUIRED)
的情况下, 请尽量避免再使用link_directories()
, 它和 target_link_libraries()
容易引发冲突。
若正确配置, 则不需要 include_directories("/home/nvidia/ncnn/build/install/include/ncnn")
DaChengTechnology 提到的方式:
add_subdirectory($(NCNN_PROJECT_DIR))
是说把 ncnn 工程源码包含到当前工程中来。
我也遇到这个问题,后面是因为动态库与静态库混用没有指定导致。我的情况是:我有些源文件使用了ncnn(静态)后编译成了动态库。链接时就失败了。我的解决是都编译成静态库,希望对其他人有帮助
Cuda:10.2,aarch64 编译时,出现了大量以下错误信息: undefined reference to 'omp_get_num_threads' undefined reference to 'omp_get_thread_num' undefined reference to 'GOMP_parallel' 使用-fopenmp之后出现以下错误信息: hidden symbol `_ZN4ncnn3Mat18from_pixels_resizeEPKhiiiiiPNS_9AllocatorE' in /home/nvidia/ncnn/build/install/lib/libncnn.a(mat_pixel.cpp.o) is referenced by DSO /usr/bin/ld: final link failed: Bad value