Cを使用するRuby拡張機能をコンパイル/作成するにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/4057306

  •  27-09-2019
  •  | 
  •  

質問

cを使用するルビーエクステンションを作成したい。しかし、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 <varargs.h>."
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include/varargs.h:5:2: error: #error "Revise your code to use <stdarg.h>."
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ファイルには、コードの1行しかありません。

#include <ruby.h>

どんな助けも大歓迎です。

役に立ちましたか?

解決

もちろん、ヘッダーファイルだけを含めることはできません。Rubyライブラリにリンクする必要があります。

読む この章からのこの章。

また、お気軽に GitHubで私のレポを閲覧します, 、私は多くの拡張機能を書きます。

助けが必要な場合は、そのサイトにメッセージを送ってください。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top