jasperproject / jasper-client

Client code for Jasper voice computing platform
MIT License
4.53k stars 1.01k forks source link

Unable to compile openfst #34

Closed fritz-fritz closed 10 years ago

fritz-fritz commented 10 years ago

openfst will not compile on Ubuntu 13.10 64-bit. (www.openfst.org site is currently down though openfst-1.3.3 and openfst-1.3.4 can be found on mirrors). Have tried numerous recommendations from the cached form of this page with both 1.3.3 and 1.3.4 though can't seem to get openfst to compile:

Making install in bin
make[2]: Entering directory `/home/roland/openfst-1.3.4/src/bin'
g++ -DHAVE_CONFIG_H   -I./../include -I./../script    -g -O2 -MT fstarcsort.o -MD -MP -MF .deps/fstarcsort.Tpo -c -o fstarcsort.o fstarcsort.cc
mv -f .deps/fstarcsort.Tpo .deps/fstarcsort.Po
/bin/bash ../../libtool --tag=CXX   --mode=link g++  -g -O2   -o fstarcsort fstarcsort.o ../script/libfstscript.la ../lib/libfst.la -lm -ldl 
libtool: link: g++ -g -O2 -o .libs/fstarcsort fstarcsort.o  ../script/.libs/libfstscript.so ../lib/.libs/libfst.so -lm -ldl
../script/.libs/libfstscript.so: undefined reference to `dlopen'
../script/.libs/libfstscript.so: undefined reference to `dlerror'
collect2: error: ld returned 1 exit status
make[2]: *** [fstarcsort] Error 1
make[2]: Leaving directory `/home/roland/openfst-1.3.4/src/bin'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/home/roland/openfst-1.3.4/src'
make: *** [install-recursive] Error 1

with some modifications the build got farther to src/extensions/far before it failed.

I know this isn't an issue with the Jasper Client though this is a dependency and thought you should be aware / maybe had a solution.

fritz-fritz commented 10 years ago

Okay I have now been able to get openfst to compile through trial and error based off the suggestions at the page mentioned above.

  1. edit src/bin/Makefile.am, src/extensions/far/Makefile.am, src/extensions/pdt/Makefile.am
    • on lines beginning with LDADD = remove the trailing -lm -ldl
    • append on a new line AM_LDFLAGS = -Wl,-no-as-needed -lm -ldl
  2. edit configure.ac:
    • remove -Werror from AM_INIT_AUTOMAKE(
    • and replace with -Wno-extra-portability
  3. run sudo autoreconf --force --install
  4. run sudo ./configure --enable-compact-fsts --enable-const-fsts --enable-far --enable-lookahead-fsts --enable-pdt
  5. run sudo make install

While I don't know yet whether this results in a working configuration, the build did finish.

I will test further and post back

fritz-fritz commented 10 years ago

ran make check had to edit src/test/Makefile.am in the same way as above but here are the results:

PASS: fst_test
PASS: weight_test
PASS: algo_test
============================================================================
Testsuite summary for OpenFst 1.3.4
============================================================================
# TOTAL: 3
# PASS:  3
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
fritz-fritz commented 10 years ago

Also of note I ran into the same issue with phonetisaurus-0.7.8. I have reached out to the developer and hope to have an answer soon to resolve that compile error as well.

$ sudo make
g++ -O2 -I3rdparty/sparsehash -I3rdparty/utfcpp     Phonetisaurus.o FstPathFinder.o MBRDecoder.o LatticePruner.o util.o phonetisaurus-g2p.cpp -o ../phonetisaurus-g2p -lfst -ldl -lm -lrt
/usr/local/lib/libfst.so: undefined reference to `dlopen'
/usr/local/lib/libfst.so: undefined reference to `dlerror'
collect2: error: ld returned 1 exit status
make: *** [../phonetisaurus-g2p] Error 1

Any suggestions would be appreciated

fritz-fritz commented 10 years ago

found the problem was related to gcc / g++ version 4.8 which Ubuntu 13.10 was running... Installing v4.4 with sudo apt-get install gcc-4.4 g++-4.4 cpp-4.4 and then configuring the machine to use it via upgrade-alternative fixed the compilation issues...

with a few other tweaks to the source code (home directories & audio hw number) I was up and running and have already built a module to control WeMo switches by voice! Will probably fork and make some recommended changes shortly to accommodate non-raspi users...

AndyMacDee commented 10 years ago

Many thanks for logging all your issues and solutions. I have reached the stage where I am now able to speak to Jasper and I get a recognition beep. I don't get any audible responses from Jasper, and it appears to struggle understanding most of what I say and this appears on the main.py command line every 10 seconds after Jasper reports back his interpretation on what I've said:

ALSA lib pcm_dsnoop.c:612:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server socket
jack server is not running or cannot be started

Just wondering how you managed to overcome these hurdles. I'm pretty sure the hardware IDs I'm using are okay, but I could be wrong.

fritz-fritz commented 10 years ago

It probably is the hw address that is wrong. try to cd ~/jasper/client and execute aplay -D hw:1,0 beep_hi.wav as this is one of the commands in mic.py that you should be hearing. If you do not hear anything try removing -D hw:1,0 or changing it to something else like -D hw:0,0 If this resolves your issue it is definitely the hardware address that is hardcoded into the code that is causing issues. To fix, you can change the address in jasper/client/mic.py and jasper/boot/boot.py or alter your /etc/asound.conf

davesnowdon commented 10 years ago

I couldn't get openfst to compile on the 'Pi itself however, I did manage to cross-compile it on my Fedora Linux box and then transfers the output to the 'pi

1) Set up cross-compilation environment as described here: http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/

2) Configure openfst using: ./configure --prefix=$PIROOT --build=x86_64-redhat-linux --host=arm-unknown-linux-gnueabi --enable-compact-fsts --enable-const-fsts --enable-far --enable-lookahead-fsts --enable-pdt

where $PIROOT was set to a directory other that /usr/local so that running the install script would not overwrite my native binaries

I got x86_64-redhat-linux by running gcc -dumpmachine on my Fedora box, your value for --host may vary depending on the machine you are building on

3) make 4) make install 5) zip up the files under $PIROOT, copy the archive to the 'Pi and unzip under /usr/local

I tested that I can run one of the executables, haven't finished building everything else yet

Chazmus commented 10 years ago

The install-recursive errors can also be caused by a lack of swap space. I'm currently building it again after creating a 512Mb swap file and certainly seems to have gotten further than before... still building though... can take up to 6 hours on the pi apparently :-/