How to Compile Ruby on Windows? - ruby

linking miniruby.exe
win32.obj : error LNK2001: unresolved external symbol __imp____pioinfo
miniruby.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.rel
This is the error in cmd while compiling the package using Development cmd for VS2015.
What is wrong?

I ran into the same error (minus some printed output differences) when trying to compile Ruby 2.5.1 on Windows using Visual Studio 2015 Express. I thought that all I needed to do was to add the bin directory to my PATH. So I did this and then tried building but I failed:
$> cd <path_to_ruby_download>
$> set PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin;%PATH%
$> win32\configure.bat
I was able to get past this problem thanks to some insight from this attempt. The main hint (from jules_a) is:
Looks like cl.exe cannot be found. You should use vcvarsall.bat to
configure your path properly.
I tried searching for this vcvarsall batch file but couldn't find it in my Visual Studio installation directory. However, thanks to this article, I found another way. Turns out that all I needed to do was to build from a developer console.
On my computer, I could start this dev console by going to Start -> All Programs -> Visual Studio 2015 -> Visual Studio Tools -> Developer Command Prompt for VS2015. Alternatively, you can launch VsDevCmd.bat, located in Common7\Tools\ directory of your Visual Studio installation.
And then everything worked! Note that I did not need to bother with RubyInstaller or any of that jazz!

You want to compile it or install it? Because you don't need to compile it if you just want to install it. Check the binaries
http://rubyinstaller.org/

For downloading ruby
I am not sure if you still need the answer, I also see that rubyinstaller does not have new ruby release also. After asking around for a while I found that they are posting new release at github. I downloaded 2.4.1 and it work for me.
https://github.com/oneclick/rubyinstaller2/releases
For compiling ruby
Please read this link so you will have info. they change to use msys2 and mingw now
https://github.com/oneclick/rubyinstaller2/

Related

rust: link.exe not found

I installed the rust compiler and also MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.27) (as an individual component)
This does not seam to be working.
Does rust require anything more which I have not installed? Thank you in advance.
Install the Windows SDK too.
I also didn't want to install all of Visual Studio just to compile rust from the command line.
Based on the info in coder-256's link, I tried running C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat. Then, instead of being unable to find link.exe, I got the error:
note: LINK : fatal error LNK1181: cannot open input file 'advapi32.lib'
Searching Stack for that error led to this answer: Install the Windows SDK
So I installed the Windows 10 SDK, and now (after launching a new cmd window) it works.
Using Win11, here's the specific steps that worked for me (assumes VSCode and Rust are already installed):
Go to the Visual Studio Download site
Download Build Tools for Visual Studio 2019 (version 16.9)
Install
Create a "hello world" Rust project (cargo new hello)
Open project in VSCode
Set path info in launch.json file (located at folder root, may need to create this first)
Type Shift+Ctrl+B to build the Rust project

Unable to compile Rust program: LNK1181: cannot open input file 'C:\\Program.obj'

I am getting the error:
C:\rust\hello_world\src>where link.exe
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\Hostx64\x86\link.exe
C:\rust\hello_world\src>rustc main.rs
error: linking with `link.exe` failed: exit code: 1181
|
= note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX64\\x86\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LARGEADDRESSAWARE" "/SAFESEH" "/LIBPATH:C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "main.main.7rcbfp3g-cgu.0.rcgu.o" "main.main.7rcbfp3g-cgu.1.rcgu.o" "main.main.7rcbfp3g-cgu.2.rcgu.o" "main.main.7rcbfp3g-cgu.3.rcgu.o" "main.main.7rcbfp3g-cgu.4.rcgu.o" "main.main.7rcbfp3g-cgu.5.rcgu.o" "/OUT:main.exe" "main.4s37gsrti678ik8u.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libstd-a2af7cbca70405c4.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libpanic_unwind-8f8ad41ed0b34354.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libhashbrown-3442ca764a847dfc.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-726244614f5a8f3a.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libbacktrace-29b7599014a92286.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_demangle-519f7f7caa7ec7f2.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libunwind-feba7334127a8724.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcfg_if-6d75d87de5ddb74c.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\liblibc-7dc5efd24952e919.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\liballoc-b95120d391119ce4.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_std_workspace_core-0e624f0b43962fb3.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcore-58985b8c03f907a8.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcompiler_builtins-27c1b248396c205c.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib"
= note: LINK : fatal error LNK1181: cannot open input file 'C:\\Program.obj'
I've looked at other posts suggested by Stack Overflow as well as some Google results regarding this issue. I've tried to install and reinstall VS Community 2019 with C++ for desktop module, Visual Studio build tools with C++ build tools, the newest Windows 10 SDK with all options as well as the newest rustup-init installation. Where might my problem be?
You need to install Windows SDK. Download Visual C++ Build Tools from https://visualstudio.microsoft.com/downloads/ and select Windows SDK during install. Or if If you have already installed it:
Windows Settings > Apps > Microsoft Visual C++ Build Tools > Modify > Windows SDK
https://users.rust-lang.org/t/problems-with-installing-rust-on-windows/9349/22
http://asyncbulbs.blogspot.com/2017/06/workaround-for-rustc-with-new-visual.html
direct link to Build Tools (should work still) https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15
https://github.com/rust-lang/rust/issues/43039#issuecomment-589321158
https://github.com/rust-lang/prev.rust-lang.org/issues/1015
After a lot of trial and error I discovered that I had previously installed mingw with GNU. Even if rust looked for link.exe in "...Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC...", it was using GNU version not MSVC version of some dependencies. So in my case using not default(which is for MSVC which comes with VS) installation, but an GNU platform specific rust installation from https://forge.rust-lang.org/infra/other-installation-methods.html worked for me. Maybe if someone experienced could explain the issue in normal terms for future reference.

Visual Studio 2005: "Error: the Visual C++ Project Engine is not properly installed."

My VS2005 started printing the following error:
Error: the Visual C++ Project Engine is not properly installed. The build cannot continue. Please repair the Visual Studio installation.
What do I do now? Is there a way to fix this that does not require reinstalling the application?
I was able to solve this by following this procedure:
locate this file "VCProjectEngine.dll" (vc/vcpackages)
re-register it by running this command on the shell ( the command window):
regsvr32 VCProjectEngine.dll

building ruby on windows 7

I know this has been asked before but I ran into a specific problem.
I'm trying to build ruby 1.9.2 rc2 on windows 7. When I run configure.bat it aborts with the following message.
cl -nologo -MD rtname.c user32.lib -link > nul
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.
I find that the file 'rtname.c' does not exist anywhere within the source files. And this is why cl aborts.
I'm totally clueless as to what to do next. Searching for rtname.c on google doesn't return anything.
The first thing you have to do on windows is make sure your have some version of Visual studio C++ express edition installed. The latest version can be downloaded here
Next, you need to run the following file from the command line:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat
This configures your path environmental variable to allow the command prompt (and other programs) to find cl.exe. After doing this, running configure.bat should work correctly. This will build a 32-bit version of Ruby.
Maybe Visual Studio is required in your case to build Ruby from sources on Windows, but why don't you use RubyInstaller instead? It is a nice build environment; you can compile any version of Ruby on your machine, even from TRUNK.
If I understand it correctly you must have the C++ compiler installed to build Ruby. Could it be that you are missing that?
The RubyInstaller is quite stable and works most times.
I found that having already installed ruby on the box helps, see http://blog.cyplo.net/2011/01/01/compiling-ruby-1-9-2-windows/ , hope that helps

Building Opensource Qt for Visual Studio 2005/2008

Does anyone have instructions on building the opensource version of Qt? Now that the repository is opened up, I'm trying to build for VS2008 but I'm getting errors when it tries to build qmake.
I found the question I'm looking to use Visual Studio to write and compile using the open source version of Qt4 but this information is out of date, and doesn't really help me. For reference, here's what happens when I try to build with configure -platform win32-msvc2008
Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
cl -c -Foproject.obj -W3 -nologo -O2 -I. -Igenerators -Igenerators\unix -Igenerators\win32 -Igenerators\mac -
IC:\dev\open_source\qt\include -IC:\dev\open_source\qt\include\QtCore -IC:\dev\open_source\qt\include -IC:\dev\open_sou
rce\qt\include\QtCore -IC:\dev\open_source\qt\src\corelib\global -IC:\dev\open_source\qt\include\QtScript -IC:\dev\op
en_source\qt\mkspecs\win32-msvc2008 -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NODLL -DQT_NO_STL
-DQT_NO_COMPRESS -DUNICODE -DHAVE_QCONFIG_CPP -DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -D
QT_NO_DATASTREAM -DQT_NO_PCRE -DQT_BOOTSTRAPPED -DQMAKE_OPENSOURCE_EDITION project.cpp
project.cpp
c:\dev\open_source\qt\src\corelib\tools\qstringlist.h(45) : fatal error C1083: Cannot open include file: 'QtCore/qalgori
thms.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
Building qmake failed, return code 2
Well, one helpful thing is to run configure inside the Visual Studio Command Prompt. That should be available in the Visual Studio start menu group under Visual Studio Tools.
Also now when you run configure you don't have to specify target platform, because it will be set as an environment variable by the VS Command Prompt.
I got errors from configure and nmake when I did not use the VS Command Prompt, and since switching I have not had any issues.
So the simple instructions would be:
1) open VS command prompt
2) navigate to qt folder where configure.exe is located
3) configure
4) nmake
Please, ensure that you have ActiveState Perl installed
This blog article seems to have more recent information on building Qt with visual studio. Hope it helps.
Note that Nokia, as of Qt 4.6, is now providing their own open source VS builds of Qt, so it is no longer necessary to build from source yourself to do development with Visual Studio. Access their open source download page, and look for builds named (e.g.) qt-win-opensource-4.6.1-vs2008.exe.
Also, if you simply want to compile with MSVC so you can develop with the open source libraries with visual studio, I put together a project to provide "pre-built" Qt LGPL libraries with MSVC 2008.
It might be helpfull and has the advantages of taking up less space then compiling it yourself. It also provides a command prompt with all your environment variables set up for you and a link to launch Visual Studio with a Qt environment. It's called qt-msvc-installer.
What user156973 said. Install ActiveState perl and run configure again.

Resources