Thanks for this very interesting series. I've followed along up to this point but I can't build it after adding #include "mruby.h". I get lots of these errors:
C:\workdir>cl /Zi /std:c++latest /GR- /nologo /analyze main.cpp /Imruby /link /debug user32.lib /SUBSYSTEM:windows /ENTRY:mainCRTStartup libmruby.lib libmruby_core.lib
main.cpp
C:\workdir\mruby\string.h(23): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\workdir\mruby\string.h(26): error C3646: 'len': unknown override specifier
I've tried mruby 3 and mruby 2.1.2 with the same result.
It looks like the C headers are not being parsed correctly by cl.exe but I don't know enough to work out the underlying problem.
I got the mruby headers and .lib files working on my Windows 10 PC using the following process:
After downloading the mruby source from github, check out the 2.1.2 version as follows:
git checkout tags/2.1.2
Build mruby as described in the article in a x64 Native Tools Command Prompt for VS2019 window (ruby minirake)
Copy libmruby.lib and libmruby_core.lib to the working directory as described in the article
Copy mruby\include to the working directory as described in the article. The mruby.h file and the mruby folder should be in the same directory as the main.cpp file.
Then, I needed to do some things differently to get the article code to compile. The differences needed on my system were:
Add /MD to the compiler options, since the ruby minirake task is compiling libmruby.lib and libmruby_core.lib with this option. (I worked this out by looking at the ruby minirake --verbose output. The compiler messages were not helpful.)
I needed to specify the absolute path of the working directory with the /I option on my system using the %~dp0.
The last thing that confused me is that adding /SUBSYSTEM:windows /ENTRY:mainCRTStartup to the end of the compile command will hide all printf or puts output from mruby, so I recommend leaving these out while debugging.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for this very interesting series. I've followed along up to this point but I can't build it after adding #include "mruby.h". I get lots of these errors:
I've tried mruby 3 and mruby 2.1.2 with the same result.
It looks like the C headers are not being parsed correctly by cl.exe but I don't know enough to work out the underlying problem.
I got the mruby headers and .lib files working on my Windows 10 PC using the following process:
ruby minirake
)Then, I needed to do some things differently to get the article code to compile. The differences needed on my system were:
ruby minirake
task is compiling libmruby.lib and libmruby_core.lib with this option. (I worked this out by looking at theruby minirake --verbose
output. The compiler messages were not helpful.)My minimal test program for mruby is:
and the .bat file to compile it is:
I needed to specify the absolute path of the working directory with the /I option on my system using the %~dp0.
The last thing that confused me is that adding
/SUBSYSTEM:windows /ENTRY:mainCRTStartup
to the end of the compile command will hide all printf or puts output from mruby, so I recommend leaving these out while debugging.