mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
LIBSO=1 compile darknet.so library on Linux
This commit is contained in:
26
Makefile
26
Makefile
@ -3,12 +3,14 @@ CUDNN=0
|
|||||||
OPENCV=0
|
OPENCV=0
|
||||||
DEBUG=0
|
DEBUG=0
|
||||||
OPENMP=0
|
OPENMP=0
|
||||||
|
LIBSO=0
|
||||||
|
|
||||||
ARCH= -gencode arch=compute_20,code=[sm_20,sm_21] \
|
ARCH= -gencode arch=compute_20,code=[sm_20,sm_21] \
|
||||||
-gencode arch=compute_30,code=sm_30 \
|
-gencode arch=compute_30,code=sm_30 \
|
||||||
-gencode arch=compute_35,code=sm_35 \
|
-gencode arch=compute_35,code=sm_35 \
|
||||||
-gencode arch=compute_50,code=[sm_50,compute_50] \
|
-gencode arch=compute_50,code=[sm_50,compute_50] \
|
||||||
-gencode arch=compute_52,code=[sm_52,compute_52]
|
-gencode arch=compute_52,code=[sm_52,compute_52] \
|
||||||
|
-gencode arch=compute_61,code=[sm_61,compute_61]
|
||||||
|
|
||||||
# This is what I use, uncomment if you know your arch and want to specify
|
# This is what I use, uncomment if you know your arch and want to specify
|
||||||
# ARCH= -gencode arch=compute_52,code=compute_52
|
# ARCH= -gencode arch=compute_52,code=compute_52
|
||||||
@ -17,12 +19,18 @@ VPATH=./src/
|
|||||||
EXEC=darknet
|
EXEC=darknet
|
||||||
OBJDIR=./obj/
|
OBJDIR=./obj/
|
||||||
|
|
||||||
|
ifeq ($(LIBSO), 1)
|
||||||
|
LIBNAMESO=darknet.so
|
||||||
|
APPNAMESO=uselib
|
||||||
|
endif
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
|
CPP=g++
|
||||||
NVCC=nvcc
|
NVCC=nvcc
|
||||||
OPTS=-Ofast
|
OPTS=-Ofast
|
||||||
LDFLAGS= -lm -pthread
|
LDFLAGS= -lm -pthread
|
||||||
COMMON=
|
COMMON=
|
||||||
CFLAGS=-Wall -Wfatal-errors
|
CFLAGS=-Wall -Wfatal-errors
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
OPTS=-O0 -g
|
OPTS=-O0 -g
|
||||||
@ -63,7 +71,17 @@ endif
|
|||||||
OBJS = $(addprefix $(OBJDIR), $(OBJ))
|
OBJS = $(addprefix $(OBJDIR), $(OBJ))
|
||||||
DEPS = $(wildcard src/*.h) Makefile
|
DEPS = $(wildcard src/*.h) Makefile
|
||||||
|
|
||||||
all: obj backup results $(EXEC)
|
all: obj backup results $(EXEC) $(LIBNAMESO) $(APPNAMESO)
|
||||||
|
|
||||||
|
ifeq ($(LIBSO), 1)
|
||||||
|
CFLAGS+= -fPIC
|
||||||
|
|
||||||
|
$(LIBNAMESO): $(OBJS)
|
||||||
|
$(CPP) -shared -std=c++11 -fvisibility=hidden -DYOLODLL_EXPORTS $(COMMON) $(CFLAGS) $^ -o $@ src/yolo_v2_class.cpp $(LDFLAGS)
|
||||||
|
|
||||||
|
$(APPNAMESO): $(OBJS)
|
||||||
|
$(CPP) -std=c++11 $(COMMON) $(CFLAGS) -o $@ src/yolo_console_dll.cpp $(LDFLAGS) -L ./ -l:$(LIBNAMESO)
|
||||||
|
endif
|
||||||
|
|
||||||
$(EXEC): $(OBJS)
|
$(EXEC): $(OBJS)
|
||||||
$(CC) $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS)
|
$(CC) $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS)
|
||||||
@ -84,5 +102,5 @@ results:
|
|||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OBJS) $(EXEC)
|
rm -rf $(OBJS) $(EXEC) $(LIBNAMESO) $(APPNAMESO)
|
||||||
|
|
||||||
|
@ -11,9 +11,17 @@
|
|||||||
#endif // OPENCV
|
#endif // OPENCV
|
||||||
|
|
||||||
#ifdef YOLODLL_EXPORTS
|
#ifdef YOLODLL_EXPORTS
|
||||||
|
#if defined(_MSC_VER)
|
||||||
#define YOLODLL_API __declspec(dllexport)
|
#define YOLODLL_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
|
#define YOLODLL_API __attribute__((visibility("default")))
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#if defined(_MSC_VER)
|
||||||
#define YOLODLL_API __declspec(dllimport)
|
#define YOLODLL_API __declspec(dllimport)
|
||||||
|
#else
|
||||||
|
#define YOLODLL_API
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct bbox_t {
|
struct bbox_t {
|
||||||
|
Reference in New Issue
Block a user