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

Texplay 4.4 does not compile on Windows - Ruby 1.9.3 #26

Open
burtlo opened this issue Aug 28, 2014 · 11 comments
Open

Texplay 4.4 does not compile on Windows - Ruby 1.9.3 #26

burtlo opened this issue Aug 28, 2014 · 11 comments

Comments

@burtlo
Copy link
Contributor

burtlo commented Aug 28, 2014

Attempted to build this against commit 22ff506. It fails.

PS C:\source> git clone [email protected]:banister/texplay.git
PS C:\source> cd texplay
PS C:\source> git checkout 22ff506
PS C:\source\texplay> rake compile:texplay
Temporarily enhancing PATH to include DevKit...
cd tmp/i386-mingw32/texplay/1.9.3
make
linking shared-object texplay/texplay.so
bindings.o: In function `m_clone_image':
C:\source\texplay\tmp\i386-mingw32\texplay\1.9.3/../../../../ext/texplay/bindings.c:311: undefined reference to `rb_obj_reveal'
collect2: ld returned 1 exit status
make: *** [texplay.so] Error 1
rake aborted!
Command failed with status (2): [make...]

Tasks: TOP => compile:texplay => compile:texplay:i386-mingw32 => copy:texplay:i386-mingw32:1.9.3 => tmp/i386-mingw32/texplay/1.9.3/texplay.so
(See full trace by running task with --trace)
@burtlo burtlo changed the title Texplay does not compile on Windows - Ruby 1.9.3 Texplay 4.4 does not compile on Windows - Ruby 1.9.3 Aug 28, 2014
@burtlo
Copy link
Contributor Author

burtlo commented Aug 28, 2014

This looks like a case where the code is expecting Ruby 2.1.

Incompatibility
You can't write RBASIC(obj)->klass field directly because it is const value now.

Basically you should not write this field because MRI expects it to be an immutable field, but if you want to do it in your extension you can use the following functions:

VALUE rb_obj_hide(VALUE obj)
Clear RBasic::klass field. The object will be an internal object. ObjectSpace.each_object can't find this object.

VALUE rb_obj_reveal(VALUE obj, VALUE klass)
Reset RBasic::klass to be klass. We expect the `klass' is hidden class by rb_obj_hide().

@burtlo
Copy link
Contributor Author

burtlo commented Aug 28, 2014

Commit a3f16c6 by @gilles-leblanc added the functionality that is not compatible with Ruby 1.9.3.

I backed out that change and I successfully rake compile and rake package. However, when I attempt to install the gem I have issues with the freeglut_static

PS C:\source\texplay> gem install --local .\pkg\texplay-0.4.4.pre.gem
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing .\pkg\texplay-0.4.4.pre.gem:
        ERROR: Failed to build gem native extension.

        C:/Ruby/bin/ruby.exe extconf.rb
checking for main() in -lfreeglut_static... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby/bin/ruby
        --with-texplay/texplay-dir
        --without-texplay/texplay-dir
        --with-texplay/texplay-include
        --without-texplay/texplay-include=${texplay/texplay-dir}/include
        --with-texplay/texplay-lib
        --without-texplay/texplay-lib=${texplay/texplay-dir}/lib
        --with-freeglut_staticlib
        --without-freeglut_staticlib


Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.9.1/gems/texplay-0.4.4.pre for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.9.1/gems/texplay-0.4.4.pre/ext/texplay/gem_make.out

This is the same exact error that you get when attempting gem install texplay --pre.

@burtlo
Copy link
Contributor Author

burtlo commented Aug 28, 2014

Alright, if I had read more of the repository I would have stumbled upon the README in the vendor folder (https://github.com/banister/texplay/tree/master/ext/texplay/vendor/freeglut).

And the instructions are very simple for Windows users.

  1. Download RubyInstaller for Windows DevKit.
  2. Extract and install the DevKit. I have always placed my installations at C:\devkit
  3. Copy the GL folder from ext/texplay/vendor/freeglut/include to C:\devkit\mingw\include.
  4. Copy the libfreeglut_static.a from ext/texplay/vendor/freeglut/lib to C:\devkit\mingw\lib.
  5. gem install texplay --pre

This works, but this means that for windows users they would need to download this vendor content and then perform these steps. There must be a better way that I am not familiar with on how to package content like this when it has this kind of requirement.

@burtlo
Copy link
Contributor Author

burtlo commented Aug 28, 2014

Alright, excuse my ignorance again, I guess if I knew that rake-compiler added the rake task rake native gem. Running that command creates a gem on the platform with all the libraries compiled. Requiring you to perform none of the following above steps.

PS > rake native gem
PS > gem install --local pkg\texplay-0.4.4.pre-x86-mingw32.gem

Everything is OK if you build a native gem.

@burtlo
Copy link
Contributor Author

burtlo commented Aug 28, 2014

Alright in conclusion, to get everything working on Windows, I needed to back out the changes with commit a3f16c6 by @gilles-leblanc. That functionality is not compatible with Ruby 1.9.3. I imagine that we could IFDEF around that functionality, but I'm not sure the exact course of action.

This is an issue because Windows does not have decent support for Ruby 2.0 and no support for Ruby 2.1.

@gilles-leblanc
Copy link
Contributor

Eh... So we would loose Ruby 2.0+ compatibility on Linux and Mac in exchange for 1.9.3 on Windows?

@burtlo
Copy link
Contributor Author

burtlo commented Aug 28, 2014

I assume that we can get around this by:

  1. Using some #ifdef around a ruby version/platform
  2. Selectively load source from ext/texplay/extconf.rb

I have not ever done either of those things before so they are guesses.

@gilles-leblanc
Copy link
Contributor

Good idea.

I haven't either but we should look into it.

On Thu, Aug 28, 2014 at 9:29 AM, Franklin Webber [email protected]
wrote:

I assume that we can get around this by:

  1. Using some #ifdef around a ruby version/platform
  2. Selectively load source from ext/texplay/extconf.rb

I have not ever done either of those things before so they are guesses.


Reply to this email directly or view it on GitHub
#26 (comment).

@burtlo
Copy link
Contributor Author

burtlo commented Aug 28, 2014

Alright. I think I can fix it. I'll use Ruby's version.h to figure out the version.

@gilles-leblanc
Copy link
Contributor

If you need help let me know.
On Aug 28, 2014 10:27 AM, "Franklin Webber" [email protected]
wrote:

Alright. I think I can fix it. I'll use Ruby's version.h
https://github.com/ruby/ruby/blob/trunk/version.h to figure out the
version.


Reply to this email directly or view it on GitHub
#26 (comment).

burtlo pushed a commit to burtlo/texplay that referenced this issue Aug 28, 2014
Reference: banister#26

Ruby 1.9.3 does not support `rb_obj_reveal` so ifdef conditionals were added to allow the gem to be compiled.
@burtlo
Copy link
Contributor Author

burtlo commented Aug 28, 2014

@gilles-leblanc would you take a look at pull request #28 and tell if that looks about right.

  • Instead of deleting the KLASS_OF macro I conditionally define it.
  • I switch on the Ruby Major/Minor version to figure out which call to use in the m_clone_image function.

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

2 participants