Thoughts and tutorials on programming

Saturday, May 30, 2009

how to install sqlite3 from source on ruby mingw (1.8 or 1.9)

here they are, inspired by a question from Charles Roper
1) install wget or curl in path
2) install unzip.exe (http://gnuwin32.sourceforge.net/packages/unzip.htm -- binaries link) in path, then put \bin in your path.
3) install rake compiler [gem install rake-compiler]
3.1) add the bin folder of GCC from the devkit to your  path [i.e. if you installed the straight devkit [1] then "set path=C:\ruby\devkit\gcc\3.4.5\bin;%PATH%"]
3.5) install msysgit, then git clone git://github.com/luislavena/sqlite3-ruby.git, then cd into it.
4) rake vendor:sqlite3
5) rake native gem
6) gem install pkg/xxx.gem

mingw ruby 1.9/1.8 how to install mysql from source


inspired by a question from JD[1], here's the instructions:

Looks like the only way I know of is (assuming ruby 1.9 with devkit [2]) 

1) download mysql 5.0.x windows "without installer" 
2) unzip, put/rename it to c:\mysql 
3) download mysql 2.8.1 binary from tmtm http://www.tmtm.org/en/mysql/ruby/ 
4) edit extconf so that anywhere it says mswin32 it now says mswin32|mingw  
4a) make sure that mysql's bin are *not* in your path [might not be ncessary, but just in case] 
5) run ruby extconf.rb -- --with-mysql-include=c:/mysql/include --with-mysql-lib=c:/mysql/lib/opt 
6) run make, then run make install 
7) make sure libmysql.dll is in your path or in current directory 8) run ruby -e 'require "mysql"' -- should work.

[1] http://www.ruby-forum.com/topic/188199#new
[2] http://programming-gone-awry.blogspot.com/2009/05/ruby-19-one-click-installer.html

Wednesday, May 27, 2009

how to setup a complete mingw msys build environment for ruby (including dependencies)

Here's how: use Luis Lavena's pre built scripts to set it up for you (in this case to set it up for building a complete version of ruby), then tie in to the msys and mgit that it created for you.

steps:

download rubyinstaller's source, git clone git://github.com/oneclick/rubyinstaller.git

then build a version, "any version" of ruby with it, a la

cd rubyinstaller

rake # wait about 30 minutes :)

now set your path to "use" its newly downloaded, loaded with dependencies, versions of mingw and msys, a la build_env.bat contents (in my case):

set PATH=D:\dev\downloads\rubyinstaller\sandbox\mingw\bin;D:\dev\downloads\rubyinstaller\sandbox\msys\bin;D:\dev\downloads\rubyinstaller\sandbox\msys\usr\local\bin;%PATH%

now you can go anywhere and build anything (other versions of ruby, whatever),
example of building ruby trunk:

D:\dev\downloads\ruby_trunk>build_env
D:\dev\downloads\ruby_trunk>sh

Melissa@BLACKY /d/dev/downloads/ruby_trunk
$ autoconf && ./configure && make && make install

much thanks to luis for setting this up, and the mingw/msys team.

Monday, May 18, 2009

e text editor on virtualbox howto

howto compile e text editor on ubuntu, virtualbox:

install ubuntu on a virtualbox guest.

Now we need to create some extra swap file (more RAM, basically).

create a new disk (say 2G) -- you'll probably want it fixed size.
add it as secondary master to the image (shutdown guest-> settings -> hard drives).

add it as swap now
[in ubuntu]

sudo mkswap /dev/sdc
edit /etc/fstab
add in this line:

/dev/sdc none swap sw 0 0

check top to see the old swap size
reboot
check top -- your swap size should have increased considerly, now it should compile with default settings.

e text editor on andlinux howto

finally got the e text editor to work on andlinux! sweet!

how to:

1) install andLinux, choose coFS so you can see *all* your windows files.

2) resize the default partition to > 2GB default [1]

http://ext2resize.sourceforge.net/download.html

extract c:\program files\andlinux\toporesize.zip

shutdown andlinux

now run (for 10GB)

C:\Program Files\andLinux\ImageResizeTool\toporesize-0.7.1>tfile ..\..\Drives\base.vdi 10000

now restart andlinux

and within it:

sudo apt-get install build-essential -y # install gcc

now download ext2resize within linux http://ext2resize.sourceforge.net/download.html

install ext2resize, then run

    sudo ext2online /dev/cobd0 


3) "give yourself more swap ram" [at least 1GB for sure 2GB swap file works well] [2]

root@andLinux:~# swapoff /dev/cobd1

c:\Program Files\andLinux\Drives>type swap.vdi >>swap.vdi2


several times

or in ruby:

a = File.new 'swap.vdi2', 'w'

a.seek 2e9

a.write 'a'

4) checkout the git repository

sudo apt-get install git-core

git clone git://github.com/etexteditor/e.git

apply this patch:

http://e-texteditor.com/forum/viewtopic.php?p=13046#13046

install some unlisted dependencies

sudo apt-get install build-essential curl libgtk2.0-dev

then follow the directions within linux-notes.txt

Then follow the directions under the section "it all comes crashing down"

http://fixnum.org/blog/2009/e_on_fedora

And you *might* have a working andlinux e text editor.

[1] http://www.andlinux.org/forum/viewtopic.php?p=1581#1581

[2] http://www.andlinux.org/forum/viewtopic.php?p=956&sid=ebe8efafb867fe03519fcf166dbe104e

Friday, May 08, 2009

ruby 1.9 one click installer

Here's how to get a pretty easy working 1.9/1.8.6 mingw (from my post to ruby installers list)

for the files at

http://rubyinstaller.org/downloads/

quick install instructions (1.8.6, 1.9):

install a ruby one click installer to c:\Ruby

afterward, 
c:\Ruby now has
  bin\
  lib\
  share\

Now unzip the devkit.7z and move its contents into the same folder
(devkit is a bundled up mingw GCC+msys).

i.e.

c:\Ruby now has
  bin\
  lib\
  share\ 
 devkit\
INSTALL.txt

(note: the message "This folder already contains a folder named bin"
is expected--choose "yes" to confirm folder replace).

next add c:\Ruby\bin to the beginning of your path and enjoy the power
of a faster ruby with a compiler.

==More Detailed instructions==

Same as above--however, if you want to use a folder other than c:\Ruby
then please change devkit/msys/1.0.11/etc/fstab to properly point to
the right directories for mingw and /usr/local

How to add ruby\bin to your path:
either do this on the command line thus:
set PATH=c:\ruby-1.9.1-p0-i386-mingw32\bin;%PATH%

or change the PATH variable within my computer -> properties ->
advanced -> environment variables (add it to the front of path within
"system variables").

== How to determine success ==
If successful you should get an output like (for 1.8):

C:\>ruby -v
ruby 1.8.6 (2009-03-31 patchlevel 368) [i386-mingw32]

C:\>gcc -v
Reading specs from C:/Ruby/devkit/gcc/3.4.5/bin/../lib/gcc/mingw32/3.4.5/specs
...

and installing binary gems should work properly:
C:\>gem install json
Building native extensions. This could take a while...
Successfully installed json 
...

If a gem fails to compile (ex: because of lack of headers), you can at 
times get away with doing a
gem install gemname --platform=mswin32
this installs the msvc binaries for it. They are *typically* compatible. It's safer, however, to download the headers and compile it locally, and submit your process upstream so they can release a quality mingw binary :)

Enjoy!

Contributors

Followers