Burgestrand / spotify

Low-level Ruby bindings for libspotify, the official Spotify C API
https://rubygems.org/gems/spotify
Other
147 stars 17 forks source link

FFI does not find libspotify functions on Windows #1

Closed Burgestrand closed 12 years ago

Burgestrand commented 13 years ago

Following error is raised when loading Hallon:

in `attach_function': Function 'sp_error_message' not found in [libspotify] (FFI::NotFoundError)

This is a result of name mangling in windows DLLs.

As of currently, this can be hacked (really, it’s evil) around by hooking the attach_function method in FFI::Library, and then iterating over the arguments to calculate the total byte size to finally mangle the name before trying to bind it.

Burgestrand commented 12 years ago

This was (hopefully) fixed in FFI v1.0.10, see related commit here: https://github.com/ffi/ffi/commit/89000c9461c180fa6630c58cde24dfd641535888

Keeping the issue open until I have confirmation.

Burgestrand commented 12 years ago

Oh, one more thing it appears; I need to use ffi_convention :stdcall for it to pick the names up on windows. I’ll make a minor release for this.

http://rdoc.info/github/ffi/ffi/master/FFI/Library#ffi_convention-instance_method

Burgestrand commented 12 years ago

Hah, I fail, forgot the minor release thingy. While I’m on the topic, it’s probably wise to only do the :stdcall thingy on windows. Who knows what things I could screw up. One can work around it with the following code, though.

module Spotify
  @ffi_convention = :stdcall
end

require 'spotify' # after we’ve done the thing above!
Burgestrand commented 12 years ago

This issue has been around for ages. I have no idea how Hallon fares on windows either, so for now I’ll leave windows as unsupported.