Installing ngspice on ubuntu?

Totally new to linux. Installed it on an old laptop and am playing with it, and I thought I would try to install ngspice on it for circuit modeling. I see that downloading and installing a program is different than windows, and when I looked online for answers, it’s like I was transported to another universe where compiling a kernel is part of the fun. I found a reasonable looking pdf…

I don’t understand step 1. It seems that I am supposed to enter this script somewhere, and I am clueless about where that might be. This makes “compiling” look like dropping a mega-deus after a long night of binging on taco bell.
Somebody please help me educate myself.

1 Like

Let me see what I can do to help.

Do you have a download link for this software?

  1. in this step, we’re going to create a new directory and CD into it. It can really be anywhere, but best practice would be to do it in /opt or /tmp. Let’s change the directions slightly and install it in /tmp. (the third command is just taking ownership of the directory so we don’t have to use sudo for everything)
sudo mkdir /tmp/ng-spice
cd /tmp/ng-spice
sudo chown $(whoami): .
  1. download the source tarball from this link:
wget -O ngspice-27.tar.gz
  1. Extract the archive:
tar -xf ngspice-27.tar.gz
  1. CD into the directory that’s been created:
cd ngspice-27
  1. dependencies can be tricky. The documentation you linked mentions a few. Let’s start with build-essential and work from there.
sudo apt install build-essential libgtk2.0-dev libxaw7-dev libxaw7-header

Note: autoconf, libtool and automake are included in the build-essential metapackage. A metapackage is just a package that doesn’t have any software itself, but has dependencies to make installing things that are commonly used together easier.

  1. build and install the tools:
./configure --enable-xgraph
make -j$(nproc)
sudo make install

Note: $(nproc) is a bash trick that will output the number of cores on your system. We use it there to tell make to use all cores to speed up compilation.

aclocal | A workaround for a lack of flexibility in the next command

./ | generates ./configure

./configure --enable-xgraph | configures the build preferences so that the package is properly set up for your environment

make -j$(nproc) | compiles the source code. -j indicates the number of “jobs” or parallel workers that will compile your code.

sudo make install | installs the compiled software on your system.

Disclaimer: I tested this on Ubuntu 18.04 (beta). I don’t have a non-prerelease version available, so I can’t guarantee that the package names will be the same. If you have issues, let me know and I’d be happy to help you work through it.

I’m also not 100% sure that the tarball I got is the right one. If you have a link to the proper tarball, I can validate these steps from that one, just to make sure we’re all on the same page.


Thank you. You are truly deserving of the name sgtawesomesauce. But I am afraid even these step by step perfectly clear directions are still of no help to me. I have no idea where to input the text. When I said “beginner”, I should have mentioned it is worse than that. I have absolutely no idea at all about linux, how to enter commands, etc. Is there some kind of console command thing? Like when I give myself 10,000 daedric arrows in skyrim?
Edit- oh, and that sourceforge link was indeed the same place I was trying to download the program from.

Ah, I assumed you had a bit of experience with the terminal.

To be clear, there’s a terminal emulator that will give you a command prompt, similar to windows. That’s where you want to run the commands from.

If you haven’t seen this video, it might be of use to you.

1 Like

there is also #ult which will go over the basic commands in a easy to digest way :smiley:


Thank you! I will check these out first thing in the morning.


Ah, sorry. I totally forgot about your hard work. It’s very good content. I’d recommend checking it out, @Radio_God


Again, thank you both. I have been going over this for awhile this morning. Linux is basically a foreign language, and when spoken correctly, becomes a functional operating system. I guess this will take a few years to figure out, but I guess I have to start sometime, might as well be today. I had dual booted a notebook laptop to recover pictures when windows xp self-destructed, and I am re-installing ubuntu 16.04 lte as I type this so I can get rid of windows entirely. I will set it up and try installing ng spice and post my failure or sucess.

You’ll get there. I think you’ll have this sorted with only a few more hours of work.

I think years is a bit much. Much like any other field, the more you work with it, the more you learn and maintenence tasks become easier and nearly muscle memory eventually.

I’d equate it with learning to touch type, or learning a new keyboard layout.

I followed step 1 and it did create a directory for tmp/ng-spice. On step 2, the wget came back saying ‘0’ was an invalid option. I tried it with zero and a capital “O”. When I did it with a capital “O”, it looks like it did download something, and it says ‘ng-spice-27.tar.gz’ saved.
However, when I tried step 3 to extract, it says it’s not in gzip format, then Child returned status 1, and error is not recoverable: exiting now.
I don’t know what this means, and as a total retard, I can only think that this means I have to call in an amber alert for my operating system?

hmm… So, first thing’s first. that means that the file that it expected to download didn’t actually download properly. It may have been corrupted or it may have downloaded a HTML file for some reason.

if you do this:

ls -alh

in the directory, there should be a column for file sizes. Can you tell me the size of ng-spice-27.tar.gz?

That will give you more information. It should be about 27MB if memory serves. (I’m away from the machine I tested this on)

It says 212K total, and the file size for spice itself was 202k. Yeah, that don’t sound right for a file size.

Hmm, that’s not right. You could try this: Download the file from sourceforge in your browser, then use the cp command to copy it from your Downloads folder to /tmp/ng-spice.

cp takes two (or more) arguments. Source and Destination. It will look like this in the terminal:

cp ~/Downloads/ng-spice-27.tar.gz /tmp/ng-spice

Ok, I’ll get on that right away. Thank you.


So I have ngspice in my downloads folder, I’m not sure how I copy it into the tmp directory. If I put in the command line you posted, will it do it on it’s own?
Ok, I did enter it and it says no such file exists. But it is in my downloads folder and named exactly as you have it written down.

Are you running the command as root or your user? If it’s root, you may need to specify an absolute path.

cp /home/<youruserhere>/Downloads/ng-spice-27.tar.gz /tmp/ng-spice

Haaahaa, I have no idea. I just hit control/alt and F1 and started at step 1. I’ll punch in that text and see what happens.

Your user should show on the prompt. <username>@<hostname> $ or something similar to that.

It says cp: cannot stat, and no such file or directory. The directory looks like it’s here, because every line on the command console has a /tmp/ng-spice$ on it.
Do I need to extract the download first?

The destination is there, it can’t find the source file.

cd to ~/Downloads and see if you can see the file.

Also, once you’re there, use pwd to get the full path of the location you’re in.