1

I have a Linux system running from a kernel image I compiled off the sources from a Git repository. When I am running Linux, I would like to install a driver for some NI instrument. When I try running the installer, it tells me that it cannot detect the Linux kernel sources, and that those are required for the driver.

I have the sources available, so that's not an issue, but I don't know how to make those available to this installer. Are kernel sources traditionally kept in some specific directory, or is there some environment variable that tells where they are?

Also, what constitutes the kernel sources? There is a large number of files in the Git repo I pulled, but many of those files seem to be build or make files for different platforms. What specifically is needed for a kernel module?

4
  • As far as I know there isn't a precompiled driver, I got a tar package for my device, and there was only one option to install, so I'm assuming its necessary to build it with the sources.
    – Amari
    Commented Nov 1, 2017 at 13:12
  • You compiled the kernel, so the source files will not be in a 'default' directory unless you copy them there, but the sources do exist in the git repo you cloned. How are you 'installing' the driver (rpm, deb, script)? Is the driver pre-compiled or are you compiling it? Does the driver module match the kernel version (2.6, 3.x, 4.x)? Can you compile the driver at the same time you compile the kernel?
    – jc__
    Commented Nov 1, 2017 at 14:01
  • @jc__ I am installing the driver using a bash script provided in the driver package I downloaded. I assume the driver is not pre-compiled, else it wouldn't need the sources, right? I believe the driver version I have should work, because I found an old forum thread on NI's forum asking about which driver to use with Ubuntu of my version and was pointed to the one I am using.
    – Amari
    Commented Nov 1, 2017 at 14:35
  • If the driver is being compiled you may need to pass the location of the kernel sources to the build process. Is the driver being built with a make file? What was your reason to compile the kernel vs using a distro install? Is this a 32, 64 bit pc or a cross compile for embedded like ARM?
    – jc__
    Commented Nov 1, 2017 at 14:57

2 Answers 2

1

The module build system expects to find the configured kernel source (by configured, I mean with the .config file used to build the kernel) in /lib/modules/$(uname -r)/build. The simplest approach for you is to create a symlink there pointing at your source directory:

sudo ln -s /path/to/kernel/source /lib/modules/$(uname -r)/build
0

Traditionally, kernel sources were in /usr/src/linux . If your distro has a linux sources package, that is where they would probably go. Try package linux-source on debian-based distros, or kernel-devel on RedHat-based distros.

3
  • So I tried copying the git repository to my linux system and put it in /usr/src/linux-VERSION, but when I tried the install again, it still complained that the sources were not found. Is there anything else I need to set to tell the OS that the sources are there?
    – Amari
    Commented Nov 1, 2017 at 13:45
  • Its the driver you need to 'tell'. Can you edit the install script of the driver?
    – jc__
    Commented Nov 1, 2017 at 14:03
  • 1
    Try ln -s /usr/src/linux-VERSION /usr/src/linux; traditionally kernel sources are in /usr/src/linux not /usr/src/linux-VERSION. Commented Nov 1, 2017 at 14:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .