Recently I attempted to install the Algorithm::SVMLight perl module via CPAN onto my Ubuntu box. It did not go well. I discovered that the CPAN package doesn’t include half of what you need, and I could not find any directions anywhere about how to get it to work. That compounded with svm-light’s lack of commenting made for a fun evening.
I’m posting my experience and solution here so maybe someone else who has the same problem can use it and not have to pull their hair out like I did.
First off.. forget about installing via CPAN. We're doing this manually. Here's what I had to do:
1. Download Algorithm::SVMLight to its own directory:
- cd ~
- wget Algorithm-SVMLight-0.08.tar.gz
- tar xzf Algorithm-SVMLight-0.08.tar.gz
2. Download svmlight into that directory:
- cd Algorithm-SVMLight-0.08
- mkdir svm_light
- cd svm_light
- wget svm_light.tar.gz
- tar xzf svm_light.tar.gz
3. Algorithm-SVMLight-0.08 includes a patch file SVMLight.patch that you need to apply:
- patch -p0 svmlight.patch
4. Now we need to build and install svmlight, and then create a shared library that Algorithm::SVMLight links into:
- cd svm_light
4.1. Open Makefile in an editor (eg. nano, pico, vi, gedit, whatever) and replace
"CFLAGS= -O3" with "CFLAGS= -O3 -fPIC"
- make
- gcc -shared -o libsvmlight.so svm_common.o svm_learn.o svm_hideo.o svm_learn_main.o
5. Put this library somewhere Algorithm::SVMLight can find it (you need to be root to do this):
- su
- cp libsvmlight.so /usr/lib/
- exit
- sudo cp libsvmlight.so /usr/lib/
6. Before we can build Algorithm::SVMLight, we need to add a couple header files:
- cp *.h ../lib/Algorithm/
7. Now Algorithm::SVMLight should build and install:
(Note: on Debian I needed to apt-get libmodule-build-perl first.)
- cd ..
- perl Makefile.PL # CPAN might download some stuff here. It's cool though.
- perl Build.PL
- make
- sudo make install
I think I've remembered everything correctly. With any amount of luck this should work. If not, send me an email and I'll try to help you out.
Tags
Links