Fix compilation problems on Windows (#644)

This commit is contained in:
BaofengZan 2021-07-30 10:57:29 +08:00 committed by GitHub
parent abcc753b19
commit 55ad6259ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 3 deletions

14
yolov5/API.h Normal file
View File

@ -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

View File

@ -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)

View File

@ -1,6 +1,7 @@
#ifndef _YOLO_LAYER_H
#define _YOLO_LAYER_H
#include "API.h"
#include <vector>
#include <string>
#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<Yolo::YoloKernel>& vYoloKernel);
@ -108,7 +109,7 @@ namespace nvinfer1
void** mAnchor;
};
class YoloPluginCreator : public IPluginCreator
class API YoloPluginCreator : public IPluginCreator
{
public:
YoloPluginCreator();