I'm trying to get r8168-dkms to install on a fresh install of 20.04.1, to my new AMD Ryzen pc, but it's getting a compile error.

uname -a output: 
Linux terry-pc 5.8.0-50-generic #56~20.04.1-Ubuntu SMP Mon Apr 12 21:46:35 UTC 
2021 x86_64 x86_64 x86_64 GNU/Linux

dpkg -i r8168-dkms_8.048.00-1_all.deb


DKMS make.log for r8168-8.048.00 for kernel 5.8.0-50-generic (x86_64) Fri 23 Apr 2021 12:09:08 PM PDT make: Entering directory '/usr/src/linux-headers-5.8.0-50-generic' AR /var/lib/dkms/r8168/8.048.00/build/built-in.a CC [M] /var/lib/dkms/r8168/8.048.00/build/r8168_n.o CC [M] /var/lib/dkms/r8168/8.048.00/build/r8168_asf.o CC [M] /var/lib/dkms/r8168/8.048.00/build/rtl_eeprom.o CC [M] /var/lib/dkms/r8168/8.048.00/build/rtltool.o /var/lib/dkms/r8168/8.048.00/build/r8168_n.c: In function ‘rtl8168_proc_init’: /var/lib/dkms/r8168/8.048.00/build/r8168_n.c:1670:47: error: passing argument 4 of ‘proc_create_data’ from incompatible pointer type [-Werror=incompatible-pointer-types] 1670 | &rtl8168_proc_fops, f->show)) { | ^~~~~~~~~~~~~~~~~~ | | | const struct file_operations * In file included from /var/lib/dkms/r8168/8.048.00/build/r8168_n.c:92: ./include/linux/proc_fs.h:103:31: note: expected ‘const struct proc_ops *’ but argument is of type ‘const struct file_operations *’ 103 | extern struct proc_dir_entry *proc_create_data(const char , umode_t, | ^~~~~~~~~~~~~~~~ /var/lib/dkms/r8168/8.048.00/build/r8168_n.c: At top level: /var/lib/dkms/r8168/8.048.00/build/r8168_n.c:25825:31: error: initialization of ‘void ()(struct net_device , unsigned int)’ from incompatible pointer type ‘void ()(struct net_device *)’ [-Werror=incompatible-pointer-types] 25825 | .ndo_tx_timeout = rtl8168_tx_timeout, | ^~~~~~~~~~~~~~~~~~ /var/lib/dkms/r8168/8.048.00/build/r8168_n.c:25825:31: note: (near initialization for ‘rtl8168_netdev_ops.ndo_tx_timeout’) cc1: some warnings being treated as errors make[1]: *** [scripts/Makefile.build:284: /var/lib/dkms/r8168/8.048.00/build/r8168_n.o] Error 1 make: *** [Makefile:1783: /var/lib/dkms/r8168/8.048.00/build] Error 2 make: Leaving directory '/usr/src/linux-headers-5.8.0-50-generic'

Has anyone hit this, and fixed it?

  • If you still have some internet on that system try installing the build-essential package and try again. sudo apt install build-essential
    – Terrance
    Apr 24, 2021 at 2:52
  • That package was already installed, as build-essential/focal-updates, now 12.8ubuntu1.1 amd64 [installed,automatic]. No internet, just using usb-drives to move files over from an internet-connected laptop; a cheap usb/wifi gadget should arrive tomorrow, as a stopgap until I can get this working.
    – Terry
    Apr 24, 2021 at 6:05
  • Try the driver from realtek.com/en/component/zoo/category/… titled GBE Ethernet LINUX driver r8168 for kernel up to 5.6. It is not a DKMS driver, but it is possible to convert it over to one after it is installed.
    – Terrance
    Apr 25, 2021 at 2:51
  • Thanks. Your suggestion is what I wound up doing. I gave up on the dkms version, but since I had downloaded and moved over (via usb drive) the various packages needed to compile a device driver, I went back the to version I had downloaded from the Realtek site, and was pleasantly surprised that It compiled, and worked! Problem solved, but I hope this chip/driver doesn't require a lot of care & feeding on each kernel increment.
    – Terry
    Apr 26, 2021 at 6:37
  • There is a way to make that driver go DKMS so that you don't have to worry about it with kernel updates. I'll write up something below to help.
    – Terrance
    Apr 26, 2021 at 13:49

1 Answer 1


06 Dec 2021: Updating answer for version 8.049.02

17 Feb 2023: One of the newest drivers from Realtek versions 8.050.03 will not work with the newest LTS Kernel of 5.19.0-32-generic. Version 8.051.02 will work fine. However, I do recommend the use of the r8168-dkms package and that will install the 8.049.02 driver that works fine with the 5.15 and the 5.19 Kernels.

Make sure to change your version of the driver and kernel as needed.

Now that you have the r8168-8.049.02 driver installed from Realtek it unfortunately does not contain the DKMS info for the driver to be taken over into new kernel updates.

To resolve this, we are going to create a dkms.conf file for this driver.

Create a directory for the new driver:

sudo mkdir /usr/src/r8168-8.049.02

Then go to the folder with the r8168 driver (or download and extract the driver from here) that was extracted and copy all of its contents to the newly created directory:

sudo cp * /usr/src/r8168-8.049.02/

or the src/ directory contents if it exists (this should also contain a Makefile in that directory as well).

sudo cp src/* /usr/src/r8168-8.049.02/

Then create a new dkms.conf file in the new source directory:

sudo nano /usr/src/r8168-8.049.02/dkms.conf

and add the following lines to the file:


Then save and close the file.

Now we're going to add the dkms driver to the kernel:

sudo dkms add -m r8168 -v 8.049.02
sudo dkms build -m r8168 -v 8.049.02
sudo dkms install -m r8168 -v 8.049.02

Then check the driver with dkms status. If you see something about the driver that is built being different than the currently installed driver, run the following line to correct it:

sudo dkms uninstall -m r8168 -v 8.049.02 -k 5.8.0-50-generic && sudo dkms install -m r8168 -v 8.049.02 -k 5.8.0-50-generic --force

From now on with new kernel updates and upgrades the driver should now install automatically into the new kernel.

Hope this helps!

  • @mchid Let me add that, it would be the src/ directory if it exists. The one I downloaded put the files in the main directory.
    – Terrance
    Feb 2, 2022 at 23:10
  • Yes, src is in the main directory. I apologize for the confusion, I was saying that you don't transfer the main directory but rather the contents of the main directory. I'm sure people would quickly figure that out if they make the mistake. Also, I'm almost 100% sure that DKMS does need the Makefile. I think you should probably revert the edit. Mybad.
    – mchid
    Feb 2, 2022 at 23:16
  • However, I didn't really think about that second make file. You're right, I think the main Makefile simply references the other one. IDK. Still though, I think the original answer was good.
    – mchid
    Feb 2, 2022 at 23:22
  • @mchid It is all good! :) It gave me a chance to correct my folders to directories. :)
    – Terrance
    Feb 2, 2022 at 23:26

You must log in to answer this question.

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