Thursday, July 28, 2011

Compiling Nvidia driver for Debian Squeeze 64bit.

Update (2) : It seems that the display driver fails to load with
dlopen: /usr/lib/xorg/modules/extensions// wrong ELF class: ELFCLASS64
dlopen: /usr/lib/xorg/modules/drivers// wrong ELF class: ELFCLASS64
After some googling, I found that the my system was installed with 32bit userland libraries (blame it on the DVD that came with my linux magazine), even though I have a amd64bit kernel.

So I re-installed the machine with the amd64 netinstall official CD downloaded from Debian, installed all necessary packages (list is given below), and re-run the installer again. Of-course, before running the installer, I have switched off GDM3 and added the black-list-configuration.

cat /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
# generated by nvidia-installer
blacklist nouveau
options nouveau modeset=0
As expected every thing now compiles normally (appart from the CC error, which can be corrected by setting CC env variable to /usr/bin/gcc-4.3, but  I didn't do that), all libraries and drivers were installed correctly and my Xorg works great, no error in /var/log/Xorg.0.log

All my posts regarding Nvidia driver is now invalid. Learned a good lesson also, read, read, read the documentation, specially the Nvidia's.

Update (1) : no need for all the below mentioned changes, set the CC environment variable with "-m64"  and re-run the installer directly.
# export CC="/usr/bin/gcc-4.3 -m64"
# ./
Finally I was able to compile the latest version of Nvidia 64bit driver (NVIDIA-Linux-x86_64-275.21) for my Debian Squeeze 64bit. I was getting errors like

error: # error acpi_walk_namespace() conftest failed!
error: # error pci_dma_mapping_error() conftest failed!
In file included from /tmp/selfgz13934/NVIDIA-Linux-x86_64-275.21/kernel/nv.c:13:
error: #error "NV_PCI_DMA_MAPPING_ERROR() undefined!"
error: #error "NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT value unrecognized!"

later I found out that the kernel/ is failing to compile acpi_walk_namespace and acpi_walk_namespace and thus was unable to create object file configtest$$.o. 

So I tried an easy way by modifying the file. First I extracted the driver file using the command 

# ./ -x

This will create a folder named NVIDIA-Linux-x86_64-275.21 in the current folder. Change directory to ./NVIDIA-Linux-x86_64-275.21/kernel and modify the file. Below is the diff output for the same.

index 5b10bb1..eb5d192 100755
--- a/kernel/
+++ b/kernel/
@@ -955,7 +955,7 @@ compile_test() {
             $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
             rm -f conftest$$.c

-            if [ -f conftest$$.o ]; then
+            if [ ! -f conftest$$.o ]; then
                 rm -f conftest$$.o
                 echo "#define NV_ACPI_WALK_NAMESPACE_PRESENT" >> conftest.h
                 echo "#define NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT 6" >> conftest.h
@@ -1105,7 +1105,7 @@ compile_test() {
             $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
             rm -f conftest$$.c

-            if [ -f conftest$$.o ]; then
+            if [ ! -f conftest$$.o ]; then
                 echo "#define NV_PCI_DMA_MAPPING_ERROR_PRESENT" >> conftest.h
                 echo "#define NV_PCI_DMA_MAPPING_ERROR_ARGUMENT_COUNT 2" >> conftest.h
                 rm -f conftest$$.o

The idea is very simple, just added an ' ! ' to the " if " condition, where checks if the file configtest$$.o exists or not. Also please not that on Debian Squeeze the NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT takes only 6 arguments not 7. 

rerun ./nvidia-installer from the root folder where you extracted the Nvidia driver files.

Hope this would solve issues with Nvidia driver for some one.


  1. Programing has never been my cup of tea. Yet this what very informative and valuable. Thank you for sharing. If possible keep us posted, about articles like this.

  2. Debian is my favorite OS of all times, and in my opinion only this operation system perfectly fits for work in IT sphere! But recently I faced one problem - after buying a new videocard I couldt find any drivers on it. And then my brother recommended me this service that provides only the best NVidia Drivers Download for every user!