Help with installing a linux driver, kernel headers not configured

I’m trying to install the 96.43.xx series driver in my Lubuntu 14.04.1 desktop. My kernel is 3.13.0-39-generic (i686). When I start the installation I get an error saying pre-install script failed. I click “continue anyway”. It tries to build the driver and reports error

ERROR: The kernel header file
‘/lib/modules/3.13.0-39-generic/build/include/linux/version.h’ does not
exist. The most likely reason for this is that the kernel source files
in ‘/lib/modules/3.13.0-39-generic/build’ have not been configured.

I have also done sudo apt-get install linux-headers. What should I do?

Here’s the complete log:

nvidia-installer log file ‘/var/log/nvidia-installer.log’
creation time: Fri Nov 21 20:18:55 2014
installer version: 1.0.7

PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

option status:
license pre-accepted : false
update : false
force update : false
expert : false
uninstall : false
driver info : false
precompiled interfaces : true
no ncurses color : false
query latest version : false
OpenGL header files : true
no questions : false
silent : false
no recursion : false
no backup : false
kernel module only : false
sanity : false
add this kernel : false
no runlevel check : false
no network : false
no ABI note : false
no RPMs : false
no kernel module : false
force SELinux : default
no X server check : false
no cc version check : false
run distro scripts : true
no nouveau check : false
run nvidia-xconfig : false
sigwinch work around : true
force tls : (not specified)
X install prefix : (not specified)
X library install path : (not specified)
X module install path : (not specified)
OpenGL install prefix : (not specified)
OpenGL install libdir : (not specified)
utility install prefix : (not specified)
utility install libdir : (not specified)
installer prefix : (not specified)
doc install prefix : (not specified)
kernel name : (not specified)
kernel include path : (not specified)
kernel source path : (not specified)
kernel output path : (not specified)
kernel install path : (not specified)
precompiled kernel interfaces path : (not specified)
precompiled kernel interfaces url : (not specified)
proc mount point : /proc
ui : (not specified)
tmpdir : /tmp
ftp mirror : ftp://download.nvidia.com
RPM file list : (not specified)
selinux chcon type : (not specified)

Using: nvidia-installer ncurses user interface
-> License accepted.
-> Installing NVIDIA driver version 96.43.23.
-> Running distribution scripts
executing: ‘/usr/lib/nvidia/pre-install’…
-> done.
-> The distribution-provided pre-install script failed! Continue installation
anyway? (Answer: Yes)
-> Performing CC sanity check with CC=“cc”.
-> Performing CC version check with CC=“cc”.
ERROR: The kernel header file
‘/lib/modules/3.13.0-39-generic/build/include/linux/version.h’ does not
exist. The most likely reason for this is that the kernel source files
in ‘/lib/modules/3.13.0-39-generic/build’ have not been configured.
ERROR: Installation has failed. Please see the file
‘/var/log/nvidia-installer.log’ for details. You may find suggestions
on fixing installation problems in the README available on the Linux
driver download page at www.nvidia.com.