我正在尝试编译mruby。这是我第一次从命令行编译一些东西。当我在目录上运行make时,我得到这样的结果:
make -C mrblib --no-print-directory CC=gcc LL=gcc
make -C ../tools/mrbc --no-print-directory CC=gcc LL=gcc
gcc -Wall -Werror-implicit-function-declaration -g -MMD -I../../src -I../../src/../include -c ../../src/st.c -o ../../src/st.o
In file included from ../../src/regint.h:93,
from ../../src/st.c:6:
../../src/../include/mruby.h: In function ‘mrb_special_const_p’:
../../src/../include/mruby.h:100: warning: comparison is always true due to limited range of data type
../../src/st.c: In function ‘st_hash’:
../../src/st.c:1053: error: ‘SIZEOF_ST_INDEX_T’ undeclared (first use in this function)
../../src/st.c:1053: error: (Each undeclared identifier is reported only once
../../src/st.c:1053: error: for each function it appears in.)
make[2]: *** [../../src/st.o] Error 1
make[1]: *** [../bin/mrbc] Error 2
make: *** [src/mrblib/mrblib.o] Error 2在Mac OS X 10.7.3上构建是不是有一个步骤我没有注意到?谢谢
发布于 2012-04-22 00:31:36
这个问题在几个小时前就解决了。去拿一份后备箱的新拷贝。
发布于 2013-10-14 10:55:31
如果这对任何人都有帮助,这里有一个关于如何开始使用mruby的快速教程:
作为先决条件,请确保您有git、C编译器和bison。您可能已经安装了这些工具。
克隆mruby源代码,在本例中,我将把它放在~/mruby中
git clone https://github.com/mruby/mruby.git ~/mruby在您的bash配置文件中,创建一个指向此目录根目录的变量。它稍后会很有用。
export MRUBY_HOME=~/mruby现在,在mruby根目录中,运行make
cd $MRUBY_HOME && makemruby现在已经编译了一些内容,并将其放入build目录中。在那里,您将找到一个库,以便将其包含在您自己的脚本中。
现在让我们编译一个示例脚本。将此文件命名为example.c
#include <stdlib.h>
#include <stdio.h>
#include <mruby.h>
int main(void)
{
mrb_state *mrb = mrb_open();
char code[] = "p 'hello world!'";
printf("Executing Ruby code from C!\n");
mrb_load_string(mrb, code);
return 0;
}要编译此脚本,我们需要指定刚刚编译的mruby库归档文件,并包含包含头文件的mruby include目录:
gcc example.c $MRUBY_HOME/build/host/lib/libmruby.a -I $MRUBY_HOME/include这将创建一个名为a.out的文件。要指定特定的文件名,可以传递-o选项和应用于编译输出的文件名。执行我们新编译的程序应该会像预期的那样显示:
./a.out
Executing Ruby code from C!
hello world!发布于 2015-06-07 00:25:50
我把它用在Windows上了。通过分享它,以防人们需要它:)
我用的是: Windows操作系统,mingw编译器,bison (提取二进制文件和依赖项,否则你会得到一个dll not found错误) ruby
在PATH环境变量中设置所有的bin文件夹(mindw,bison和ruby)。
接下来,在mruby文件夹中运行: mingw32-make.exe (位于mingw的Bin文件夹中)。
如果所有的PATH变量都设置正确,那么您的代码应该可以编译。
现在,您应该看到包含可执行文件的.\build\host\bin和包含所需库的.\build\host\lib。
接下来创建一个C++程序(我使用的是C::B)。
#include <stdlib.h>
#include <stdio.h>
#include <mruby.h>
#include <mruby/compile.h>
int main(void)
{
mrb_state *mrb = mrb_open();
if (!mrb) { /* handle error */ }
puts("Executing Ruby code from C!");
mrb_load_string(mrb, "p 'hello world!'");
mrb_close(mrb);
return 0;
}@Andrew example对我不起作用。我收到一个错误:未在此范围内声明'mrb_load_string‘
我更正了这个错误,包括:#include
我希望这是非常有用的设置库为windows!
https://stackoverflow.com/questions/10259082
复制相似问题