2016-05-02 60 views
0
Ruby擴展

sampleSource code(包括生成文件)錯誤的C語言創建一個

我做一個測試上面的示例, 但是,當我編譯它遇到錯誤! 我做錯了嗎?

H:\Ruby\test_ymal\MyTest>make 
compiling MyTest.c 
In file included from d:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0/ruby/define 
       from d:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0/ruby/ruby.h 
       from d:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0/ruby.h:33, 
       from MyTest.c:2: 
d:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0/ruby/win32.h:319:44: warning: 'st 
extern int clock_gettime(clockid_t, struct timespec *); 
              ^
d:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0/ruby/win32.h:320:43: warning: 'st 
extern int clock_getres(clockid_t, struct timespec *); 
             ^
linking shared-object mytest.so 
process_begin: CreateProcess(NULL, rm -f mytest.so, ...) failed. 
make (e=2): 
Makefile:253: recipe for target 'mytest.so' failed 
make: [mytest.so] Error 2 (ignored) 
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: mytest-i38 
mytest-i386-mingw32.def: file not recognized: File truncated 
collect2.exe: error: ld returned 1 exit status 
Makefile:253: recipe for target 'mytest.so' failed 
make: *** [mytest.so] Error 1 

----由2016年5月3日加----------------------

H:\Ruby\test_ymal\MyTest>make 
generating mytest-i386-mingw32.def 
compiling MyTest.c 
linking shared-object mytest.so 
process_begin: CreateProcess(NULL, rm -f mytest.so, ...) failed. 
make (e=2): 
Makefile:271: recipe for target 'mytest.so' failed 
make: [mytest.so] Error 2 (ignored) 

但( mytest.so)在ruby中測試的文件是可以的。
如何解決這個錯誤?
process_begin:CreateProcess的(NULL,RM -f mytest.so,...)失敗

irb(main):003:0> require 'H:\Ruby\test_ymal\MyTest\mytest.so' 
=> true 
irb(main):004:0> include MyTest 
=> Object 
irb(main):005:0> puts test1 
10 
=> nil 
irb(main):006:0> exit 
+0

請分享實際的源代碼和創建的Makefile。這看起來像一個問題,你正在使用的生成文件或工具鏈 – Mircea

+0

@Mircea感謝評論。我剛剛添加了我的測試源代碼(包括makefile)。感謝您的幫助 – nainaigu

+0

@Mircea我在makefile中修復了相同的錯誤。但仍然存在一個錯誤。你能幫助我嗎? – nainaigu

回答

0

我找到了答案。 rm -rf mytest.so進程在makefile中添加。 只是將其移出。