From 4a8fd71a2eb5e057766ec7408e2da9d65662bf6e Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 3 Jun 2019 20:14:52 +0000 Subject: [PATCH 1/2] core: fix visibility handling --- modules/core/include/opencv2/core/cvdef.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 9805d96100..c42517f545 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -371,10 +371,10 @@ Cv64suf; # define OPENCV_DISABLE_DEPRECATED_COMPATIBILITY #endif -#ifdef CVAPI_EXPORTS -# if (defined _WIN32 || defined WINCE || defined __CYGWIN__) +#ifndef CV_EXPORTS +# if (defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined(CVAPI_EXPORTS) # define CV_EXPORTS __declspec(dllexport) -# elif defined __GNUC__ && __GNUC__ >= 4 +# elif defined __GNUC__ && __GNUC__ >= 4 && (defined(CVAPI_EXPORTS) || defined(__APPLE__)) # define CV_EXPORTS __attribute__ ((visibility ("default"))) # endif #endif From f5ca9d3fe17caffe7324a965b4aeea7f9d940ec2 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 4 Jun 2019 17:40:24 +0300 Subject: [PATCH 2/2] python: visibility --- modules/python/common.cmake | 1 - modules/python/src2/cv2.cpp | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/python/common.cmake b/modules/python/common.cmake index 830e4cbc45..17503c03f9 100644 --- a/modules/python/common.cmake +++ b/modules/python/common.cmake @@ -61,7 +61,6 @@ ocv_update(OPENCV_PYTHON_EXTENSION_BUILD_PATH "${LIBRARY_OUTPUT_PATH}/${MODULE_I set_target_properties(${the_module} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${OPENCV_PYTHON_EXTENSION_BUILD_PATH}" ARCHIVE_OUTPUT_NAME ${the_module} # prevent name conflict for python2/3 outputs - DEFINE_SYMBOL CVAPI_EXPORTS PREFIX "" OUTPUT_NAME cv2 SUFFIX ${CVPY_SUFFIX}) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index fbe2bbca51..4b2801fca9 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -1769,8 +1769,12 @@ static int to_ok(PyTypeObject *to) } +#if defined(__GNUC__) +#pragma GCC visibility push(default) +#endif + #if PY_MAJOR_VERSION >= 3 -extern "C" CV_EXPORTS PyObject* PyInit_cv2(); +PyMODINIT_FUNC PyInit_cv2(); static struct PyModuleDef cv2_moduledef = { PyModuleDef_HEAD_INIT, @@ -1783,7 +1787,7 @@ static struct PyModuleDef cv2_moduledef = PyObject* PyInit_cv2() #else -extern "C" CV_EXPORTS void initcv2(); +PyMODINIT_FUNC initcv2(); void initcv2() #endif