Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not build in MSVC #35

Closed
hh9527 opened this issue Jan 17, 2017 · 8 comments
Closed

Can not build in MSVC #35

hh9527 opened this issue Jan 17, 2017 · 8 comments

Comments

@hh9527
Copy link

hh9527 commented Jan 17, 2017

It seemed CMake is not working in oniguruma with MSVC, but use make_win64.bat works.

@iwillspeak
Copy link
Collaborator

iwillspeak commented Jan 17, 2017

\o/ welcome to rust onig!

I haven't been able to get onig building with the MSVC toolchain on Windows. It does build successfully with the GNU toolchain, which is what the AppVeyor build tests.

It's interesting that you've had some success with that batch file though. Maybe we could try and detect that we're building using the MSVC toolchain and use that file rather than CMake in the onig_sys build.rs. What're your thoughts?

@hh9527
Copy link
Author

hh9527 commented Jan 18, 2017

@iwillspeak I think it better to make upstream oniguruma CMake works in MSVC, or we will have to detect toolchain and use make_win64/32.bat.

@evandrocoan
Copy link

On the stack overflow question:

  1. error: failed to run custom build command for onig_sys v61.1.0

Was found by Matthieu M.:

Might be a different set of flags. Tracking down the line of the error I get github.com/kkos/oniguruma/blob/master/src/regenc.c#L32, where ONIG_ENCODING_DEFAULT aliases ONIG_ENCODING_ASCII which is defined as the address of a global. It's indeed not a constant in C (see stackoverflow.com/questions/3025050), so maybe you compiled in C++ mode?

@iwillspeak
Copy link
Collaborator

That's interesting. I've got access to a Windows machine now. With any luck I'll have a go at fixing this over the weekend.

@iwillspeak iwillspeak self-assigned this Mar 17, 2017
iwillspeak pushed a commit that referenced this issue Mar 17, 2017
If we are building with the MSVC toolchain then use the existing NMAKE files instead of Cmake.

This is initial work on #35
iwillspeak added a commit that referenced this issue Mar 18, 2017
If we are building with the MSVC toolchain then use the existing NMAKE files instead of Cmake.

This is initial work on #35
@evandrocoan
Copy link

evandrocoan commented Mar 18, 2017

I tested the last updates on the windows branch. I am using Visual Studio 2015, I got this error:

D:\User\Downloads\rust-onig>cargo build
   Compiling onig_sys v61.1.0 (file:///D:/User/Downloads/rust-onig/onig_sys)
error: failed to run custom build command for `onig_sys v61.1.0 (file:///D:/User/Downloads/rust-onig/onig_sys)`
process didn't exit successfully: `D:\User\Downloads\rust-onig\target\debug\build\onig_sys-6d16105efd8e8e03\build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'Build error:
STDERR:
Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
Copyright (C) Microsoft Corporation.  All rights reserved.

NMAKE : fatal error U1077: 'F:\VisualStudio2015\VC\bin\cl.EXE' : return code '0x2'
Stop.

STDOUT:
D:\User\Downloads\rust-onig\onig_sys\oniguruma>cd src

D:\User\Downloads\rust-onig\onig_sys\oniguruma\src>copy config.h.win64 config.h
        1 file(s) copied.

D:\User\Downloads\rust-onig\onig_sys\oniguruma\src>nmake -f Makefile.windows
        cl -O2 -nologo /W3  -DHAVE_CONFIG_H -DNOT_RUBY -DEXPORT /I. /I.. /Foreggnu.obj /c reggnu.c
reggnu.c
d:\user\downloads\rust-onig\onig_sys\oniguruma\src\regint.h(143): fatal error C1083: Cannot open include file: 'stdlib.h': No such file or directory
', onig_sys\build.rs:57
note: Run with `RUST_BACKTRACE=1` for a backtrace.


D:\User\Downloads\rust-onig>

Update:

I run these commands, then it built successfully:

D:\User\Downloads\rust-onig>set VISUAL_STUDIO_FOLDER=F:\VisualStudio2015

D:\User\Downloads\rust-onig>call "%VISUAL_STUDIO_FOLDER%\VC\vcvarsall.bat"

D:\User\Downloads\rust-onig>call "%VISUAL_STUDIO_FOLDER%\VC\vcvarsall.bat"

D:\User\Downloads\rust-onig>cargo build
   Compiling onig_sys v61.1.0 (file:///D:/User/Downloads/rust-onig/onig_sys)
   Compiling onig v1.2.0 (file:///D:/User/Downloads/rust-onig)
    Finished dev [unoptimized + debuginfo] target(s) in 72.93 secs

D:\User\Downloads\rust-onig>

@iwillspeak
Copy link
Collaborator

Thanks for giving it a test. The MSVC build is intended to be run from the Developer Command Prompt. If you want to run it from another place you'll have to add vcvars to your path.

Hopefully I'll be able to get it building on CI soon and push an update to Crates.io.

@iwillspeak
Copy link
Collaborator

The onig_sys crate should now build with the MSVC toolchain. It has been tested with Visual Studio 2015 on AppVeyor and with the 2017 C++ Tools only install. To make sure all of the toolchain is in scope either run the build from the Developer Command Prompt or call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat".

Let me know if you encounter any problems.

@rofrol
Copy link

rofrol commented Aug 20, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants