From d9affaed0a8b2802dd9d995fa111c84f8e34c9e1 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Wed, 3 Feb 2021 17:49:13 +0000 Subject: [PATCH] Add symbol visibility information to all the functions that are exported --- CMakeLists.txt | 3 ++ include/qdldl.h | 88 +++++++++++++++++++++++++++++-------------------- 2 files changed, 55 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be5bc76..55f25c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,6 +105,7 @@ set( # ---------------------------------------------- add_library (qdldlobject OBJECT ${qdldl_src} ${qdldl_headers}) target_include_directories(qdldlobject PRIVATE ${PROJECT_SOURCE_DIR}/include) +target_compile_definitions(qdldlobject PUBLIC BUILDING_QDLDL) # Create Static Library @@ -116,6 +117,7 @@ include(GNUInstallDirs) add_library (qdldlstatic STATIC ${qdldl_src} ${qdldl_headers}) # Give same name to static library output set_target_properties(qdldlstatic PROPERTIES OUTPUT_NAME qdldl) +target_compile_definitions(qdldlstatic PUBLIC BUILDING_QDLDL) # Declare include directories for the cmake exported target target_include_directories(qdldlstatic @@ -141,6 +143,7 @@ install(FILES ${qdldl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qdldl") # ---------------------------------------------- # Create qdldl shared library add_library (qdldl SHARED ${qdldl_src} ${qdldl_headers}) +target_compile_definitions(qdldl PUBLIC BUILDING_QDLDL) # Declare include directories for the cmake exported target target_include_directories(qdldl diff --git a/include/qdldl.h b/include/qdldl.h index c823ff5..b133d9a 100644 --- a/include/qdldl.h +++ b/include/qdldl.h @@ -5,6 +5,22 @@ #include "qdldl_types.h" #include "qdldl_version.h" +// Define the function attributes that are needed to mark functions as being +// visible for linking in the shared library version of QDLDL +#if defined(_WIN32) +# if defined(BUILDING_QDLDL) +# define QDLDL_API_EXPORT __declspec(dllexport) +# else +# define QDLDL_API_EXPORT __declspec(dllimport) +# endif +#else +# if defined(BUILDING_QDLDL) +# define QDLDL_API_EXPORT __attribute__((visibility("default"))) +# else +# define QDLDL_API_EXPORT +# endif +#endif + # ifdef __cplusplus extern "C" { # endif // ifdef __cplusplus @@ -44,12 +60,12 @@ extern "C" { * Returns -2 if the return value overflows QDLDL_int. * */ - QDLDL_int QDLDL_etree(const QDLDL_int n, - const QDLDL_int* Ap, - const QDLDL_int* Ai, - QDLDL_int* work, - QDLDL_int* Lnz, - QDLDL_int* etree); +QDLDL_API_EXPORT QDLDL_int QDLDL_etree(const QDLDL_int n, + const QDLDL_int* Ap, + const QDLDL_int* Ai, + QDLDL_int* work, + QDLDL_int* Lnz, + QDLDL_int* etree); /** @@ -86,20 +102,20 @@ extern "C" { * or otherwise LDL factorisable) * */ -QDLDL_int QDLDL_factor(const QDLDL_int n, - const QDLDL_int* Ap, - const QDLDL_int* Ai, - const QDLDL_float* Ax, - QDLDL_int* Lp, - QDLDL_int* Li, - QDLDL_float* Lx, - QDLDL_float* D, - QDLDL_float* Dinv, - const QDLDL_int* Lnz, - const QDLDL_int* etree, - QDLDL_bool* bwork, - QDLDL_int* iwork, - QDLDL_float* fwork); +QDLDL_API_EXPORT QDLDL_int QDLDL_factor(const QDLDL_int n, + const QDLDL_int* Ap, + const QDLDL_int* Ai, + const QDLDL_float* Ax, + QDLDL_int* Lp, + QDLDL_int* Li, + QDLDL_float* Lx, + QDLDL_float* D, + QDLDL_float* Dinv, + const QDLDL_int* Lnz, + const QDLDL_int* etree, + QDLDL_bool* bwork, + QDLDL_int* iwork, + QDLDL_float* fwork); /** @@ -116,12 +132,12 @@ QDLDL_int QDLDL_factor(const QDLDL_int n, * @param x initialized to b. Equal to x on return * */ -void QDLDL_solve(const QDLDL_int n, - const QDLDL_int* Lp, - const QDLDL_int* Li, - const QDLDL_float* Lx, - const QDLDL_float* Dinv, - QDLDL_float* x); +QDLDL_API_EXPORT void QDLDL_solve(const QDLDL_int n, + const QDLDL_int* Lp, + const QDLDL_int* Li, + const QDLDL_float* Lx, + const QDLDL_float* Dinv, + QDLDL_float* x); /** @@ -137,11 +153,11 @@ void QDLDL_solve(const QDLDL_int n, * @param x initialized to b. Equal to x on return * */ -void QDLDL_Lsolve(const QDLDL_int n, - const QDLDL_int* Lp, - const QDLDL_int* Li, - const QDLDL_float* Lx, - QDLDL_float* x); +QDLDL_API_EXPORT void QDLDL_Lsolve(const QDLDL_int n, + const QDLDL_int* Lp, + const QDLDL_int* Li, + const QDLDL_float* Lx, + QDLDL_float* x); /** @@ -157,11 +173,11 @@ void QDLDL_Lsolve(const QDLDL_int n, * @param x initialized to b. Equal to x on return * */ -void QDLDL_Ltsolve(const QDLDL_int n, - const QDLDL_int* Lp, - const QDLDL_int* Li, - const QDLDL_float* Lx, - QDLDL_float* x); +QDLDL_API_EXPORT void QDLDL_Ltsolve(const QDLDL_int n, + const QDLDL_int* Lp, + const QDLDL_int* Li, + const QDLDL_float* Lx, + QDLDL_float* x); # ifdef __cplusplus }