c/c++语言开发共享如何编译/创建使用c的ruby扩展?

我想创建一个使用c的ruby扩展。 但是当我使用gcc编译它时,我收到此错误:

gcc rubyext.c -orubyext -I /usr/local/include/ruby-1.9.1/ In file included from rubyext.c:1: /usr/local/include/ruby-1.9.1/ruby/ruby.h:25:25: error: ruby/config.h: No such file or directory In file included from rubyext.c:1: /usr/local/include/ruby-1.9.1/ruby/ruby.h:107: error: 'SIZEOF_INT' undeclared here (not in a function) /usr/local/include/ruby-1.9.1/ruby/ruby.h:108: error: 'SIZEOF_LONG' undeclared here (not in a function) /usr/local/include/ruby-1.9.1/ruby/ruby.h:112: error: 'SIZEOF_VOIDP' undeclared here (not in a function) In file included from /usr/local/include/ruby-1.9.1/ruby/ruby.h:1326, from rubyext.c:1: /usr/local/include/ruby-1.9.1/ruby/missing.h:25: error: redefinition of 'struct timeval' /usr/local/include/ruby-1.9.1/ruby/missing.h:35: error: redefinition of 'struct timespec' In file included from /usr/local/include/ruby-1.9.1/ruby/intern.h:27, from /usr/local/include/ruby-1.9.1/ruby/ruby.h:1327, from rubyext.c:1: /usr/lib/gcc/x86_64-linux-gnu/4.4.3/include/varargs.h:4:2: error: #error "GCC no longer implements ." /usr/lib/gcc/x86_64-linux-gnu/4.4.3/include/varargs.h:5:2: error: #error "Revise your code to use ." In file included from /usr/local/include/ruby-1.9.1/ruby/intern.h:29, from /usr/local/include/ruby-1.9.1/ruby/ruby.h:1327, from rubyext.c:1: /usr/local/include/ruby-1.9.1/ruby/st.h:122: error: expected declaration specifiers or '...' before 'uint32_t' In file included from /usr/local/include/ruby-1.9.1/ruby/ruby.h:1327, from rubyext.c:1: /usr/local/include/ruby-1.9.1/ruby/intern.h:508: error: expected declaration specifiers or '...' before 'rb_pid_t' /usr/local/include/ruby-1.9.1/ruby/intern.h:526: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'rb_fork' /usr/local/include/ruby-1.9.1/ruby/intern.h:527: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'rb_fork_err' /usr/local/include/ruby-1.9.1/ruby/intern.h:529: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'rb_waitpid' /usr/local/include/ruby-1.9.1/ruby/intern.h:530: error: expected ')' before 'pid' /usr/local/include/ruby-1.9.1/ruby/intern.h:531: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'rb_spawn' /usr/local/include/ruby-1.9.1/ruby/intern.h:532: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'rb_spawn_err' /usr/local/include/ruby-1.9.1/ruby/intern.h:534: error: expected ')' before 'pid' /usr/local/include/ruby-1.9.1/ruby/intern.h:652: error: expected declaration specifiers or '...' before 'uint32_t' 

我做错了吗? 我的rubyext.c文件只有一行代码:

 #include  

任何帮助是极大的赞赏。

    当然,您不能只包含头文件,您必须链接到Ruby库。

    阅读Pickaxe的这一章。

    也可以随意浏览我在github上的一些repos ,我写了很多C扩展。

    如果您需要帮助,请在该网站上给我发消息。

      以上就是c/c++开发分享如何编译/创建使用c的ruby扩展?相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注(计算机技术网)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请点击右边联系管理员删除。

      如若转载,请注明出处:https://www.ctvol.com/c-cdevelopment/518941.html

      (0)
      上一篇 2020年12月5日
      下一篇 2020年12月5日

      精彩推荐