vendredi 3 avril 2015

Ruby C Extention on Windows

I've been practicing with writing C extensions for Ruby. It works perfectly on Ubuntu and even when I tried linking to an third party library in my case I used SDL2 and it worked just fine on Ubuntu. When I'm writing C extensions for Ruby on Windows it compiles just fine I get my .so file and everything no errors. But when I test require like this ruby -I. -e "require 'gsdl'" I get an error saying "The specified module could not be found." Why is this how can I get the C extensions to work. I have Devkit installed and I used Msys and the make that was included in Devkit's bin folder to make the c extention in my project /ext file. My extconf looks like this require "mkmf" ext_nme = "gsdl" dir_config(ext_nme,"C:/Users/my_name/gsdl/SDL/include/SDL2","C:/Users/my_name/g sdl/SDL/lib") have_library("mingw32") have_library("SDL2main") have_library("SDL2") create_makefile(ext_nme) and my C extention looks like this #include <ruby.h> #include "SDL.h" void Init_gsdl(VALUE self); void Init_gsdl(VALUE self){ SDL_Window* window; SDL_Init(SDL_INIT_VIDEO); window = SDL_CreateWindow("Strawberry",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,240, 240,SDL_WINDOW_SHOWN); SDL_Delay(3000); SDL_DestroyWindow(window); puts("Gehirn SDL"); SDL_Quit(); } This is my directory structure


Aucun commentaire:

Enregistrer un commentaire