Skip to content

Commit 55ad625

Browse files
authored
Fix compilation problems on Windows (wang-xinyu#644)
1 parent abcc753 commit 55ad625

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

yolov5/API.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifdef API_EXPORTS
2+
#if defined(_MSC_VER)
3+
#define API __declspec(dllexport)
4+
#else
5+
#define API __attribute__((visibility("default")))
6+
#endif
7+
#else
8+
9+
#if defined(_MSC_VER)
10+
#define API __declspec(dllimport)
11+
#else
12+
#define API
13+
#endif
14+
#endif

yolov5/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ cmake_minimum_required(VERSION 2.6)
33
project(yolov5)
44

55
add_definitions(-std=c++11)
6-
6+
add_definitions(-DAPI_EXPORTS)
77
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
88
set(CMAKE_CXX_STANDARD 11)
99
set(CMAKE_BUILD_TYPE Debug)
1010

1111
find_package(CUDA REQUIRED)
1212

13+
if(WIN32)
14+
enable_language(CUDA)
15+
endif(WIN32)
16+
1317
include_directories(${PROJECT_SOURCE_DIR}/include)
1418
# include and link dirs of cuda and tensorrt, you need adapt them if yours are different
1519
# cuda
@@ -33,5 +37,7 @@ target_link_libraries(yolov5 cudart)
3337
target_link_libraries(yolov5 myplugins)
3438
target_link_libraries(yolov5 ${OpenCV_LIBS})
3539

40+
if(UNIX)
3641
add_definitions(-O2 -pthread)
42+
endif(UNIX)
3743

yolov5/yololayer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef _YOLO_LAYER_H
22
#define _YOLO_LAYER_H
33

4+
#include "API.h"
45
#include <vector>
56
#include <string>
67
#include "NvInfer.h"
@@ -40,7 +41,7 @@ namespace Yolo
4041

4142
namespace nvinfer1
4243
{
43-
class YoloLayerPlugin : public IPluginV2IOExt
44+
class API YoloLayerPlugin : public IPluginV2IOExt
4445
{
4546
public:
4647
YoloLayerPlugin(int classCount, int netWidth, int netHeight, int maxOut, const std::vector<Yolo::YoloKernel>& vYoloKernel);
@@ -108,7 +109,7 @@ namespace nvinfer1
108109
void** mAnchor;
109110
};
110111

111-
class YoloPluginCreator : public IPluginCreator
112+
class API YoloPluginCreator : public IPluginCreator
112113
{
113114
public:
114115
YoloPluginCreator();

0 commit comments

Comments
 (0)