Skip to content

Compile sub static lib error win + clang + msys2 #187

@Khalyutin

Description

@Khalyutin

Use CDS as static lib in other.dll win + clang + msys2 (not MINGW)
other.dll it is load failt without define CDS_EXPORT_API __declspec(dllexport)

CDS_OS_TYPE calculated as "CDS_OS_WIN64" and NOT # define CDS_EXPORT_API __declspec(dllexport)
cmake code:

    set(LIBCDS_CXX_STANDARD ${CMAKE_CXX_STANDARD}) # c++20
    add_definitions( -DCDS_BUILD_STATIC_LIB)
    add_subdirectory(extern/libcds)
    set(cds "cds-s")
    if(CMAKE_BUILD_TYPE STREQUAL "Debug")
        set(cds "${cds}_d")
    endif()
    set(LIB_cds_ID "${cds}")

or

    add_definitions(-DCDS_BUILD_STATIC_LIB) # nead global to include .h   
    set(LIB_cds_ID "my-cds-static")
    file(GLOB cds_src extern/libcds/src/*.cpp)  
    add_library                 (${LIB_cds_ID} STATIC ${cds_src})        

workaround in code\extern\libcds\cds\compiler\gcc\compiler_macro.h:

-- #if CDS_OS_TYPE == CDS_OS_MINGW
++ #if CDS_OS_TYPE == CDS_OS_MINGW || CDS_OS_TYPE == CDS_OS_WIN64 || CDS_OS_TYPE == CDS_OS_WIN32
#   ifdef CDS_BUILD_LIB
#       define CDS_EXPORT_API          __declspec(dllexport)
#   elif !defined(CDS_BUILD_STATIC_LIB)
#       define CDS_EXPORT_API          __declspec(dllimport)
#   endif
#else
#   ifndef __declspec
#       define __declspec(_x)
#   endif
#endif

create PR?
code\extern\libcds\cds\compiler\gcc\compiler_macro.h

-- #if CDS_OS_TYPE == CDS_OS_MINGW
++ #if CDS_OS_TYPE == CDS_OS_MINGW || CDS_OS_TYPE == CDS_OS_WIN64 || CDS_OS_TYPE == CDS_OS_WIN32

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions