cross compiling for android

  • Bleh

    Bleh - 2013-09-13

    I am attempting to cross compile ngspice for android. The commands I'm using are:

    ~/ngspice-25/release$ export CC="arm-linux-gnueabi-gcc"
    ~/ngspice-25/release$ ../configure --host=arm-linux-gnueabi
    ~/ngspice-25/release$ make

    and then an error occurs during make:

    ./ngmakeidx -o ngspice.idx ../../src/ngspice.txt
    /bin/bash: ./ngmakeidx: cannot execute binary file
    make[2]: *** [ngspice.idx] Error 126
    make[2]: Leaving directory /home/ryno/ngspice-25/release/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory/home/ryno/ngspice-25/release/src'
    make: *** [all-recursive] Error 1

    It would be greatly appreciated if anyone could help me solve the problem, or tell me if it is not possible to do what I'm trying to do...

    Last edit: Bleh 2013-09-13
  • Holger Vogt

    Holger Vogt - 2013-09-13


    before doing ngspice, 'make' generates ngmakeidx and then uses it to generate an index file ngspice.idx for an outdated help. If you cross-compile, then the resulting executable ngmakeidx cannot run on your actual machine, only on the target host, which does not help here.

    As a remedy, try the following:
    edit ngspice/src/ and blank out lines 1573 and 1574 by #, and rerun ../configure.

    If you are using ./ before ../configure, then you have to edit, and blank out lines 288, 289, the new correct is then generated.

    If you want to use ngspice.idx, you can generate it by standard ngspice on your actual machine and (hopefully) use it on android.


  • Bleh

    Bleh - 2013-09-20


    thanks for your quick response. I have done what you suggested and following the removal of some more lines referring to ngspice.idx/ngmakeidx in the Makefile and editing some of the code in src/main.c (to do with tmpfile()), I finally got it working! It might be worth mentioning that no rooting of your android device is required!

    I have attached the result for anyone who wants to give it a try. The tar contains a readme with instructions and an installation script that should (hopefully) do all that is needed besides installing the needed apps from the google play store. I got ngspice working with the following additional apps from the google play store: terminal-emulator, octave, droidplot and terminal-ide. I also included the octave_space scripts and a ghostscript binary obtained from The result is that plots can be shown on a GUI and/or written to file. I find that terminal-ide provides the best "working experience", and have configured the install script as such.

    Concerning the issue with tmpfile(): I simply could not get it to work, I think it may have something to do with writing permissions but can't be sure. I was also unable to get smktemp() to work. My temporary and very sluggish solution is to do a system call to "mktemp" and use the generated file. This solution still has the issue of removing the tempfile after ngspice closes, so I added another few lines to check each time on startup for any tempfiles in ~/tmp/ conforming to a specific template (~/tmp/spXXXXXX) and removing them. The implication is that on the first run you might get a strange error message, but after that it should be quiet. Another implication is that only one instance of ngspice should be running at any one time...

    I hope someone finds this useful, and please let me know if you have any questions/suggestions!

    • Samir Sabri

      Samir Sabri - 2013-10-25

      Hello Bleh,

      I tried to search for your email to contact you, but I couldn't find it, I need to contact you to discuss a project please if you don't mind ..


  • Bleh

    Bleh - 2013-09-20
    Last edit: Bleh 2013-09-20

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks