Skip to content

Add project support Bazel build system. #1167

@MiyamuraMiyako

Description

@MiyamuraMiyako

Is your feature request related to a problem?

I try build static library directly, but lib files can't use in my bazel project.
log cpr.lib(threadpool.obj) : error LNK2019: �޷��������ⲿ���� _Cnd_timedwait_for������ "public: __cdecl <lambda_eba37c162f1e7731b0928a0b0fca0ed0>::operator()(void)const " (??R<lambda_eba37c162f1e7731b0928a0b0fca0ed0>@@QEBA@XZ) �������˸÷��� cpr.lib(async.obj) : error LNK2019: �޷��������ⲿ���� __std_init_once_link_alternate_names_and_abort������ "public: __cdecl std::_Init_once_completer::~_Init_once_completer(void)" (??1_Init_once_completer@std@@QEAA@XZ) �������˸÷���
I can't find the reason yet.
this is my BUILD.bazel file's some content:

cc_import(
    name = "zlibstatic",
    hdrs = [],
    static_library = "libs/win-x64/zlibstatic.lib",
    visibility = ["//visibility:public"],
)

cc_import(
    name = "curl",
    hdrs = [],
    deps=[":zlibstatic"],
    static_library = "libs/win-x64/libcurl.lib",
    visibility = ["//visibility:public"],
)

cc_import(
    name = "cpr",
    hdrs = glob([
        "src/cpr/*.h",
    ]),
    static_library = "libs/win-x64/cpr.lib",
    deps=[":zlibstatic",":curl"],
    visibility = ["//visibility:public"],
)

cc_binary(
    name = "..........",
    srcs = glob([
        "**/*.cpp",
        "**/*.hpp",
        "**/*.h",
    ]),
    copts = [
        "/utf-8",
        "-std:c++17",
        "-Bv",
        "-W3",
        "-MT",
        "-D_UNICODE",
        "-DUNICODE",
    ],
    includes = ["src"],
    linkopts = [
        "-ENTRY:wWinMainCRTStartup",
        "-SUBSYSTEM:WINDOWS",
        "-NODEFAULTLIB:libcmt.lib",
    ],
    linkstatic = 1,
    deps = [
        ..........
        ":zlibstatic",
        ":curl",
        ":cpr",
        .........
    ],
)

Possible Solution

If cpr support bazel directly, maybe it will be easier to use. But I can't successfully convert the cmake project to a bazel project yet.

Alternatives

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions