Tuesday, April 3, 2012

arduino progress

today we met at adam's place
i got the soft potentiometer to control an led blink frequency.
mike got a gyro to control a servo.  turn the gyro, the servo turns to match
adam made george's bigger robot run.
rajath installed emacs-ide (with my help)

Wednesday, October 5, 2011

emacs is hard to use

trying to write an emacs extension. all i got was "writing gnu emacs extensions" copyright 1997. i figured i'd follow it until i came across something obviously outdated. that happened on page 19 mid-way through the first example where it refers to the keybinding delete-backward-char which isn't in the default bindings. actually it happened back on page 12 where it says backspace is bound to help, which isn't true. whatever, i kept reading to find out how to rebind keys until the delete-backward-char thing.

anyways, now i'm trying to read the emacs lisp introduction. turns out the easiest way to do that is opening emacs, going to menu option "Help|More Manuals|Introduction to Emacs Lisp". clicking that drops you into an info reader thing. turns out the emacs menubar grows an "Info" menu with basic navigation. but that didn't stop me from not noticing it and searching the internet for 20 minutes first. i know i've seen an info tutorial before. oh yeah! go to "Help|More Manuals|All other Manuals" then search for "info" with "C-s info" then hitting C-s over and over. it's near the bottom.

Tuesday, July 5, 2011

dejagnu up and running

trying to follow this:
http://www.gnu.org/software/dejagnu/manual/x199.html

tl;dr


dginn% adduser dgt
dginn% sudo su dgt
dgt@dginn:/home/ozzloy$ cd
dgt@dginn:~$ cp .bashrc .bashrc_old
dgt@dginn:~$ vim .bashrc
dgt@dginn:~$ diff -u .bashrc_old .bashrc
--- .bashrc_old 2011-07-05 20:48:12.213693305 -0700
+++ .bashrc 2011-07-05 20:49:43.243826829 -0700
@@ -102,3 +102,5 @@
. /etc/bash_completion
fi

+PS1="\u:\w\$ "
+
dgt@dginn:~$ exit
exit
dginn% sudo su dgt
dgt:/home/ozzloy$ cd
dgt:~$ mkdir dejagnu.test
dgt:~$ cd !$
cd dejagnu.test
dgt:~/dejagnu.test$ cp -r /usr/share/doc/dejagnu/examples/calc/\
{configure.in,Makefile.am,calc.c,testsuite} . # from 3.2.2

dgt:~/dejagnu.test$ aclocal
dgt:~/dejagnu.test$ autoconf
dgt:~/dejagnu.test$ autoheader
dgt:~/dejagnu.test$ cp Makefile.am Makefile.am_old
dgt:~/dejagnu.test$ vim Makefile.am
dgt:~/dejagnu.test$ diff -u Makefile.am_old Makefile.am # note that this differs from section 3.2.2
--- Makefile.am_old 2011-07-05 21:11:44.795765132 -0700
+++ Makefile.am 2011-07-05 21:17:20.026256810 -0700
@@ -18,7 +18,8 @@
AUTOMAKE_OPTIONS = dejagnu

check_PROGRAMS = calc
+bin_PROGRAMS = calc
calc_SOURCES = calc.c

EXTRA_DIST = testsuite/calc.test/calc.exp testsuite/config/unix.exp calc.1
-RUNTESTDEFAULTFLAGS = --tool calc CALC=`pwd`/calc --srcdir $$srcdir/testsuite
+RUNTESTDEFAULTFLAGS = --tool calc CALC=`pwd`/calc --srcdir ./testsuite

dgt:~/dejagnu.test$ touch NEWS README AUTHORS ChangeLog # run this and the next before automake --add-missing
dgt:~/dejagnu.test$ mkdir doc # to avoid "config.status: error: cannot find input file: `Makefile.in'" when running ./configure
dgt:~/dejagnu.test$ automake --add-missing
Makefile.am: installing `./INSTALL'
Makefile.am: installing `./COPYING' using GNU General Public License v3 file
Makefile.am: Consider adding the COPYING file to the version control system
Makefile.am: for your code, to avoid questions about which license your project uses.
Makefile.am: installing `./depcomp'
dgt:~/dejagnu.test$ ls
aclocal.m4 calc.h.in COPYING install-sh missing
AUTHORS ChangeLog depcomp Makefile.am NEWS
autom4te.cache configure doc Makefile.am_old README
calc.c configure.in INSTALL Makefile.in testsuite
# note the presence of Makefile.in. this file is only added by automake --add-missing
# if the files NEWS README AUTHORS ChangeLog and doc/ exist
dgt:~/dejagnu.test$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking for strcmp... yes
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating calc.h
config.status: calc.h is unchanged
config.status: executing depfiles commands
# note lack of "config.status: error: cannot find input file: `Makefile.in'"
dgt:~/dejagnu.test$ make
make all-am
make[1]: Entering directory `/home/dgt/dejagnu.test'
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT calc.o -MD -MP -MF .deps/calc.Tpo -c -o calc.o calc.c
mv -f .deps/calc.Tpo .deps/calc.Po
gcc -g -O2 -o calc calc.o
make[1]: Leaving directory `/home/dgt/dejagnu.test'

Wednesday, March 23, 2011

hornetseye install continued

stuck on opencv gem

recap: trying to install opencv gem, it's not installing.
kudi-guetta% gem install opencv
Building native extensions.  This could take a while...
ERROR:  Error installing opencv:
        ERROR: Failed to build gem native extension.

        /home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/bin/ruby extconf.rb
>> check require libraries...
checking for main() in -lcxcore... yes
checking for main() in -lcv... yes
checking for main() in -lhighgui... yes
checking for main() in -lstdc++... yes
>> check require headers...
checking for cxcore.h... 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=/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/bin/ruby
        --with-opencv-dir
        --without-opencv-dir
        --with-opencv-include
        --without-opencv-include=${opencv-dir}/include
        --with-opencv-lib
        --without-opencv-lib=${opencv-dir}/lib
        --with-ffcall-dir
        --without-ffcall-dir
        --with-ffcall-include
        --without-ffcall-include=${ffcall-dir}/include
        --with-ffcall-lib
        --without-ffcall-lib=${ffcall-dir}/lib
        --with-cxcorelib
        --without-cxcorelib
        --with-cvlib
        --without-cvlib
        --with-highguilib
        --without-highguilib
        --with-stdc++lib
        --without-stdc++lib
extconf.rb:41: cxcore.h not found. (RuntimeError)
        from extconf.rb:40:in `each'
        from extconf.rb:40


Gem files will remain installed in /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/opencv-0.0.7 for inspection.
Results logged to /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/opencv-0.0.7/ext/gem_make.out
annoying.
jim v on rubyforge seems to have solved the problem. except where do i run ruby extconf.rb? i went to the directory containing gem_make.out to read it. turns out it just has the same thing as was printed to terminal above. but in the same directory was extconf.rb.

extconf.rb

i planned on running ruby extconf.rb with some extra flags, like jim v. for the values to the flag:
kudi-guetta% find / -name cxcore.h 2> /dev/null
/usr/include/opencv/cxcore.h
that's the header file location. i also needed the lib file location.
kudi-guetta% ls /usr/lib|grep opencv              
kudi-guetta% find / -name "*opencv*" 2> /dev/null
...
/usr/lib/pkgconfig/opencv.pc
...
i vaguely remember *.pc files from some other project. they are used by pkg-config to get the location of libs and header files. so i checked in there for the locations.
popped open extconf.rb just to see what was in it.
made these changes to it:

then in that directory:
rvm 1.8.7@hornetseye
ruby extconf.rb
make
still a fail, but in a different place:
kudi-guetta% ruby extconf.rb
>> check require libraries...
checking for main() in -lcxcore... yes
checking for main() in -lcv... yes
checking for main() in -lhighgui... yes
checking for main() in -lstdc++... yes
>> check require headers...
checking for cxcore.h... yes
checking for cv.h... yes
checking for highgui.h... yes
checking for stdarg.h... yes
>> ----- optional -----
>> check ffcall...
checking for main() in -lcallback... yes
checking for callback.h... yes
>> support OpenCV::GUI
creating Makefile
kudi-guetta% make
g++ -I. -I. -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -I. -DHAVE_CXCORE_H -DHAVE_CV_H -DHAVE_HIGHGUI_H -DHAVE_STDARG_H -DHAVE_CALLBACK_H -I/usr/include -I/usr/include/opencv    -fPIC -g -O2  -fPIC    -c cvchaincode.cpp
In file included from opencv.h:106,
                 from cvchaincode.h:13,
                 from cvchaincode.cpp:10:
cvcondensation.h:39: error: expected initializer before ‘*’ token
cvchaincode.cpp:49: error: expected ‘}’ at end of input
make: *** [cvchaincode.o] Error 1
aaaRRRGGG

wedekind's opencv ruby gem

ugh.
going back to the install site, i see this:
If you are unable to use RubyGems to install opencv, you may have to install hornetseye-opencv from source:

git clone git://github.com/wedesoft/hornetseye-opencv.git
cd hornetseye-opencv
rake
sudo rake install
cd ..
which isn't working for me. or ... it doesn't seem to be. here's what i get:
kudi-guetta% pwd
/home/ozzloy/src/hornetseye/hornetseye-opencv
kudi-guetta% rake 
(in /home/ozzloy/src/hornetseye/hornetseye-opencv)
kudi-guetta% rake install
(in /home/ozzloy/src/hornetseye/hornetseye-opencv)
kudi-guetta% rake test
(in /home/ozzloy/src/hornetseye/hornetseye-opencv)
ext/hornetseye_opencv.so: no such file to load -- opencv (LoadError)
        from ./test/tc_hornetseye_opencv.rb:22
        from /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
        from /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
        from /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
        from /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/b...]

(See full trace by running task with --trace)
just under the instructions for installing hornetseye-opencv, the page links to wedekind's fork of the opencv gem which i tried installing next.

installing wedekind's opencv gem fork

here's the tail end of the install process from wedekind's opencv gem install instructions.
kudi-guetta% rake gem
(in /home/ozzloy/src/hornetseye/ruby-opencv)
mkdir -p pkg
Gemspec generated
WARNING:  description and summary are identical
  Successfully built RubyGem
  Name: opencv
  Version: 0.0.7
  File: opencv-0.0.7.gem
mv opencv-0.0.7.gem pkg/opencv-0.0.7.gem
kudi-guetta% gem install pkg/opencv-0.0.7.gem 
Building native extensions.  This could take a while...
ERROR:  Error installing pkg/opencv-0.0.7.gem:
        ERROR: Failed to build gem native extension.

        /home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/bin/ruby extconf.rb
>> check require libraries...
checking for main() in -lcxcore... yes
checking for main() in -lcv... yes
checking for main() in -lhighgui... yes
checking for main() in -lcvaux... yes
checking for main() in -lstdc++... yes
>> check require headers...
checking for cxcore.h... yes
checking for cv.h... yes
checking for highgui.h... yes
checking for cvaux.h... yes
checking for stdarg.h... yes
>> ----- optional -----
>> check ffcall...
checking for main() in -lcallback... yes
checking for callback.h... yes
>> support OpenCV::GUI
creating Makefile

make
g++ -I. -I. -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -I. -DHAVE_CXCORE_H -DHAVE_CV_H -DHAVE_HIGHGUI_H -DHAVE_CVAUX_H -DHAVE_STDARG_H -DHAVE_CALLBACK_H -I/usr/include -I/usr/include/opencv    -fPIC -g -O2  -fPIC    -c cvchaincode.cpp
In file included from opencv.h:101,
                 from cvchaincode.h:13,
                 from cvchaincode.cpp:10:
cvcondensation.h:39: error: expected initializer before ‘*’ token
cvchaincode.cpp:49: error: expected ‘}’ at end of input
make: *** [cvchaincode.o] Error 1


Gem files will remain installed in /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/opencv-0.0.7 for inspection.
Results logged to /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/opencv-0.0.7/ext/gem_make.out
and this is the same problem i was having installing the gem via gem install opencv, after modifying the extconf.rb file to point to the right places. what do i do now? i'll see if i can figure out the problem with cvcondensation.h. nope, the file looks fine at line 39.

moving on to openexr

this installed just fine with:
sudo aptitude install -y libopenexr-dev
gem install hornetseye-openexr #i'm using rvm

on to qt4

installing the qt libs and stuff went fine sudo aptitude install libqt4-ruby1.8 qt4-dev-tools libswscale-dev -y
but the next step didn't work:
kudi-guetta% cd hornetseye-qt4 
kudi-guetta% rake
(in /home/ozzloy/src/hornetseye/hornetseye-qt4)
g++ -MM ext/xvwidget.cc ext/frame.cc ext/init.cc | sed -e :a -e N -e 's/\n/\$/g' -e ta | sed -e 's/ *\\\$ */ /g' -e 's/\$/\n/g' | sed -e 's/^/ext\//' > .depends.mf
g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS    -g -O2  -fPIC   -I/usr/include/qt4 -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -c -o ext/xvwidget.o ext/xvwidget.cc
In file included from ext/xvwidget.cc:36:
ext/xvwidget.hh:22: fatal error: X11/extensions/Xv.h: No such file or directory
compilation terminated.
rake aborted!
Command failed with status (1): [g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONS...]
/home/ozzloy/src/hornetseye/hornetseye-qt4/Rakefile:210
(See full trace by running task with --trace)
kudi-guetta%
i'll come back to this too.
so far i fail at ruby-opencv and hornetseye-qt4.

hornetseye-rmagick

of course the ubuntu stuff works fine: sudo aptitude install libmagickwand-dev -y.
woo! this seems to have worked as well: gem install hornetseye-rmagick (again, using rvm)

skipping v4l, straight to v4l2

sudo aptitude install linux-libc-dev -y was already installed.
gem install hornetseye-v4l2 went just fine too.

hornetseye-xorg

this might solve the problem with qt4 since it had something to do with a missing header file in some X11 path. let's hope so.
sudo aptitude install xserver-xorg-dev libgl1-mesa-dev libglu1-mesa-dev -y worked
gem install hornetseye-xorg failed like this:
kudi-guetta% gem install hornetseye-xorg
Fetching: hornetseye-xorg-0.5.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing hornetseye-xorg:
        ERROR: Failed to build gem native extension.

        "/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/bin/ruby" -rubygems /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@global/gems/rake-0.8.7/bin/rake RUBYARCHDIR=/home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2/lib RUBYLIBDIR=/home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2/lib
g++ -MM ext/openglimagepainter.cc ext/x11window.cc ext/x11output.cc ext/xvideoimagepainter.cc ext/frame.cc ext/x11display.cc ext/init.cc ext/timer.cc ext/ximagepainter.cc | sed -e :a -e N -e 's/\n/\$/g' -e ta | sed -e 's/ *\\\$ */ /g' -e 's/\$/\n/g' | sed -e 's/^/ext\//' > .depends.mf
(in /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2)
g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS    -g -O2  -fPIC   -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -c -o ext/openglimagepainter.o ext/openglimagepainter.cc
g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS    -g -O2  -fPIC   -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -c -o ext/x11window.o ext/x11window.cc
ext/x11window.cc:20: fatal error: X11/xpm.h: No such file or directory
compilation terminated.
rake aborted!
Command failed with status (1): [g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONS...]
/home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2/Rakefile:209
(See full trace by running task with --trace)


Gem files will remain installed in /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2 for inspection.
Results logged to /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2/./gem_make.out
damn. since that's the last section of interest to me, i'll try to solve it.
google for "X11/xpm.h: No such file or directory" gives me yinglcs2's similar problem. solution: sudo aptitude install -y libxpm-dev.
now it fails with a different message:
kudi-guetta% gem install hornetseye-xorg     
Building native extensions.  This could take a while...
ERROR:  Error installing hornetseye-xorg:
        ERROR: Failed to build gem native extension.

        "/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/bin/ruby" -rubygems /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@global/gems/rake-0.8.7/bin/rake RUBYARCHDIR=/home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2/lib RUBYLIBDIR=/home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2/lib
g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS    -g -O2  -fPIC   -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -c -o ext/openglimagepainter.o ext/openglimagepainter.cc
(in /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2)
g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS    -g -O2  -fPIC   -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -c -o ext/x11window.o ext/x11window.cc
g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS    -g -O2  -fPIC   -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -c -o ext/x11output.o ext/x11output.cc
g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS    -g -O2  -fPIC   -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -c -o ext/xvideoimagepainter.o ext/xvideoimagepainter.cc
In file included from ext/xvideoimagepainter.cc:35:
ext/xvideoimagepainter.hh:20: fatal error: X11/extensions/Xvlib.h: No such file or directory
compilation terminated.
rake aborted!
Command failed with status (1): [g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONS...]
/home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2/Rakefile:209
(See full trace by running task with --trace)


Gem files will remain installed in /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2 for inspection.
Results logged to /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/hornetseye-xorg-0.5.2/./gem_make.out
so to google again, this time for "X11/extensions/Xvlib.h: No such file or directory".
found a solution from ubuntu forum's abhayashi:
sudo aptitude install -y libxv-dev
and now gem install hornetseye-xorg works!

back to hornetseye-qt4

since hornetseye-xorg involved a bunch of x stuff, and the qt4 error looked like a missing x header, i'll just try installing it again:
kudi-guetta% pwd                               
/home/ozzloy/src/hornetseye/hornetseye-qt4
kudi-guetta% rake             
(in /home/ozzloy/src/hornetseye/hornetseye-qt4)
g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS    -g -O2  -fPIC   -I/usr/include/qt4 -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -c -o ext/xvwidget.o ext/xvwidget.cc
g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS    -g -O2  -fPIC   -I/usr/include/qt4 -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -c -o ext/frame.o ext/frame.cc
g++ -DNDEBUG -DHAVE_CONFIG_H -D__STDC_CONSTANT_MACROS    -g -O2  -fPIC   -I/usr/include/qt4 -I/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-linux -c -o ext/init.o ext/init.cc
g++ -shared -o ext/hornetseye_qt4.so ext/xvwidget.o ext/frame.o ext/init.o -lswscale -lX11 -lXv -lQtGui -lQtCore -L/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib -Wl,-R -Wl,/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib -L/home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib -lruby -L.  -rdynamic -Wl,-export-dynamic -lrt -ldl -lcrypt -lm   -lc
kudi-guetta% rake install
(in /home/ozzloy/src/hornetseye/hornetseye-qt4)
kudi-guetta% rake test
(in /home/ozzloy/src/hornetseye/hornetseye-qt4)
hooray! that looks like it worked. now the only problem is with the opencv extension.

Monday, March 21, 2011

hornets eye install

http://www.wedesoft.demon.co.uk/hornetseye-api/file.Installation.html
sudo aptitude install build-essential ruby1.8 ruby1.8-dev irb1.8 rubygems1.8 rake libswscale-dev

first problem


googled "sh: rake1.8: not found" and got a solution. it even has a little explanation of what's wrong and suggested short, medium, and long term workarounds.
sudo su -
rake=/usr/bin/rake gem install malloc

another workaround

i initially didn't encounter this problem because i had started off using rvm and creating a gemset for hornetseye. then i thought i should follow the instructions on the site more closely to avoid headaches. so that's funny. rvm sets up the paths and stuff correctly i guess, so the rvm install of 1.8.7 has no problem finding the rvm install of rake.

second problem

same as the first one, but with multiarray in place of malloc. again, not a problem when i was using rvm.

screw it, using rvm

i'll keep using rvm until i run across some problem forcing me to do it without rvm.

hornetseye-frame problem

installing hornets-frame complains too:

looks like it needs some boost lib. off to google again. also i tried installing the yard gem, but that gave some error output, so i abandoned it... but turns out the solution presents itself in the next step anyways. gem install yard
googled for "fatal error: boost/smart_ptr.hpp: No such file or directory" and got this (among others). need to sudo aptitude install -y libboost-dev

yet another hornetseye-frame problem

this time, hornetseye-frame installed, but its documentation seems to have failed.

but it looks like the solution is right there in the error output, so i'll try installing bluecloth like it says: gem install bluecloth. after this, i retried installing yard, in case there was stuff it failed to do on the failed install attempt in the last step. gem install yard

tangent on yard gem

so yard sure did have a ton of other stuff to do.
gem install yard gave a ton of output like this:
[error]: Exception occurred while generating 'YARD/Server/Commands/ListMethodsCo
mmand.html'  
[error]: ArgumentError: wrong number of arguments (1 for 0)
[error]: Stack trace:
        /home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in `raise'
        /home/ozzloy/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in `require'
        /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/yard-0.6.5/lib/yard/templates/helpers/html_helper.rb:456:in `simple_markup_html'
        /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/yard-0.6.5/lib/yard/templates/helpers/html_helper.rb:81:in `html_markup_rdoc'
        /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/yard-0.6.5/lib/yard/templates/helpers/html_helper.rb:42:in `send'
        /home/ozzloy/.rvm/gems/ruby-1.8.7-p330@hornetseye/gems/yard-0.6.5/lib/yard/templates/helpers/html_helper.rb:42:in `htmlify'
to google again, searching for
[error]: Exception occurred while generating 'YARD/Server/Commands/ListMethodsCo
mmand.html'
which yielded nothing. this time i searched for "ubuntu yard gem" and got jenny fong's blog entry dealing with yard on ubuntu. from there i gathered i needed to start fresh with rdoc and yard, which i did like this:
sudo gem uninstall rdoc # complained that rdoc wasn't installed
gem uninstall rdoc # also complained that rdoc wasn't installed
gem install rdoc # took a while, but worked
gem install yard

thankfully, that worked.

yard gem tangent done

retrying the hornetseye-frame install: gem install hornetseye-frame
it worked! on to the next line.

hornetseye-{alsa,1394}

this worked just fine:
sudo aptitude install -y libasound2-dev
gem install hornetseye-alsa
sudo aptitude install -y libdc1394-22-dev
gem install hornetseye-1394
sudo aptitude install -y libavformat-dev libswscale-dev
gem install hornetseye-ffmpeg
gem install hornetseye-narray
gem install narray

opencv problem

tried gem install opencv which gave this output:

i have dealt with opencv before, so i knew there was something with a name like "libcv" that i probably needed. aptitude search libcv turned up what i was looking for. next this:
sudo aptitude install -y libcv-dev libcv2.1 libcvaux-dev libcvaux2.1

still no opencv gem

another try at gem install opencv gave this:

needs some highgui dev package i think. google search for the fail line yielded nothing, but i had more luck with aptitude search highgui|grep dev. this gave the package name which i installed via sudo aptitude install -y libhighgui-dev

still still no opencv gem

even after installing that stuff i get the following behavior

so i'm gonna go to sleep now and try to finish tomorrow. i'll probably just have to give a flag of what directory to include for opencv junk. (the bulk of this post was written a day before i posted it.)

Thursday, February 3, 2011

creating a gem

this whole post is useless but i already wrote it so i'm posting


this video goes over everything in this post, except for conventional directory and file layout and the bin/ directory. but i didn't find it until i was about to hit publish. oh wells.

scattered notes


it's been difficult to find a tutorial on building a gem. it seems as though many ways have come and gone, and not gone. bundler can create gems. gem can create gems if you set up the files correctly. jeweler. new gem. hoe. echoe... well bundler gem some_gem_name creates a skeleton project for you and makes it into a git repo for you so you can start off clean. that's right, it creates a skeleton and makes it a git repo. awesome. and it uses git to specify which files are included in the gem. check out some_gem_name/some_gem_name.gemspec after running that command. you'll see something like:
s.files         = `git ls-files`.split("\n")
s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables   =
`git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }

so it makes sense that bundler starts off the project under git control. this also forces me to think about what exactly is and isn't in git.

gem structure conventions


from reading through actionmailer and some other gems, i've found that the basic structure is to mirror ruby class and module nesting th directory structure. after running bundle gem some_gem_name a new directory called some_gem_name is created in the current directory. under that is Gemfile, some_gem_name.gemspec, lib/ some other stuff. under lib/ is some_gem_name/ and some_gem_name.rb. in some_gem_name.rb is a skeleton with a module named SomeGemName! i guess bundler just uses the convention of taking out underscores and capitalizing the next letter, and capitilizing the first letter too. so that's cool.

so now we're in lib/some_gem_name/


in lib/some_gem_name/ is a file named version.rb. in that is simply:
module SomeGemName
VERSION = "0.0.0"
end

based on what i've read in actionmailer and thor, this is also where the meat goes. the guts of the code that make the gem do what it does. every file that does something important and lib like should go in here. and it should begin with some requires, and all the code should be between a [module|class] SomeGemName and an end. in addition, any directory under this one (for example lib/some_gem_name/foo_bar) should be the name of a module or class, with the first capital letter made lower, and every following capital made lower and preceded by an underscore. so the directory foo_bar corresponds to the class or module FooBar. furthermore, the nesting of those classes and modules in ruby should reflect the nesting of the directories on the filesystem. for example lib/some_gem_name/foo_bar/ should contain files that begin with some requires, followed by opening the class|module SomeGemName and then opening the class|module FooBar.
for example, inside lib/some_gem_name/foo_bar/foo_bar.rb, you would find something like:
require 'nokogiri'

module SomeGemName
class FooBar
def baz directance
fronlum = turboencabulate directance
fronlum.dipits
end
end
end

another convention seems to be having a name.rb as a sibling to every lib/**/name/. so there's a some_gem_name.rb corresponding to lib/some_gem_name/ and located at lib/some_gem_name.rb. another example, there should be a foo_bar.rb for lib/some_gem_name/foo_bar/ located at lib/some_gem_name/foo_bar.rb

bin/


there's also the option of creating a directory bin/ as a sibling to lib/. this is what bundler does. it looks like the convention is to use a file with no extension. that's how bundler creates the bundle command. so that's cool. within these files, you can just require 'some_gem_name' and use the stuff in your gem libs. the context is already set up so your some_gem_name

rake


right after running bundle gem some_gem_name && cd some_gem_name you can do rake -T to see a list that looks like this:
rake build    # Build template_validator-0.0.4.gem into the pkg directory
rake install  # Build and install template_validator-0.0.4.gem into system ...
rake release  # Create tag v0.0.4 and build and push template_validator-0.0...

so after writing the code into the locations described above, you can run rake build && rake install && irb -r some_gem_name to test out the gem you just created! so that's awesome.

actionmailer has a neat trick

to turn some code i wrote into a gem, i decided to read through other gems for examples of how to do it. while reading through the actionmailer gem installed with rails 3.0.3, i found this /home/ozzloy/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/actionmailer-3.0.3/lib/rails/generators/mailer/templates/mailer.rb:

class <%= class_name %> < ActionMailer::Base
default :from => "from@example.com"
<% for action in actions -%>

# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.<%= file_path.gsub("/",".") %>.<%= action %>.subject
#
def <%= action %>
@greeting = "Hi"

mail :to => "to@example.org"
end
<% end -%>
end

so that's cool! it's using ruby to generate ruby code. metaprogramming, but not by manipulating classes and modules directly. instead generating the source code to create modules and classes, which i presume gets printed to a file with scaffolding. and probably also eval'd so as to keep DRY. anyways, neat.

Where am I?