Want to install the pyaudio in toradex apalis board

Hello,

Trying to install the google cloud in toradex board for speech to text conversion.

And need to install the ‘pyaudio’ dependency package.

pip install pyaudio

Getting the ‘portaudio’ library not found error while installing the pyaudio.

http://portaudio.com/download.html
And now cross compiled the portaudio (pa_stable_v190600_20161030.tgz) and placed the libraries in ‘/usr/lib/’.

But now getting different linker error while installing the pyaudio.

Also I have tried to install this package ‘python-audio’ & ‘portaudio-v19’ via yocto, still it says ‘pyaudio’ not found.

Can you please help me to install the pyaudio in toradex board ?

(env) root@apalis-imx6:/# pip install pyaudio
Collecting pyaudio
  Using cached PyAudio-0.2.11.tar.gz
Building wheels for collected packages: pyaudio
  Running setup.py bdist_wheel for pyaudio ... error
  Complete output from command /env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-iNp6BF/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpnk9Eoxpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-armv7l-2.7
  copying src/pyaudio.py -> build/lib.linux-armv7l-2.7
  running build_ext
  building '_portaudio' extension
  creating build/temp.linux-armv7l-2.7
  creating build/temp.linux-armv7l-2.7/src
  arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/saro/workdir/Titus/yocto_toradexApalis_imx6/oe-core/build/tmp-glibc/work/armv7at2hf-neon-angstrom-linux-gnueabi/python/2.7.12-r1=/usr/src/debug/python/2.7.12-r1 -fdebug-prefix-map=/home/saro/workdir/Titus/yocto_toradexApalis_imx6/oe-core/build/tmp-glibc/sysroots/x86_64-linux= -fdebug-prefix-map=/home/saro/workdir/Titus/yocto_toradexApalis_imx6/oe-core/build/tmp-glibc/sysroots/apalis-imx6= -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-armv7l-2.7/src/_portaudiomodule.o
  In file included from /usr/include/python2.7/Python.h:8:0,
                   from src/_portaudiomodule.c:28:
  /usr/include/python2.7/pyconfig.h:1193:0: warning: "_POSIX_C_SOURCE" redefined
   #define _POSIX_C_SOURCE 200112L

  In file included from /usr/include/stdio.h:27:0,
                   from src/_portaudiomodule.c:27:
  /usr/include/features.h:225:0: note: this is the location of the previous definition
   # define _POSIX_C_SOURCE 200809L

  arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed build/temp.linux-armv7l-2.7/src/_portaudiomodule.o -L/usr/lib -lportaudio -lpython2.7 -o build/lib.linux-armv7l-2.7/_portaudio.so
  /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_front.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
  /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_unix_util.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
  /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_unix_util.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
  /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_debugprint.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
  /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_unix_oss.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
  /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_converters.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
  /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_cpuload.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
  /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_process.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
  collect2: error: ld returned 1 exit status
  error: command 'arm-angstrom-linux-gnueabi-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for pyaudio
  Running setup.py clean for pyaudio
Failed to build pyaudio
Installing collected packages: pyaudio
  Running setup.py install for pyaudio ... error
    Complete output from command /env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-iNp6BF/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-63Y3_q-record/install-record.txt --single-version-externally-managed --compile --install-headers /env/include/site/python2.7/pyaudio:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-armv7l-2.7
    copying src/pyaudio.py -> build/lib.linux-armv7l-2.7
    running build_ext
    building '_portaudio' extension
    creating build/temp.linux-armv7l-2.7
    creating build/temp.linux-armv7l-2.7/src
    arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/saro/workdir/Titus/yocto_toradexApalis_imx6/oe-core/build/tmp-glibc/work/armv7at2hf-neon-angstrom-linux-gnueabi/python/2.7.12-r1=/usr/src/debug/python/2.7.12-r1 -fdebug-prefix-map=/home/saro/workdir/Titus/yocto_toradexApalis_imx6/oe-core/build/tmp-glibc/sysroots/x86_64-linux= -fdebug-prefix-map=/home/saro/workdir/Titus/yocto_toradexApalis_imx6/oe-core/build/tmp-glibc/sysroots/apalis-imx6= -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-armv7l-2.7/src/_portaudiomodule.o
    In file included from /usr/include/python2.7/Python.h:8:0,
                     from src/_portaudiomodule.c:28:
    /usr/include/python2.7/pyconfig.h:1193:0: warning: "_POSIX_C_SOURCE" redefined
     #define _POSIX_C_SOURCE 200112L

    In file included from /usr/include/stdio.h:27:0,
                     from src/_portaudiomodule.c:27:
    /usr/include/features.h:225:0: note: this is the location of the previous definition
     # define _POSIX_C_SOURCE 200809L

    arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed build/temp.linux-armv7l-2.7/src/_portaudiomodule.o -L/usr/lib -lportaudio -lpython2.7 -o build/lib.linux-armv7l-2.7/_portaudio.so
    /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_front.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
    /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_unix_util.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
    /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_unix_util.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
    /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_debugprint.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
    /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_unix_oss.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
    /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_converters.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
    /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_cpuload.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
    /usr/lib/gcc/arm-angstrom-linux-gnueabi/6.2.1/../../../../arm-angstrom-linux-gnueabi/bin/ld: error: /usr/lib/libportaudio.a(pa_process.o): requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
    collect2: error: ld returned 1 exit status
    error: command 'arm-angstrom-linux-gnueabi-gcc' failed with exit status 1

    ----------------------------------------
Command "/env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-iNp6BF/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-63Y3_q-record/install-record.txt --single-version-externally-managed --compile --install-headers /env/include/site/python2.7/pyaudio" failed with error code 1 in /tmp/pip-build-iNp6BF/pyaudio/
(env) root@apalis-imx6:/#
(env) root@apalis-imx6:/#

Hi

As the error message suggest, did you try to add -fPIC to CFLAGS?

Alternatively you could try to link with the bfd linker and not with gold. I assume that
/usr/bin/ld is a symlink to the real linker being a hardlink to the either ld.bfd or ld.gold.

Replace the hardlink with a link to the bfd linker.

e.g.

root@colibri-imx6:~# ls -l /usr/bin/arm-angstrom-linux-gnueabi-ld*
-rwxr-xr-x 2 root root 3102572 Feb 10  2017 /usr/bin/arm-angstrom-linux-gnueabi-ld
-rwxr-xr-x 1 root root  445808 Feb 10  2017 /usr/bin/arm-angstrom-linux-gnueabi-ld.bfd
-rwxr-xr-x 2 root root 3102572 Feb 10  2017 /usr/bin/arm-angstrom-linux-gnueabi-ld.gold

.

root@colibri-imx6:~# rm /usr/bin/arm-angstrom-linux-gnueabi-ld
root@colibri-imx6:~# ln /usr/bin/arm-angstrom-linux-gnueabi-ld.bfd /usr/bin/arm-
angstrom-linux-gnueabi-ld 

Max

Now able to install pyaudio by adding -fPIC to CFLAGS.
Thanks for the help.