kernel build dierectory not found

Hello all,
This is my first question although i have been using Opensuse for a while now. I am trying to understand how to build a kernel module and i am following video tutorial for the same.
in the video this guy uses Ubuntu …and to build the module he says make -C /lib/modules/$(uname -r)/build M=$PWD modules ] but when i try the same it says build directory not found . i have been breaking my head since .
this is what it says
make: *** /lib/modules/4.12.14-lp151.28.48-default/build: No such file or directory. Stop.

i would like to know where to find the a kernel build files …if a different path or so.
or if i am to download it from somewhere and how to configure the same as to build the module.

thanks.

Please post the complete!!! input line, the compete output and the complete next line.
Example (shows the Graphics Hardware and used and avaible driver):

ich@linux64:~> /sbin/lspci -nnk | grep -EiA3 'vga|3d|display'
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] [10de:1c03] (rev a1)
        Subsystem: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] [10de:1c03]
        Kernel driver in use: nvidia
        Kernel modules: nouveau, nvidia_drm, nvidia
ich@linux64:~> 

Complete input line:

ich@linux64:~> /sbin/lspci -nnk | grep -EiA3 'vga|3d|display'

Output:

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] [10de:1c03] (rev a1)
        Subsystem: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] [10de:1c03]
        Kernel driver in use: nvidia
        Kernel modules: nouveau, nvidia_drm, nvidia

Next line:

ich@linux64:~> 

And please use Code-Tags.

To build external modules on openSUSE you need to install kernel-default-devel package.

Please use tags [noparse]

[/noparse] when ptoviding computer output.

SORRY! my bad …

ill uses the code tags hence forth.

so i wrote a simple char device driver (incomplete) and i tried to compile the code using

input :


h@linux-fn75:~/Documents/device-driver-tut/trial-1> make -C /lib/modules/$(uname -r)/build M=$PWD modules

and this was the response

output:


make: *** /usr/src/4.12.14-lp151.28.48-default/build: No such file or directory. 
 Stop.

when i checked the directories i couldn’t find the build folder , but here is what i found in that path .


h@linux-fn75:/lib/modules/4.12.14-lp151.28.48-default> ls
kernel             modules.builtin.bin  modules.fips     modules.symbols.bin
modules.alias      modules.dep          modules.order    vdso
modules.alias.bin  modules.dep.bin      modules.softdep
modules.builtin    modules.devname      modules.symbols



i did install kernel-default-devel packages

input code:


h@linux-fn75:~/Documents/device-driver-tut/trial-1> sudo zypper in kernel-default-devel

output:

[sudo] password for root: Loading repository data...
Reading installed packages...
Resolving package dependencies...


The following 4 NEW packages are going to be installed:
  kernel-default-devel kernel-devel kernel-macros libelf-devel


4 new packages to install.
Overall download size: 33.4 MiB. Already cached: 0 B. After the operation,
additional 63.8 MiB will be used.
Continue? [y/n/...? shows all options] (y): y
Retrieving package kernel-macros-4.12.14-lp151.28.52.1.noarch
                                           (1/4),   6.0 MiB ( 21.0 KiB unpacked)
Retrieving: kernel-macros-4.12.14-lp151.28.52.1.noarch.rpm .[done (755.2 KiB/s)]
Retrieving package libelf-devel-0.168-lp151.4.3.1.x86_64
                                           (2/4), 727.0 KiB (  2.1 MiB unpacked)
Retrieving: libelf-devel-0.168-lp151.4.3.1.x86_64.rpm ......[done (241.5 KiB/s)]
Retrieving package kernel-devel-4.12.14-lp151.28.52.1.noarch
                                           (3/4),  17.8 MiB ( 57.4 MiB unpacked)
Retrieving: kernel-devel-4.12.14-lp151.28.52.1.noarch.rpm ..[done (841.0 KiB/s)]
Retrieving package kernel-default-devel-4.12.14-lp151.28.52.1.x86_64
                                           (4/4),   8.9 MiB (  4.3 MiB unpacked)
Retrieving: kernel-default-devel-4.12.14-lp151.28.52.1.x86_[done (1016.3 KiB/s)]
Checking for file conflicts: .............................................[done]
Warning: Checking for file conflicts requires not installed packages to be downloaded in advance in order to access their file lists. See option '--download-in-advance' in the zypper manual page for details.


The following package had to be excluded from file conflicts check because it is not yet downloaded:
  kernel-default


(1/4) Installing: kernel-macros-4.12.14-lp151.28.52.1.noarch .............[done]
(2/4) Installing: libelf-devel-0.168-lp151.4.3.1.x86_64 ..................[done]
(3/4) Installing: kernel-devel-4.12.14-lp151.28.52.1.noarch ..............[done]
(4/4) Installing: kernel-default-devel-4.12.14-lp151.28.52.1.x86_64 ......[done]



i am following this tutorial where he says in the following path << /lib/modules/$(uname -r)/build >> has a makefile which apparently has all the information about the processor and which compiler to use etc. . but ofcourse he uses Ubuntu . any comment on that also helps :slight_smile:

i found another similar thread

https://forums.opensuse.org/showthread.php/524518-Kernel-Headers-for-Opensuse-42-2-Linux-kernel-4-4-57-18-3-1

but again it says to install kernel-default-devel which i did.

P.S - Thank you for the quick response .

kernel-default-devel must be the same version as kernel-devel. By default the latest version is installed. Either build your module for current kernel or install kernel-default-devel version 4.12.14-lp151.28.48. By default the latest version is installed.

Update your System and reboot.

Thank you so much …:slight_smile:
it worked …