Error: LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library

I am trying to depend on libsodium: https://download.libsodium.org/libsodium/releases/libsodium-1.0.17-stable-msvc.zip

Using the following Bazel configuration:

# WORKSPACE
new_local_repository(
    name = "org_libsodium_sodium",
    build_file = "third_party/sodium.BUILD",
    path = "third_party/sodium",
)
# sodium.BUILD
config_setting(
    name = "windows_dbg_build",
    constraint_values = ["@bazel_tools//platforms:windows"],
    values = {"compilation_mode": "dbg"},
)

config_setting(
    name = "windows_fastbuild_build",
    constraint_values = ["@bazel_tools//platforms:windows"],
    values = {"compilation_mode": "fastbuild"},
)

config_setting(
    name = "windows_opt_build",
    constraint_values = ["@bazel_tools//platforms:windows"],
    values = {"compilation_mode": "opt"},
)

cc_library(
    name = "sodium",
    srcs = select({
        ":windows_dbg_build": ["lib/dbg/libsodium.lib"],
        ":windows_fastbuild_build": ["lib/dbg/libsodium.lib"],
        ":windows_opt_build": ["lib/opt/libsodium.lib"],
        "//conditions:default": ["lib/opt/libsodium.a"],
    }),
    hdrs = glob(["sodium/**/*.h"]),
    defines = ["SODIUM_STATIC"],
    visibility = ["//visibility:public"],
)

Is it correct to use the /MT and /MTd Runtime Library for Windows precompiled static libraries?

Any idea what I am doing wrong?

Kind regards, Ryan

0 Answers