From rubyforge at lokorin.org Fri Jan 4 17:24:11 2008 From: rubyforge at lokorin.org (Andreas Launila) Date: Fri, 04 Jan 2008 23:24:11 +0100 Subject: [gecoder-devel] Simplifying the installation Message-ID: <477EB20B.6080502@lokorin.org> A gem that includes both Gecode/R and Gecode (1.3.1) in source form now exists. It "should" make the installation from nothing to Gecode + Gecode/R as simple as "gem install ..." (possibly plus some path tweaking). The gem works on Fedora and should work on other Linux distros as well. I do not have access to a machine running OSX. I would appreciate feedback from anyone that does. Windows lacks a standard compiler though, anything beyond precompiled binaries will probably lead to a too large initial threshold. Hence it would seem desirable to add a precompiled gem for win32 like for instance Mongrel and RMagick has. The question is how well that can be automated. -- Andreas Launila From rubyforge at lokorin.org Tue Jan 8 18:47:14 2008 From: rubyforge at lokorin.org (Andreas Launila) Date: Wed, 09 Jan 2008 00:47:14 +0100 Subject: [gecoder-devel] Simplifying the installation In-Reply-To: <477EB20B.6080502@lokorin.org> References: <477EB20B.6080502@lokorin.org> Message-ID: <47840B82.6050701@lokorin.org> Andreas Launila wrote: > The gem works on Fedora and should work on other Linux distros as well. > It's also confirmed to work on Ubuntu and OS X. -- Andreas Launila From rubyforge at lokorin.org Thu Jan 24 07:18:04 2008 From: rubyforge at lokorin.org (Andreas Launila) Date: Thu, 24 Jan 2008 13:18:04 +0100 Subject: [gecoder-devel] Simplifying the installation In-Reply-To: <477EB20B.6080502@lokorin.org> References: <477EB20B.6080502@lokorin.org> Message-ID: <479881FC.5040207@lokorin.org> Andreas Launila wrote: > Windows lacks a standard compiler though, anything beyond precompiled > binaries will probably lead to a too large initial threshold. Hence it > would seem desirable to add a precompiled gem for win32 like for > instance Mongrel and RMagick has. The question is how well that can be > automated. > A precompiled binary gem for Windows has been added. It has only been tested under Windows XP, where all specs pass. MinGW[1] is used to cross-compile the bindings so that the gem can be built under Linux. I have not been able to link the bindings against Gecode's MSVC DLLs. Hence the precompiled gem includes the cross-compiled Gecode DLLs and can not be used with a normal Gecode installation. Linking MSVC libraries into a MinGW library is not unheard of[2] (albeit that method, as well as the one listed in the MinGW FAQ didn't work for me), so it should be possible with some additional work. This is how to set up and use the cross-compile environment necessary to build the new gem: == Overview 1. Install MinGW 2. Cross-compile Ruby 3. Cross-compile Gecode (Optional) 4. Cross-compile the Gecode/R bindings == Install MinGW A simple way is to use a shell script[3] that does all the downloading and building. It's a bit outdated though so you need to apply the patch in[4] (under "Success with GCC 4.1.2") and update the versions of packages to download. You need at least GCC 4.2 due to[5]. I used the following versions. GCC_CORE_ARCHIVE="gcc-core-4.2.1.tar.gz" GCC_GPP_ARCHIVE="gcc-g++-4.2.1.tar.gz" GCC_G77_ARCHIVE="" GCC_OBJC_ARCHIVE="" GCC_JAVA_ARCHIVE="" BINUTILS_ARCHIVE="binutils-2.18.50-20071123-src.tar.gz" MINGW_ARCHIVE="mingw-runtime-3.14.tar.gz" W32API_ARCHIVE="w32api-3.11.tar.gz" After building MinGW you will have to make sure that the bin folder is in your path and create symbolic links prefixed with "i386-" to the executables. For instance using the following in the bin dir. ruby -e "Dir['*'].each{ |x| %x{ln -s -T #{x} i386-#{x}} }" == Cross-compile Ruby Download the Ruby source. I used 1.8.6-p111. Use the following configuration (possibly with some appropriate prefix). env ac_cv_func_getpgrp_void=no \ ac_cv_func_setpgrp_void=yes \ rb_cv_negative_time_t=no \ ac_cv_func_memcmp_working=yes \ rb_cv_binary_elf=no \ ./configure \ --host=i386-mingw32 \ --build=i686-linux Make and install and then go to the installation directory and edit lib/ruby/1.8/i386-mingw32/win32/win32.h . Comment out the read, write and select macros. Upon building Ruby a file named "rbconfig.rb" will have been created in the build directory. Replace the line CONFIG["LDSHARED"] = "i386-mingw32-gcc -shared -s" with CONFIG["LDSHARED"] = "i386-mingw32-g++ -shared -s" Copy the produced "rbconfig.rb" file to the ext/win32 dir in the Gecode/R dir. == Cross-compile Gecode This step produces the Gecode DLLs and include files. Those files are already included in SVN, so this part should not be needed. Download and unpack the Gecode tarball[7] (Gecode/R is currently using version 1.3.1). Use the following configuration (possibly with some appropriate prefix). ./configure \ --with-host-os=Windows \ --host=i386-mingw32 \ --build=i686-linux \ --disable-examples Edit Makefile and add "--whole-archive" to DLLFLAGS, then run make. A number of DLLs should now have been created, copy them to vendor/gecode/win32/lib in the Gecode/R dir. Copy the gecode folder (the one containing all the headers) to vendor/gecode/win32/include. == Cross-compile the Gecode/R bindings This is done as part of building the gems (hence "rake gem" should be enough). The following is how to do it manually. Enter the ext directory inside the Gecode/R dir. Run ruby -Iwin32 extconf-win32.rb make A file named "gecode.so" should have been created. Rename it to "gecode.dll" and move it to the lib directory. [1] http://www.mingw.org/ [2] http://blog.outofhanwell.com/2006/05/01/linking-msvc-libraries-with-mingw-projects/ [3] http://www.mingw.org/MinGWiki/index.php/BuildMingwCross [4] http://www.mingw.org/MinGWiki/index.php/build%20a%20Win32%20x-compiler%20for%20Linux [5] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27650 [6] http://www.ruby-lang.org/en/downloads/ [7] http://www.gecode.org/download.html -- Andreas Launila