From 90a4b2be0ea3be40580fb0349dda7499c9473490 Mon Sep 17 00:00:00 2001 From: Matthew Hill Date: Mon, 17 Oct 2016 16:08:23 -0400 Subject: [PATCH] Added windows DLL export to C lib --- src/bindings/c/CMakeLists.txt | 2 +- src/bindings/c/alpr_c.cpp | 20 ++++++++++---------- src/bindings/c/alpr_c.h | 8 +++++++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/bindings/c/CMakeLists.txt b/src/bindings/c/CMakeLists.txt index 25d08e2..2f7e528 100644 --- a/src/bindings/c/CMakeLists.txt +++ b/src/bindings/c/CMakeLists.txt @@ -12,7 +12,7 @@ set(alprc_source add_library(openalprc SHARED ${alprc_source}) -set_target_properties(openalprc PROPERTIES SOVERSION ${OPENALPR_MAJOR_VERSION}) +#set_target_properties(openalprc PROPERTIES SOVERSION ${OPENALPR_MAJOR_VERSION}) TARGET_LINK_LIBRARIES(openalprc openalpr) diff --git a/src/bindings/c/alpr_c.cpp b/src/bindings/c/alpr_c.cpp index 3ef6192..4536a6a 100644 --- a/src/bindings/c/alpr_c.cpp +++ b/src/bindings/c/alpr_c.cpp @@ -22,7 +22,7 @@ #include #include -OPENALPR* openalpr_init(const char* country, const char* configFile, const char* runtimeDir) +OPENALPRC_DLL_EXPORT OPENALPR* openalpr_init(const char* country, const char* configFile, const char* runtimeDir) { alpr::Alpr* alpr_inst = new alpr::Alpr(country, configFile, runtimeDir); @@ -30,35 +30,35 @@ OPENALPR* openalpr_init(const char* country, const char* configFile, const char* } // Set the country used for plate recognition -void openalpr_set_country(OPENALPR* instance, const char* country) +OPENALPRC_DLL_EXPORT void openalpr_set_country(OPENALPR* instance, const char* country) { ((alpr::Alpr*) instance)->setCountry(country); } // Update the prewarp setting without reloading the library -void openalpr_set_prewarp(OPENALPR* instance, const char* prewarp_config) +OPENALPRC_DLL_EXPORT void openalpr_set_prewarp(OPENALPR* instance, const char* prewarp_config) { ((alpr::Alpr*) instance)->setPrewarp(prewarp_config); } // Update the detection mask without reloading the library -void openalpr_set_mask(OPENALPR* instance, unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight) +OPENALPRC_DLL_EXPORT void openalpr_set_mask(OPENALPR* instance, unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight) { ((alpr::Alpr*) instance)->setMask(pixelData, bytesPerPixel, imgWidth, imgHeight); } // Enable/disable region detection. Pass a 0 or 1 -void openalpr_set_detect_region(OPENALPR* instance, int detectRegion) +OPENALPRC_DLL_EXPORT void openalpr_set_detect_region(OPENALPR* instance, int detectRegion) { ((alpr::Alpr*) instance)->setDetectRegion(detectRegion); } -void openalpr_set_topn(OPENALPR* instance, int topN) +OPENALPRC_DLL_EXPORT void openalpr_set_topn(OPENALPR* instance, int topN) { ((alpr::Alpr*) instance)->setTopN(topN); } -void openalpr_set_default_region(OPENALPR* instance, const char* region) +OPENALPRC_DLL_EXPORT void openalpr_set_default_region(OPENALPR* instance, const char* region) { ((alpr::Alpr*) instance)->setDefaultRegion(region); } @@ -67,7 +67,7 @@ void openalpr_set_default_region(OPENALPR* instance, const char* region) // Recognizes the provided image and responds with JSON. // Caller must call free() on the returned object -char* openalpr_recognize_rawimage(OPENALPR* instance, unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, AlprCRegionOfInterest roi) +OPENALPRC_DLL_EXPORT char* openalpr_recognize_rawimage(OPENALPR* instance, unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, AlprCRegionOfInterest roi) { std::vector rois; alpr::AlprRegionOfInterest cpproi(roi.x, roi.y, roi.width, roi.height); @@ -82,7 +82,7 @@ char* openalpr_recognize_rawimage(OPENALPR* instance, unsigned char* pixelData, } -char* openalpr_recognize_encodedimage(OPENALPR* instance, unsigned char* bytes, long long length, AlprCRegionOfInterest roi) +OPENALPRC_DLL_EXPORT char* openalpr_recognize_encodedimage(OPENALPR* instance, unsigned char* bytes, long long length, AlprCRegionOfInterest roi) { std::vector rois; alpr::AlprRegionOfInterest cpproi(roi.x, roi.y, roi.width, roi.height); @@ -99,7 +99,7 @@ char* openalpr_recognize_encodedimage(OPENALPR* instance, unsigned char* bytes, return result_obj; } -void openalpr_cleanup(OPENALPR* instance) +OPENALPRC_DLL_EXPORT void openalpr_cleanup(OPENALPR* instance) { delete ((alpr::Alpr*) instance); } \ No newline at end of file diff --git a/src/bindings/c/alpr_c.h b/src/bindings/c/alpr_c.h index a357488..0219732 100644 --- a/src/bindings/c/alpr_c.h +++ b/src/bindings/c/alpr_c.h @@ -22,7 +22,13 @@ #define ALPR_C_H #ifdef __cplusplus -extern "C" { +extern "C" { +#endif + +#ifdef WIN32 + #define OPENALPRC_DLL_EXPORT __declspec( dllexport ) +#else + #define OPENALPRC_DLL_EXPORT #endif typedef void OPENALPR;