diff --git a/yolov5/API.h b/yolov5/API.h new file mode 100644 index 0000000..e33b461 --- /dev/null +++ b/yolov5/API.h @@ -0,0 +1,14 @@ +#ifdef API_EXPORTS +#if defined(_MSC_VER) +#define API __declspec(dllexport) +#else +#define API __attribute__((visibility("default"))) +#endif +#else + +#if defined(_MSC_VER) +#define API __declspec(dllimport) +#else +#define API +#endif +#endif \ No newline at end of file diff --git a/yolov5/CMakeLists.txt b/yolov5/CMakeLists.txt index 3ebc96b..281e947 100644 --- a/yolov5/CMakeLists.txt +++ b/yolov5/CMakeLists.txt @@ -3,13 +3,17 @@ cmake_minimum_required(VERSION 2.6) project(yolov5) add_definitions(-std=c++11) - +add_definitions(-DAPI_EXPORTS) option(CUDA_USE_STATIC_CUDA_RUNTIME OFF) set(CMAKE_CXX_STANDARD 11) set(CMAKE_BUILD_TYPE Debug) find_package(CUDA REQUIRED) +if(WIN32) +enable_language(CUDA) +endif(WIN32) + include_directories(${PROJECT_SOURCE_DIR}/include) # include and link dirs of cuda and tensorrt, you need adapt them if yours are different # cuda @@ -33,5 +37,7 @@ target_link_libraries(yolov5 cudart) target_link_libraries(yolov5 myplugins) target_link_libraries(yolov5 ${OpenCV_LIBS}) +if(UNIX) add_definitions(-O2 -pthread) +endif(UNIX) diff --git a/yolov5/yololayer.h b/yolov5/yololayer.h index 7224bde..e7e1e20 100644 --- a/yolov5/yololayer.h +++ b/yolov5/yololayer.h @@ -1,6 +1,7 @@ #ifndef _YOLO_LAYER_H #define _YOLO_LAYER_H +#include "API.h" #include #include #include "NvInfer.h" @@ -40,7 +41,7 @@ namespace Yolo namespace nvinfer1 { - class YoloLayerPlugin : public IPluginV2IOExt + class API YoloLayerPlugin : public IPluginV2IOExt { public: YoloLayerPlugin(int classCount, int netWidth, int netHeight, int maxOut, const std::vector& vYoloKernel); @@ -108,7 +109,7 @@ namespace nvinfer1 void** mAnchor; }; - class YoloPluginCreator : public IPluginCreator + class API YoloPluginCreator : public IPluginCreator { public: YoloPluginCreator();