Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rake specs failure on Windows #201

Closed
djberg96 opened this issue Apr 18, 2012 · 22 comments
Closed

rake specs failure on Windows #201

djberg96 opened this issue Apr 18, 2012 · 22 comments

Comments

@djberg96
Copy link
Contributor

Hi,

ffi (latest from git repo) using MSVC++ 10
Windows 7

c:\Users\djberge\Repositories\ffi>rake specs
The system cannot find the path specified.
[warn] YARD unavailable
mkdir -p build/i386-mswin32_100/ffi_c/1.9.3
cd build/i386-mswin32_100/ffi_c/1.9.3
c:/usr/bin/ruby.exe -I. ../../../../ext/ffi_c/extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include... no
checking for rb_thread_blocking_region()... yes
checking for ruby_native_thread_p()... yes
checking for rb_thread_call_with_gvl()... yes
creating extconf.h
creating Makefile
cd -
cd build/i386-mswin32_100/ffi_c/1.9.3
nmake

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

generating ffi_c-i386-mswin32_100.def

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

NMAKE : fatal error U1052: file 'Makefile.vc' not found
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
rake aborted!
Command failed with status (2): [nmake...]

Tasks: TOP => specs => compile => compile:i386-mswin32_100 => compile:ffi_c:i386-mswin32_100 => copy:ffi_c:i386-mswin32_
100:1.9.3 => build/i386-mswin32_100/ffi_c/1.9.3/ffi_c.so
(See full trace by running task with --trace)
@ghost
Copy link

ghost commented May 3, 2012

I think this is due to building in a separate build dir. You could look in ext/ffi_c/libffi.vc.mk, find the line that looks like:

@cd $(LIBFFI_BUILD_DIR) && $(MAKE) -f Makefile.vc

and try changing it to

@cd $(LIBFFI_BUILD_DIR) && $(MAKE) -f $(LIBFFI_SRC_DIR)/Makefile.vc

@djberg96
Copy link
Contributor Author

djberg96 commented May 8, 2012

Ok, I tried it but got this:

NMAKE : fatal error U1052: file '../../../../ext/ffi_c/libffi/Makefile.vc' not found
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'

I don't actually see a Makefile.vc, btw, just a Makefile. I tried changing it, but nmake didn't seem to like it.

@ghost
Copy link

ghost commented May 8, 2012

There should be a Makefile.vc in libffi (i.e. https://github.com/ffi/ffi/blob/master/ext/ffi_c/libffi/Makefile.vc)

@ghost ghost closed this as completed Jan 25, 2013
@alikh31
Copy link

alikh31 commented Jun 8, 2014

I'm trying to compile ffi for msvc compiler but somehow it choose mingw over it, I couldn't find any instruction for building it on the wiki, other than that very short one, could any one help me with that??

cc: @ghost @djberg96

@djberg96
Copy link
Contributor Author

I still see this on master with VC 2013.

@tduehr
Copy link
Member

tduehr commented May 22, 2015

rake specs doesn't work anyway... does rake spec work with VC?

@djberg96
Copy link
Contributor Author

@tduehr Same issue with rake spec.

@tduehr
Copy link
Member

tduehr commented May 26, 2015

does rake build work?

@djberg96
Copy link
Contributor Author

@tduehr Yes, it works.

@tduehr
Copy link
Member

tduehr commented May 26, 2015

can you supply a fresh full trace for this?

@djberg96
Copy link
Contributor Author

The whole shebang:

PS C:\Users\djberge\Repositories\ffi> git pull
Current branch master is up to date.

PS C:\Users\djberge\Repositories\ffi> ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [i386-mswin32_120]

PS C:\Users\djberge\Repositories\ffi> rake spec --trace
The system cannot find the path specified.
** Invoke spec (first_time)
** Invoke compile (first_time)
** Invoke compile:i386-mswin32_120 (first_time)
** Invoke compile:ffi_c:i386-mswin32_120 (first_time)
** Invoke copy:ffi_c:i386-mswin32_120:2.2.1 (first_time)
** Invoke lib (first_time, not_needed)
** Invoke build/i386-mswin32_120/ffi_c/2.2.1/ffi_c.so (first_time)
** Invoke build/i386-mswin32_120/ffi_c/2.2.1/Makefile (first_time, not_needed)
** Invoke build/i386-mswin32_120/ffi_c/2.2.1 (first_time, not_needed)
** Invoke ext/ffi_c/extconf.rb (first_time, not_needed)
** Invoke ext/ffi_c/AbstractMemory.c (first_time, not_needed)
** Invoke ext/ffi_c/ArrayType.c (first_time, not_needed)
** Invoke ext/ffi_c/Buffer.c (first_time, not_needed)
** Invoke ext/ffi_c/Call.c (first_time, not_needed)
** Invoke ext/ffi_c/ClosurePool.c (first_time, not_needed)
** Invoke ext/ffi_c/DataConverter.c (first_time, not_needed)
** Invoke ext/ffi_c/DynamicLibrary.c (first_time, not_needed)
** Invoke ext/ffi_c/Function.c (first_time, not_needed)
** Invoke ext/ffi_c/FunctionInfo.c (first_time, not_needed)
** Invoke ext/ffi_c/LastError.c (first_time, not_needed)
** Invoke ext/ffi_c/LongDouble.c (first_time, not_needed)
** Invoke ext/ffi_c/MappedType.c (first_time, not_needed)
** Invoke ext/ffi_c/MemoryPointer.c (first_time, not_needed)
** Invoke ext/ffi_c/MethodHandle.c (first_time, not_needed)
** Invoke ext/ffi_c/Platform.c (first_time, not_needed)
** Invoke ext/ffi_c/Pointer.c (first_time, not_needed)
** Invoke ext/ffi_c/Struct.c (first_time, not_needed)
** Invoke ext/ffi_c/StructByReference.c (first_time, not_needed)
** Invoke ext/ffi_c/StructByValue.c (first_time, not_needed)
** Invoke ext/ffi_c/StructLayout.c (first_time, not_needed)
** Invoke ext/ffi_c/Thread.c (first_time, not_needed)
** Invoke ext/ffi_c/Type.c (first_time, not_needed)
** Invoke ext/ffi_c/Types.c (first_time, not_needed)
** Invoke ext/ffi_c/Variadic.c (first_time, not_needed)
** Invoke ext/ffi_c/ffi.c (first_time, not_needed)
** Execute build/i386-mswin32_120/ffi_c/2.2.1/ffi_c.so
cd build/i386-mswin32_120/ffi_c/2.2.1
nmake

Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.


Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.

NMAKE : fatal error U1052: file 'Makefile.vc' not found
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
rake aborted!
Command failed with status (2): [nmake...]
C:/Ruby22VC/lib/ruby/2.2.0/rake/file_utils.rb:66:in `block in create_shell_runner'
C:/Ruby22VC/lib/ruby/2.2.0/rake/file_utils.rb:57:in `call'
C:/Ruby22VC/lib/ruby/2.2.0/rake/file_utils.rb:57:in `sh'
C:/Ruby22VC/lib/ruby/2.2.0/rake/file_utils_ext.rb:37:in `sh'
C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rake-compiler-0.9.5/lib/rake/extensiontask.rb:155:in `block (2 levels) in define_compile_tasks'
C:/Ruby22VC/lib/ruby/2.2.0/fileutils.rb:127:in `chdir'
C:/Ruby22VC/lib/ruby/2.2.0/fileutils.rb:127:in `cd'
C:/Ruby22VC/lib/ruby/2.2.0/rake/file_utils_ext.rb:37:in `chdir'
C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rake-compiler-0.9.5/lib/rake/extensiontask.rb:154:in `block in define_compile_tasks'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:240:in `call'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:235:in `each'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:199:in `each'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:199:in `each'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:199:in `each'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:199:in `each'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:199:in `each'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
C:/Ruby22VC/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
C:/Ruby22VC/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
C:/Ruby22VC/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
C:/Ruby22VC/lib/ruby/2.2.0/rake/application.rb:106:in `each'
C:/Ruby22VC/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
C:/Ruby22VC/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
C:/Ruby22VC/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
C:/Ruby22VC/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
C:/Ruby22VC/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
C:/Ruby22VC/lib/ruby/2.2.0/rake/application.rb:75:in `run'
C:/Ruby22VC/bin/rake.bat:40:in `<main>'
Tasks: TOP => spec => compile => compile:i386-mswin32_120 => compile:ffi_c:i386-mswin32_120 => copy:ffi_c:i386-mswin32_120:2.2.1 => build/i386-mswin32_120/ffi_c/2.2.1/ffi_c.so

@tduehr
Copy link
Member

tduehr commented May 26, 2015

Try changing Makefile to Makefile.vc on line 45 of ext/ffi_c/extconf.rb

@tduehr
Copy link
Member

tduehr commented May 26, 2015

Does rake compile work?

@djberg96
Copy link
Contributor Author

@tduehr I made the suggested change. It still fails, but I think we're making progress:

PS C:\Users\djberge\Repositories\ffi\ext\ffi_c> rake compile
(in C:/Users/djberge/Repositories/ffi)
The system cannot find the path specified.
mkdir -p build/i386-mswin32_120/ffi_c/2.2.1
cd build/i386-mswin32_120/ffi_c/2.2.1
C:/Ruby22VC/bin/ruby.exe -I. ../../../../ext/ffi_c/extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile
cd -
cd build/i386-mswin32_120/ffi_c/2.2.1
nmake

Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.

generating ffi_c-i386-mswin32_120.def
compiling ../../../../ext/ffi_c/AbstractMemory.c
AbstractMemory.c
c:\users\djberge\repositories\ffi\ext\ffi_c\Types.h(78) : fatal error C1083: Cannot open include file: 'ffi.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
rake aborted!
Command failed with status (2): [nmake...]
C:/Ruby22VC/bin/rake.bat:40:in `<main>'
Tasks: TOP => compile => compile:i386-mswin32_120 => compile:ffi_c:i386-mswin32_120 => copy:ffi_c:i386-mswin32_120:2.2.1 => build/i386-mswin32_120/ffi_c/2.2.1/ffi_c.so

@tduehr
Copy link
Member

tduehr commented May 26, 2015

Yes, we've at least loaded the Makefile and started compiling. Looks like we're missing an include flag somehow. I'll have to get VC setup in my windows VM to debug further.

@djberg96
Copy link
Contributor Author

I see ffi.h.vc and ffi.h.vc64 under libffi/include. Does extconf.rb need to be modified to look for those?

@tduehr
Copy link
Member

tduehr commented May 26, 2015

No, I think the libffi.vc.mk and libffi.vc64.mk files need to be changed. But i haven't done this on VC before so I really need to look at what's going on.

@djberg96
Copy link
Contributor Author

@tduehr Any more luck with this?

@phasis68 Any ideas?

@phasis68
Copy link
Contributor

It seems that libffi on MSVC is not compatible with rake spec

If I modify extconf.rb#L40
$LOCAL_LIBS << " ./libffi/.libs/libffi_convenience.lib" if !libffi_ok && RbConfig::CONFIG['host_os'] =~ /mswin/
to
$LOCAL_LIBS << " ../../../../ext/ffi_c/libffi/.libs/libffi_convenience.lib" if !libffi_ok && RbConfig::CONFIG['host_os'] =~ /mswin/

And

libffi.vc.mk#L7
INCFLAGS = $(INCFLAGS) -I$(LIBFFI_BUILD_DIR)/include -I$(LIBFFI_BUILD_DIR)/src/x86
to
INCFLAGS = $(INCFLAGS) -I$(LIBFFI_SRC_DIR)/include -I$(LIBFFI_SRC_DIR)/src/x86

libffi.vc.mk#L24
@cd $(LIBFFI_BUILD_DIR) && $(MAKE) -f Makefile.vc
to
@cd $(LIBFFI_SRC_DIR) && $(MAKE) -f Makefile.vc

Then, ffi_c.so can be built.
But, there are still errors related with spec.

@djberg96
Copy link
Contributor Author

@phasis68, thanks!

It compiled, so we're making progress. Here's the failure I saw when running rake spec:

install -c build/i386-mswin32_120/ffi_c/2.2.2/ffi_c.so lib/ffi_c.so
cp build/i386-mswin32_120/ffi_c/2.2.2/ffi_c.so build/i386-mswin32_120/stage/lib/ffi_c.so
C:/Ruby22VC/bin/ruby.exe -I'C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-support-3.3.0/lib';'C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rs
pec-core-3.3.1/lib' 'C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/exe/rspec' --pattern 'spec/**{,/*/**}/*_spec.rb' --color -w --format documentation
The system cannot find the path specified.
"make CPU=i386 OS=win32 "
ERROR:
C:/Users/Daniel/Repositories/ffi/spec/ffi/spec_helper.rb:68:in `compile_library': Unable to compile "C:/Users/Daniel/Repositories/
ffi/spec/ffi/fixtures/libtest.dll" (RuntimeError)
        from C:/Users/Daniel/Repositories/ffi/spec/ffi/spec_helper.rb:78:in `<module:TestLibrary>'
        from C:/Users/Daniel/Repositories/ffi/spec/ffi/spec_helper.rb:77:in `<top (required)>'
        from C:/Ruby22VC/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby22VC/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Users/Daniel/Repositories/ffi/spec/ffi/async_callback_spec.rb:6:in `<top (required)>'
        from C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1327:in `load'
        from C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'
        from C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1325:in `each'
        from C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
        from C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:102:in `setup'
        from C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:88:in `run'
        from C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:73:in `run'
        from C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:41:in `invoke'
        from C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/exe/rspec:4:in `<main>'
C:/Ruby22VC/bin/ruby.exe -I'C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-support-3.3.0/lib';'C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rs
pec-core-3.3.1/lib' 'C:/Ruby22VC/lib/ruby/gems/2.2.0/gems/rspec-core-3.3.1/exe/rspec' --pattern 'spec/**{,/*/**}/*_spec.rb' --color -w --format documentation failed
``

@djberg96
Copy link
Contributor Author

djberg96 commented Jun 24, 2016

It seems we'll need to create a Makefile compatible with nmake instead of GNUmakefile, and modify GMAKE to use nmake.

@djberg96
Copy link
Contributor Author

Well, we're now going on 5 years since the original report, so I think I'll close since I'm not really doing Ruby on Windows much any more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants