tensorrtx icon indicating copy to clipboard operation
tensorrtx copied to clipboard

yolov5 编译错误

Open Y-pandaman opened this issue 1 year ago • 1 comments

Env

  • GPU, RTX3060
  • OS, Ubuntu18.04
  • Cuda version 11.4
  • TensorRT version 8.2.5.1

About this repo

  • which branch/tag/commit are you using?
  • which model? yolov5

Your problem

  • what is your command? e.g. sudo ./yolov5 -s
  • what's your output?
  • what output do you expect?

请问yolov5_trt 中的myplugins库很重要吗?我链接到自己的程序里后,会报如下的错:

CMake Error: install(EXPORT "EXPORT_xict_cpp" ...) includes target "xict_cpp" which requires target "myplugins" that is not in any export set.
CMake Error in CMakeLists.txt:
  export called with target "xict_cpp" which requires target "myplugins" that
  is not in any export set.

我添加了$<BUILD_INTERFACE:not_exported>这个指令也没用,我的部分cmakelists如下:

include_directories(${PROJECT_SOURCE_DIR}/include/xict_cpp/perception/plugin/ ${PROJECT_SOURCE_DIR}/include/xict_cpp/perception/common/)
file(GLOB_RECURSE PLUGIN_SRCS ${PROJECT_SOURCE_DIR}/src/xict_cpp/perception/plugin/*.cu)
add_library(myplugins SHARED ${PLUGIN_SRCS})
target_link_libraries(myplugins PRIVATE $<BUILD_INTERFACE:not_exported>)
xict_cc_library(
  NAME
  ${PROJECT_NAME}
  SRCS
  ${src_files}
  INCLUDES
  ${OpenCV_INCLUDE_DIRS}
  ${GST_INCLUDE_DIRS}
  ${OpenSSL_INCLUDE_DIR}
  ${EXTRA_INCLUDES}
  DEPS
  dl
  Threads::Threads
  Eigen3::Eigen
  ${OpenCV_LIBS}
  ${GST_LIBRARIES}
  fmt::fmt
  absl::flags
  eCAL::core
  protobuf::libprotobuf
  nvinfer
  cudart
  myplugins
  absl::flags_parse
  ${OPENSSL_LIBRARIES}
  ${EXTRA_DEPS})
function(xict_cc_library)
  cmake_parse_arguments(
    XICT_CC_LIB "" "NAME" "HDRS;SRCS;COPTS;DEFINES;LINKOPTS;INCLUDES;DEPS"
    ${ARGN})

  set(_NAME "${XICT_CC_LIB_NAME}")

  # ==============#
  # Build targets #
  # ==============#

  # common library
  add_library(${_NAME} ${XICT_CC_LIB_SRCS} ${XICT_CC_LIB_HDRS})
  add_library(${PROJECT_NAME}::${_NAME} ALIAS ${_NAME})

  # generate a header with export macros, which is written to the
  # CMAKE_CURRENT_BINARY_DIR location.
  generate_export_header(${_NAME})

  target_include_directories(
    ${_NAME}
    PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
           "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
           "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
           ${XICT_CC_LIB_INCLUDES})

  target_link_libraries(
    ${_NAME}
    PUBLIC ${XICT_CC_LIB_DEPS}
    PRIVATE ${XICT_CC_LIB_LINKOPTS})

  # compiling options
  target_compile_options(${_NAME} PRIVATE ${XICT_CC_LIB_COPTS})
  if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    target_compile_options(${_NAME} PRIVATE -Wall -Wextra -Wpedantic
                                            -Wno-unused-parameter)
  elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
    target_compile_options(${_NAME} PRIVATE /W4)
  endif()
  if(MSVC)
    # Force include the export header when using Microsoft Visual C++ compiler.
    target_compile_options(
      ${_NAME} PUBLIC "/FI${CMAKE_CURRENT_BINARY_DIR}/${_NAME}_export.h")
  endif()

  # compiling definitions
  target_compile_definitions(${_NAME} PUBLIC ${XICT_CC_LIB_DEFINES})
  if(NOT BUILD_SHARED_LIBS)
    target_compile_definitions(${_NAME} PUBLIC "XICT_COMMON_STATIC_DEFINE")
  endif()

  # compiling features
  target_compile_features(${_NAME} PRIVATE cxx_std_14)

  # =============================#
  # CMake package configurations #
  # =============================#

  include(CMakePackageConfigHelpers)

  # Create the ${_NAME}Config.cmake file, which is used by other packages to
  # find this package and its dependencies.
  configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake"
    "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_NAME}Config.cmake" @ONLY)

  # Create the ${_NAME}ConfigVersion.cmake.
  write_basic_package_version_file(
    "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_NAME}ConfigVersion.cmake"
    COMPATIBILITY AnyNewerVersion)

  # ==============#
  # Install files #
  # ==============#

  include(GNUInstallDirs)

  install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${_NAME}_export.h"
          DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_NAME}")

  install(
    FILES
      "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_NAME}Config.cmake"
      "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_NAME}ConfigVersion.cmake"
      "${CMAKE_CURRENT_SOURCE_DIR}/package.xml"
    DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${_NAME}")

  install(
    TARGETS ${_NAME}
    EXPORT EXPORT_${_NAME}
    ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

  install(
    EXPORT EXPORT_${_NAME}
    DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${_NAME}"
    NAMESPACE ${PROJECT_NAME}::
    FILE ${_NAME}Targets.cmake)

  # ===============#
  # Export targets #
  # ===============#

  export(
    EXPORT EXPORT_${_NAME}
    NAMESPACE ${PROJECT_NAME}::
    FILE "${PROJECT_BINARY_DIR}/${_NAME}Targets.cmake")

endfunction()

请问有什么好的解决方法?

Y-pandaman avatar Dec 28 '23 12:12 Y-pandaman

mypluin是必须的,可以查下cmake怎么编译cuda代码

wang-xinyu avatar Jan 03 '24 10:01 wang-xinyu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 03 '24 16:03 stale[bot]