diff --git a/LAGraph/config/LAGraph.h.in b/LAGraph/config/LAGraph.h.in index 104f26ed8..87d5965da 100644 --- a/LAGraph/config/LAGraph.h.in +++ b/LAGraph/config/LAGraph.h.in @@ -66,7 +66,7 @@ #error "The GraphBLAS library must support the v2.0 C API Specification" #endif -#if ( _MSC_VER && !__INTEL_COMPILER ) +#if ( _MSC_VER && !__INTEL_COMPILER && LG_DLL ) #ifdef LG_LIBRARY // compiling LAGraph itself, exporting symbols to user apps #define LAGRAPH_PUBLIC __declspec ( dllexport ) diff --git a/LAGraph/experimental/CMakeLists.txt b/LAGraph/experimental/CMakeLists.txt index b1f181360..292e5cafa 100644 --- a/LAGraph/experimental/CMakeLists.txt +++ b/LAGraph/experimental/CMakeLists.txt @@ -33,6 +33,8 @@ SET_TARGET_PROPERTIES ( lagraphx PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/dlls ) target_link_libraries ( lagraphx PRIVATE lagraph ${GRAPHBLAS_LIBRARIES} ) target_link_directories ( lagraphx BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/build ) +target_compile_definitions ( lagraphx PRIVATE LGX_LIBRARY ) +target_compile_definitions ( lagraphx PUBLIC LGX_DLL ) #------------------------------------------------------------------------------- # static lagraphx library properties diff --git a/LAGraph/experimental/test/CMakeLists.txt b/LAGraph/experimental/test/CMakeLists.txt index 5bd25d339..0f5a62cab 100644 --- a/LAGraph/experimental/test/CMakeLists.txt +++ b/LAGraph/experimental/test/CMakeLists.txt @@ -44,6 +44,8 @@ SET_TARGET_PROPERTIES ( lagraphxtest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/dlls ) target_link_libraries ( lagraphxtest PRIVATE lagraph lagraphtest ${GRAPHBLAS_LIBRARIES} ) target_link_directories ( lagraphxtest BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/build ) +target_compile_definitions ( lagraphxtest PRIVATE LGX_TEST_LIBRARY ) +target_compile_definitions ( lagraphxtest PUBLIC LGX_TEST_DLL ) #------------------------------------------------------------------------------- # static lagraphxtest library properties diff --git a/LAGraph/include/LAGraph.h b/LAGraph/include/LAGraph.h index c4e14d735..e27e67d4a 100644 --- a/LAGraph/include/LAGraph.h +++ b/LAGraph/include/LAGraph.h @@ -66,7 +66,7 @@ #error "The GraphBLAS library must support the v2.0 C API Specification" #endif -#if ( _MSC_VER && !__INTEL_COMPILER ) +#if ( _MSC_VER && !__INTEL_COMPILER && LG_DLL ) #ifdef LG_LIBRARY // compiling LAGraph itself, exporting symbols to user apps #define LAGRAPH_PUBLIC __declspec ( dllexport ) diff --git a/LAGraph/include/LAGraphX.h b/LAGraph/include/LAGraphX.h index 67d65876f..c17b2fbbe 100644 --- a/LAGraph/include/LAGraphX.h +++ b/LAGraph/include/LAGraphX.h @@ -19,6 +19,19 @@ #include #include +#if ( _MSC_VER && !__INTEL_COMPILER && LGX_DLL ) + #ifdef LGX_LIBRARY + // compiling LAGraph itself, exporting symbols to user apps + #define LAGRAPHX_PUBLIC __declspec ( dllexport ) + #else + // compiling the user application, importing symbols from LAGraph + #define LAGRAPHX_PUBLIC __declspec ( dllimport ) + #endif +#else + // for other compilers + #define LAGRAPHX_PUBLIC +#endif + //============================================================================== // Experimental methods: in experimental/algorithm and experimental/utility //============================================================================== @@ -31,12 +44,12 @@ // LAGraph_Random_*: Random number generator //------------------------------------------------------------------------------ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_Random_Init ( char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_Random_Finalize ( char *msg @@ -44,10 +57,10 @@ int LAGraph_Random_Finalize #if defined ( COVERAGE ) // for testing only -LAGRAPH_PUBLIC bool random_hack ; +LAGRAPHX_PUBLIC extern bool random_hack ; #endif -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_Random_Seed // construct a random seed vector ( // input/output @@ -57,7 +70,7 @@ int LAGraph_Random_Seed // construct a random seed vector char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_Random_Next // advance to next random vector ( // input/output @@ -65,7 +78,7 @@ int LAGraph_Random_Next // advance to next random vector char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_Random_Matrix // random matrix of any built-in type ( // output @@ -151,7 +164,7 @@ typedef struct } LAGraph_Contents ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_SWrite_HeaderStart // write the first part of the JSON header ( FILE *f, // file to write to @@ -159,7 +172,7 @@ int LAGraph_SWrite_HeaderStart // write the first part of the JSON header char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_SWrite_HeaderItem // write a single item to the JSON header ( // inputs: @@ -173,7 +186,7 @@ int LAGraph_SWrite_HeaderItem // write a single item to the JSON header char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_SWrite_HeaderItem // write a single item to the JSON header ( // inputs: @@ -188,14 +201,14 @@ int LAGraph_SWrite_HeaderItem // write a single item to the JSON header char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_SWrite_HeaderEnd // write the end of the JSON header ( FILE *f, // file to write to char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_SWrite_Item // write the serialized blob of a matrix/vector/text ( // input: @@ -205,7 +218,7 @@ int LAGraph_SWrite_Item // write the serialized blob of a matrix/vector/text char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_SRead // read a set of matrices from a *.lagraph file ( FILE *f, // file to read from @@ -216,7 +229,7 @@ int LAGraph_SRead // read a set of matrices from a *.lagraph file char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC void LAGraph_SFreeContents // free the Contents returned by LAGraph_SRead ( // input/output @@ -224,7 +237,7 @@ void LAGraph_SFreeContents // free the Contents returned by LAGraph_SRead GrB_Index ncontents ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_SSaveSet // save a set of matrices from a *.lagraph file ( // inputs: @@ -252,7 +265,7 @@ int LAGraph_SLoadSet // load a set of matrices from a *.lagraph file char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC void LAGraph_SFreeSet // free a set of matrices ( // input/output @@ -280,7 +293,7 @@ void LAGraph_SFreeSet // free a set of matrices * @retval GrB_SUCCESS if completed successfully (equal or not) * @retval GrB_NULL_POINTER if kmax, ntris, nedges, nsteps is NULL */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_AllKTruss // compute all k-trusses of a graph ( // outputs @@ -308,7 +321,7 @@ int LAGraph_AllKTruss // compute all k-trusses of a graph * @retval GrB_NULL_POINTER if C or C_type is NULL * @return Any GraphBLAS errors that may have been encountered */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_KTruss // compute the k-truss of a graph ( // outputs: @@ -335,7 +348,7 @@ int LAGraph_KTruss // compute the k-truss of a graph * @retval GrB_SUCCESS if completed successfully * @retval GrB_NULL_POINTER if result is NULL */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_cc_lacc ( GrB_Vector *result, GrB_Matrix A, @@ -360,7 +373,7 @@ int LAGraph_cc_lacc ( * @retval GrB_INVALID_VALUE if A is not square, s is not a valid vertex index * @retval GrB_NO_VALUE if A has a negative weight cycle */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_BF_basic ( GrB_Vector *pd_output, @@ -383,7 +396,7 @@ GrB_Info LAGraph_BF_basic * @retval GrB_NO_VALUE if A has a negative weight cycle * */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_BF_basic_pushpull ( GrB_Vector *pd_output, @@ -406,7 +419,7 @@ GrB_Info LAGraph_BF_basic_pushpull * @retval GrB_NO_VALUE if A has a negative weight cycle * */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_BF_basic_mxv ( GrB_Vector *pd_output, //the pointer to the vector of distance @@ -431,7 +444,7 @@ GrB_Info LAGraph_BF_basic_mxv * @retval GrB_NO_VALUE if A has a negative weight cycle * */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_BF_full ( GrB_Vector *pd_output, @@ -458,7 +471,7 @@ GrB_Info LAGraph_BF_full * @retval GrB_NO_VALUE if A has a negative weight cycle * */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_BF_full1 ( GrB_Vector *pd_output, @@ -485,7 +498,7 @@ GrB_Info LAGraph_BF_full1 * @retval GrB_NO_VALUE if A has a negative weight cycle * */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_BF_full1a ( GrB_Vector *pd_output, @@ -512,7 +525,7 @@ GrB_Info LAGraph_BF_full1a * @retval GrB_NO_VALUE if A has a negative weight cycle * */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_BF_full2 ( GrB_Vector *pd_output, //the pointer to the vector of distance @@ -539,7 +552,7 @@ GrB_Info LAGraph_BF_full2 * @retval GrB_NO_VALUE if A has a negative weight cycle * */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_BF_full_mxv ( GrB_Vector *pd_output, @@ -571,7 +584,7 @@ GrB_Info LAGraph_BF_full_mxv * @retval GrB_NO_VALUE if A has a negative weight cycle * */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_BF_pure_c ( int32_t **pd, @@ -608,7 +621,7 @@ GrB_Info LAGraph_BF_pure_c * @retval GrB_NO_VALUE if A has a negative weight cycle * */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_BF_pure_c_double ( double **pd, @@ -642,7 +655,7 @@ GrB_Info LAGraph_BF_pure_c_double * @retval GrB_OUT_OF_MEMORY if allocation fails. * @retval GrB_NO_VALUE if A has a negative weight cycle */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_cdlp ( GrB_Vector *CDLP_handle, @@ -671,7 +684,7 @@ int LAGraph_cdlp * @retval GrB_DOMAIN_MISMATCH if type of Y0 is not FP32 or FP64, or the types of * W or Bias arent the same as Y0 */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_dnn ( // output @@ -696,7 +709,7 @@ GrB_Info LAGraph_dnn * @retval GrB_NULL_POINTER If D or D_type is NULL * @retval GrB_INVALID_VALUE If G is not square */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC GrB_Info LAGraph_FW ( const GrB_Matrix G, @@ -721,7 +734,7 @@ GrB_Info LAGraph_FW * @retval GrB_NULL_POINTER If LCC_handle or LCC_type is NULL * @retval GrB_INVALID_VALUE If A is not stored in CSR format */ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_lcc // compute lcc for all nodes in A ( GrB_Vector *LCC_handle, // output vector @@ -735,7 +748,7 @@ int LAGraph_lcc // compute lcc for all nodes in A //**************************************************************************** -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_msf ( GrB_Matrix *result, // output: an unsymmetrical matrix, the spanning forest @@ -746,7 +759,7 @@ int LAGraph_msf //**************************************************************************** -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_scc ( GrB_Vector *result, // output: array of component identifiers GrB_Matrix A, // input matrix @@ -754,7 +767,7 @@ int LAGraph_scc ( ) ; //**************************************************************************** -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_VertexCentrality_Triangle // vertex triangle-centrality ( // outputs: @@ -767,7 +780,7 @@ int LAGraph_VertexCentrality_Triangle // vertex triangle-centrality ) ; //**************************************************************************** -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_MaximalIndependentSet // maximal independent set ( // outputs: @@ -782,7 +795,7 @@ int LAGraph_MaximalIndependentSet // maximal independent set char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LG_CC_FastSV5 // SuiteSparse:GraphBLAS method, with GxB extensions ( // output @@ -796,7 +809,7 @@ int LG_CC_FastSV5 // SuiteSparse:GraphBLAS method, with GxB extensions // kcore algorithms //------------------------------------------------------------------------------ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_KCore_All ( // outputs: @@ -807,7 +820,7 @@ int LAGraph_KCore_All char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_KCore ( // outputs: @@ -818,7 +831,7 @@ int LAGraph_KCore char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_KCore_Decompose ( // outputs: @@ -834,7 +847,7 @@ int LAGraph_KCore_Decompose // counting graphlets //------------------------------------------------------------------------------ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_FastGraphletTransform ( // outputs: @@ -845,7 +858,7 @@ int LAGraph_FastGraphletTransform char *msg ) ; -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_SquareClustering ( // outputs: @@ -859,7 +872,7 @@ int LAGraph_SquareClustering // a simple example of an algorithm //------------------------------------------------------------------------------ -LAGRAPH_PUBLIC +LAGRAPHX_PUBLIC int LAGraph_HelloWorld // a simple algorithm, just for illustration ( // output diff --git a/LAGraph/src/CMakeLists.txt b/LAGraph/src/CMakeLists.txt index e96ccc4c2..c7b8b1cfa 100644 --- a/LAGraph/src/CMakeLists.txt +++ b/LAGraph/src/CMakeLists.txt @@ -38,6 +38,8 @@ SET_TARGET_PROPERTIES ( lagraph PROPERTIES target_link_libraries ( lagraph PRIVATE ${GRAPHBLAS_LIBRARIES} ${M_LIB} ) target_link_directories ( lagraph BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/build ) target_include_directories ( lagraph PUBLIC include/ ) +target_compile_definitions ( lagraph PRIVATE LG_LIBRARY ) +target_compile_definitions ( lagraph PUBLIC LG_DLL ) # install ( FILES ${LAGRAPH_INCLUDE} DESTINATION include) #------------------------------------------------------------------------------- diff --git a/LAGraph/src/test/CMakeLists.txt b/LAGraph/src/test/CMakeLists.txt index 2bcf887af..fcc618810 100644 --- a/LAGraph/src/test/CMakeLists.txt +++ b/LAGraph/src/test/CMakeLists.txt @@ -46,6 +46,8 @@ SET_TARGET_PROPERTIES ( lagraphtest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/dlls ) target_link_libraries ( lagraphtest PRIVATE lagraph ${GRAPHBLAS_LIBRARIES} ) target_link_directories ( lagraphtest BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/build ) +target_compile_definitions ( lagraphtest PRIVATE LG_TEST_LIBRARY ) +target_compile_definitions ( lagraphtest PUBLIC LG_TEST_DLL ) #------------------------------------------------------------------------------- # static lagraphtest library properties diff --git a/LAGraph/src/test/LG_brutal_malloc.c b/LAGraph/src/test/LG_brutal_malloc.c index 6db6373ef..1af8e12cf 100644 --- a/LAGraph/src/test/LG_brutal_malloc.c +++ b/LAGraph/src/test/LG_brutal_malloc.c @@ -19,6 +19,7 @@ // LAGr_Init. #include "LG_internal.h" +#include "LG_test.h" //------------------------------------------------------------------------------ // global variables: LG_brutal and LG_nmalloc @@ -38,14 +39,14 @@ // It is decremented by LG_brutal_free. After LAGraph_Finalize is called, // this value should be zero. If nonzero, a memory leak has occured. -int64_t LG_brutal = -1 ; -int64_t LG_nmalloc = 0 ; +LG_TEST_PUBLIC int64_t LG_brutal = -1 ; +LG_TEST_PUBLIC int64_t LG_nmalloc = 0 ; //------------------------------------------------------------------------------ // LG_brutal_malloc //------------------------------------------------------------------------------ -LAGRAPH_PUBLIC +LG_TEST_PUBLIC void *LG_brutal_malloc // return pointer to allocated block of memory ( size_t size // # of bytes to allocate @@ -83,7 +84,7 @@ void *LG_brutal_malloc // return pointer to allocated block of memory // LG_brutal_calloc //------------------------------------------------------------------------------ -LAGRAPH_PUBLIC +LG_TEST_PUBLIC void *LG_brutal_calloc // return pointer to allocated block of memory ( size_t nitems, // # of items to allocate @@ -103,7 +104,7 @@ void *LG_brutal_calloc // return pointer to allocated block of memory // LG_brutal_free //------------------------------------------------------------------------------ -LAGRAPH_PUBLIC +LG_TEST_PUBLIC void LG_brutal_free ( void *p // block to free @@ -125,7 +126,7 @@ void LG_brutal_free // LG_brutal_realloc //------------------------------------------------------------------------------ -LAGRAPH_PUBLIC +LG_TEST_PUBLIC void *LG_brutal_realloc // return pointer to reallocated memory ( void *p, // block to realloc diff --git a/LAGraph/src/test/include/LG_test.h b/LAGraph/src/test/include/LG_test.h index 0808286aa..f7fc10d01 100644 --- a/LAGraph/src/test/include/LG_test.h +++ b/LAGraph/src/test/include/LG_test.h @@ -17,6 +17,19 @@ #include #include +#if ( _MSC_VER && !__INTEL_COMPILER && LG_TEST_DLL ) + #ifdef LG_TEST_LIBRARY + // compiling LAGraph itself, exporting symbols to user apps + #define LG_TEST_PUBLIC __declspec ( dllexport ) + #else + // compiling the user application, importing symbols from LAGraph + #define LG_TEST_PUBLIC __declspec ( dllimport ) + #endif +#else + // for other compilers + #define LG_TEST_PUBLIC +#endif + int LG_check_bfs ( // input @@ -133,32 +146,32 @@ int LG_check_export // all entries cleared, if an out-of-memory failure occurs (GrB_assign // in particular). See src/test/test_vector for an example. -LAGRAPH_PUBLIC int LG_brutal_setup (char *msg) ; -LAGRAPH_PUBLIC int LG_brutal_teardown (char *msg) ; +LG_TEST_PUBLIC int LG_brutal_setup (char *msg) ; +LG_TEST_PUBLIC int LG_brutal_teardown (char *msg) ; -LAGRAPH_PUBLIC extern int64_t LG_brutal ; -LAGRAPH_PUBLIC extern int64_t LG_nmalloc ; +LG_TEST_PUBLIC extern int64_t LG_brutal ; +LG_TEST_PUBLIC extern int64_t LG_nmalloc ; -LAGRAPH_PUBLIC +LG_TEST_PUBLIC void *LG_brutal_malloc // return pointer to allocated block of memory ( size_t size // # of bytes to allocate ) ; -LAGRAPH_PUBLIC +LG_TEST_PUBLIC void *LG_brutal_calloc // return pointer to allocated block of memory ( size_t nitems, // # of items to allocate size_t itemsize // # of bytes per item ) ; -LAGRAPH_PUBLIC +LG_TEST_PUBLIC void LG_brutal_free ( void *p // block to free ) ; -LAGRAPH_PUBLIC +LG_TEST_PUBLIC void *LG_brutal_realloc // return pointer to reallocated memory ( void *p, // block to realloc diff --git a/LAGraph/src/utility/LAGraph_Global.c b/LAGraph/src/utility/LAGraph_Global.c index a74320f2d..c102d297d 100644 --- a/LAGraph/src/utility/LAGraph_Global.c +++ b/LAGraph/src/utility/LAGraph_Global.c @@ -22,10 +22,10 @@ //------------------------------------------------------------------------------ // These are modified by LAGraph_Init and LAGr_Init: -void * (* LAGraph_Malloc_function ) (size_t) = malloc ; -void * (* LAGraph_Calloc_function ) (size_t, size_t) = calloc ; -void * (* LAGraph_Realloc_function ) (void *, size_t) = realloc ; -void (* LAGraph_Free_function ) (void *) = free ; +LAGRAPH_PUBLIC void * (* LAGraph_Malloc_function ) (size_t) = malloc ; +LAGRAPH_PUBLIC void * (* LAGraph_Calloc_function ) (size_t, size_t) = calloc ; +LAGRAPH_PUBLIC void * (* LAGraph_Realloc_function ) (void *, size_t) = realloc ; +LAGRAPH_PUBLIC void (* LAGraph_Free_function ) (void *) = free ; //------------------------------------------------------------------------------ // threading control diff --git a/LAGraph/src/utility/LG_internal.h b/LAGraph/src/utility/LG_internal.h index 10028c327..e1bbfacea 100644 --- a/LAGraph/src/utility/LG_internal.h +++ b/LAGraph/src/utility/LG_internal.h @@ -25,7 +25,6 @@ // include files //------------------------------------------------------------------------------ -#define LG_LIBRARY #include #include "LAGraph.h"