nervosnetwork / sparse-merkle-tree

46 stars 37 forks source link

Can't build with msvc #35

Open code-monad opened 1 year ago

code-monad commented 1 year ago

The SMT-C's build script flags are not compatible in msvc environment hence it used gcc flags

Error Message:

 error occurred: Command "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX64\\x64\\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-static" "-I" "../../src" "-I" ".." "-I" "../deps/ckb-c-stdlib" "-W4" "-O3" "-fvisibility=hidden" "-fdata-sections" "-ffunction-sectio
ns" "-Wall" "-Werror" "-Wno-unused-parameter" "-Wno-nonnull" "-D__SHARED_LIBRARY__" "-DCKB_STDLIB_NO_SYSCALL_IMPL" "-FoF:\\workspace\\cryptape\\sparse-merkle-tree\\c\\rust-tests\\target\\debug\\build\\rust-tests-34b7712421c0be08\\out\\../../src/ckb_smt.o" "-c" "../../src/ckb_smt.c" with args "cl.exe" did not ex
ecute successfully (status code exit code: 2)

How to fix this

Need to add an switch case statement in build.rs to detect target_env = "msvc", and adding something like __declspec(dllexport) to make keep the same symbol visibility in msvc environments