Error compiling ToF sensor drivers on Linux - VL53L4CX
I am trying to compile the drivers for the ToF sensor: VL53L4CX for an embedded Linux application. I am running Ubuntu 22.04. When I try to make the drivers I get the following error:
CONFIG_STMVL53LX=m make -C /lib/modules/`uname -r`/build M=$PWD
make[1]: Entering directory '/usr/src/linux-headers-6.5.0-15-generic'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
You are using: gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
CC [M] /home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.o
/home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.c:567:19: error: initialization of ‘int (*)(struct i2c_client *)’ from incompatible pointer type ‘int (*)(struct i2c_client *, const struct i2c_device_id *)’ [-Werror=incompatible-pointer-types]
567 | .probe = stmvl53lx_probe,
| ^~~~~~~~~~~~~~~
/home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.c:567:19: note: (near initialization for ‘stmvl53lx_driver.<anonymous>.probe’)
/home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.c:568:19: error: initialization of ‘void (*)(struct i2c_client *)’ from incompatible pointer type ‘int (*)(struct i2c_client *)’ [-Werror=incompatible-pointer-types]
568 | .remove = stmvl53lx_remove,
| ^~~~~~~~~~~~~~~~
/home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.c:568:19: note: (near initialization for ‘stmvl53lx_driver.remove’)
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:251: /home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.5.0-15-generic/Makefile:2037: /home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx] Error 2
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.5.0-15-generic'
make: *** [Makefile:8: default] Error 2
It seems that I am using a very similar but slightly different compiler version, but I wouldn't think that it should matter as its the same major version. I am getting a type error within the driver code.
Does anyone know how I can remedy this? I can't seem to find this x86_64-linux-gnu-gcc-12 version to try it with.
Thanks for your help
