wabt-rs icon indicating copy to clipboard operation
wabt-rs copied to clipboard

Compilation on Windows with msvc

Open dschaadt opened this issue 6 years ago • 5 comments

Hi. I noticed a problem when compiling on windows (10) with stable-x86_64-pc-windows-msvc. Cmake works on wabt, but rustc fails during rustc --crate-name wabt_sys ..... It cannot link to wabt.lib since the file is not in the corresponding folder target\debug\build\wabt-sys-....\out where there is wabtshim.lib. After copying it manually there from target\debug\build\wabt-sys...\out\build\Debug, the compilation works. Looks like a -L is missing or the path is somehow incorrect.

dschaadt avatar Jul 10 '18 17:07 dschaadt

That's interesting, thanks for the report! I checked the build.rs and it looks reasonable.

Unfortunately, I don't have a windows machine and don't have an ability to debug the issue. Could you post the build log (cargo build --verbose) ?

pepyakin avatar Jul 11 '18 11:07 pepyakin

Here's the output: Compiling wabt-sys v0.2.0 Running rustc --crate-name wabt_sys C:\user\.cargo\registry\src\github.com-1ecc6299db9ec823\wabt-sys-0.2.0\src\lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=23e155977e582a23 -C extra-filename=-23e155977e582a23 --out-dir X:\test\target\debug\deps -L dependency=X:\test\target\debug\deps --cap-lints allow -L native=X:\test\target\debug\build\wabt-sys-8e3823d7b8812fb5\out\build -L native=X:\test\target\debug\build\wabt-sys-8e3823d7b8812fb5\out -l static=wabt -l static=wabt_shim error: could not find native static library wabt, perhaps an -L flag is missing?

error: aborting due to previous error

The following warnings were emitted during compilation:

warning: cl : Befehlszeile warning D9002 : Unbekannte Option "-std=c++11" wird ignoriert. warning: cl : Befehlszeile warning D9002 : Unbekannte Option "-std=c++11" wird ignoriert.

error: Could not compile wabt-sys.

Caused by: process didn't exit successfully: rustc --crate-name wabt_sys C:\user\.cargo\registry\src\github.com-1ecc6299db9ec823\wabt-sys-0.2.0\src\lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=23e155977e582a23 -C extra-filename=-23e155977e582a23 --out-dir X:\test\target\debug\deps -L dependency=X:\test\target\debug\deps --cap-lints allow -L native=X:\test\target\debug\build\wabt-sys-8e3823d7b8812fb5\out\build -L native=X:\test\target\debug\build\wabt-sys-8e3823d7b8812fb5\out -l static=wabt -l static=wabt_shim (exit code: 101)

The file wabt is located under X:\test\target\debug\build\wabt-sys-8e3823d7b8812fb5\out\build\Debug, so it cannot find it unless moved manually

dschaadt avatar Jul 11 '18 12:07 dschaadt

The default output location on Windows with MSVC for wabt.lib is %CMAKE_BINARY_DIR%\%CMAKE_BUILD_TYPE%. In a typical debug build of wabt-sys, this will be %OUT_DIR%\build\Debug but depending on optimizations it can be %OUT_DIR%\build\{Release|MinSizeRel|RelWithDebInfo}.

I think part of the inconsistency comes from the fact that, in the Wabt project, wabt.lib is more of an internal build artifact rather than a proper build target. Aa far as I can tell there is currently no way to configure CMake to build wabt.lib and install it to some install prefix along with the header.

The CMAKE_BUILD_TYPE variable is controlled by the cmake::Config::profile() so one option would be to set that explicitly on Windows MSVC builds and then add a rustc-link-search directive so that it knows where to pick up.

nlordell avatar Oct 21 '18 16:10 nlordell

Now that there is windows support and appveyor CI, the readme should have an appveyor badge 💯!

The appveyor build history: https://ci.appveyor.com/project/pepyakin/wabt-rs

xmclark avatar Dec 16 '18 19:12 xmclark

Maybe a few things missing:

  • mingw builds
  • i686 builds
  • badge on readme

xmclark avatar Dec 27 '18 03:12 xmclark