I'm trying to build module.
But here's some issues.
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
WARNING: Symbol version dump ./Module.symvers
is missing; modules will have no dependencies and modversions.`
And here's my makefile
ifeq ($(KERNELRELEASE),)
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY: modules modules_install clean
else
# called from kernel build system: just declare what our modules are
obj-m := hello.o hellop.o seq.o jit.o jiq.o sleepy.o complete.o \
silly.o faulty.o kdatasize.o kdataalign.o
endif
I tried building like this:
export KERNELDIR=/path/to/extern/linux/source
make
How can I solve this problem?
Okay, so I would try to re-install the Linux-headers.
prerequisites
terminal access(bash presumably)
root privileges
(or a user who can do 'sudo')
First, we try to re install (using APT) the linux-headers package but adding your specific version. Which is determined by the following command: $(uname -r)
and to do it all in one line:
sudo apt install --reinstall linux-headers-$(uname -r)
Then, as we talk about the kernel, and making changes to it (quite major too, a reinstall of a kernel that is) we want to reboot as soon as the APT command is done:
sudo reboot
If you get it couldn't find any package, (or similar) (from apt)
try apt update and re-try the above.
Logs
Do check /var/log/kern.log for any messages that is,
cat /var/log/kern.log
I solved this problem with the following commands:
From your built sources take the most recent .config file with kernel configuration. Copy it to kernel-source directory (e.g.: build/tmp/work-shared/lmm-corei7/kernel-source).
Run make prepare.
I spent hours on the same problem, having the same error message : ERROR: Kernel configuration is invalid...
The solution was so simple...
I was running sudo make and this created the errors.
After having done what is suggested by William Martens (reinstall the headers and reboot), I logged as root, and the module built perfectly.
To be sure, I did a second test with an admin account and sudo make, and it failed again. So I am sure this is the reason. I noticed also that after a fail, I have to reinstall the headers otherwise, even in root, it fails.
This happened on a Debian 11 with kernel 5.10.0-16-amd64.
Related
I want to cross-compile a Raspbian kernel that I downloaded from www.github.com/raspberrypi/linux on my host machine (Linux Mint Cinnamon 64bit).
I was executing the following steps:
Create folders leading to path home/sven/Develop/Raspbian
Cloning repo from link above leading to home/sven/Develop/Raspbian/linux containing the source code
Cleaning kernel by running make mrproper
Creating .config from my running raspberry pi 3B+ by running sudo scp pi#.../proc/config.gz . and then unzipping it with gunzip -c config.gz > .config
Running ARCH=arm CROSS_COMPILE=${CCPREFIX} make oldconfig
grep -v DEBUG_INFO < .config > newconfig
mv newconfig .config
ARCH=arm CROSS_COMPILE=${CCPREFIX} make oldconfig
ARCH=arm CROSS_COMPILE=${CCPREFIX} make
However, the last step is always failing (Error 2 or Error 1). I have also tried the following commands that have also been unsuccessful:
make ARCH=arm CROSS_COMPILE=${CCPREFIX}
make ARCH=arm CROSS_COMPILE=
If I type in only make oldconfig or only make, it works but then I have no idea if it's really compiled for ARM or with the gcc compiler...
My .profile file looks like this at the end:
PATH=/opt/toolchain/.../gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/:$PATH
export CCPREFIX=arm-linux-gnueabihf-
I have already tried the PATH without the "/bin/" at the end, also not working.
Does anyone have an idea???
I'm using libtool (version 2.4.6) for creating a simple shared library
under GNU/Linux.
In my specific case, portability is not as important as simplicity: I don't
want to use the whole Autotools suite, nor CMake. I just want a simple
Makefile which can compile a shared library and install it properly.
I've got a couple of variables definitions, which follow the
conventions of GNU Make
prefix ?= /usr/local
exec_prefix ?= $(prefix)
libdir ?= $(exec_prefix)/lib
I want to support an install target, and I believe it should be roughly
like this:
LIBTOOL_LIB := libxyz.la
install: target = $(abspath $(DESTDIR))
install: all
mkdir -p $(target)/$(libdir)
libtool --mode=install install $(LIBTOOL_LIB) $(target)/$(libdir)
libtool --mode=finish $(target)/$(libdir)
If I run make install DESTDIR=./test I get the following message:
mkdir -p /yadayada/src/test//usr/local/lib
libtool --mode=install install libtrullallero.la /yadayada/src/test//usr/local/lib
libtool: install: install .libs/libtrullallero.so.0.0.0 /yadayada/src.so.0.0.0
libtool: install: (cd /yadayada/src.so.0; }; })
libtool: install: (cd /yadayada/src.so; }; })
libtool: install: install .libs/libtrullallero.lai /yadayada/src.la
libtool: install: install .libs/libtrullallero.a /yadayada/src.a
libtool: install: chmod 644 /yadayada/src.a
libtool: install: ranlib /yadayada/src.a
libtool: warning: remember to run 'libtool --finish /usr/local/lib'
libtool --mode=finish /yadayada/src/test//usr/local/lib
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /yadayada/src/test//usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
/yadayada/src/test//usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
I guess I deserve this notification, since I'm installing outside the
regular library path. This is by the way the same message I would get in a
Autotools-based project, should I set a --prefix in some arbitrary path at
./configure.
There are however some weird things:
If I run make install as root (within a container, of course), without
defining DESTDIR, I get the same kind of message. This does not feel
correct: this time I did not deserve it.
With or without DESTDIR, a call to ldconfig makes in my opinion no
sense at this point. And when I'm not running it as root, it should be
also ineffective, yet the program succeeds.
Lurking in the libtool documentation, I've found a
reference to the -inst-prefix-dir option,
which should allow me to have a DESTDIR-like behaviour.
Perhaps this is what I do wrong. However it behaves weirdly!
For starters, it seems to work only if specified at the end of the
--mode=install line. In fact, if I do this:
install: target = $(abspath $(DESTDIR))
install: all
mkdir -p $(target)/$(libdir)
libtool --mode=install install -inst-prefix-dir $(target) $(LIBTOOL_LIB) $(target)/$(libdir)
libtool --mode=finish $(target)/$(libdir)
…I clearly get a messy command line:
libtool: install: install -inst-prefix-dir /yadayada/libtrullallero/test/usr/local/lib/-inst-prefix-dir
install: invalid option -- 'i'
If I move -inst-prefix-dir to the end of the line, I just get another
wrong call to install:
mkdir -p /yadayada/src/libtrullallero/test//usr/local/lib
libtool --mode=install install libtrullallero.la /yadayada/src/libtrullallero/test
libtool: install: install .libs/libtrullallero.so.0.0.0 /yadayada/src/libtrullallero/test/libtrullallero.so.0.0.0
libtool: install: (cd /yadayada/src/libtrullallero/test && { ln -s -f libtrullallero.so.0.0.0 libtrullallero.so.0 || { rm -f libtrullallero.so.0 && ln -s libtrullallero.so.0.0.0 libtrullallero.so.0; }; })
libtool: install: (cd /yadayada/src/libtrullallero/test && { ln -s -f libtrullallero.so.0.0.0 libtrullallero.so || { rm -f libtrullallero.so && ln -s libtrullallero.so.0.0.0 libtrullallero.so; }; })
libtool: install: install .libs/libtrullallero.lai /yadayada/src/libtrullallero/test/libtrullallero.la
libtool: install: install /yadayada/src/libtrullallero/test/lib
install: omitting directory '/yadayada/src/libtrullallero/test//usr/local/lib'
Makefile:22: recipe for target 'install' failed
make: *** [install] Error 1
I must be doing something wrong, but I cannot spot it. Any hint?
I am new to kernel module development. So I started with simple hello world kernel module
I am using "The Linux Kernel Module Programming Guide" book for the reference (it is addressing to kernel 2.6).
I installed kernel-devel and kenel headers with yum. I am using fedora 17.
I found that a symlink
/lib/modules/3.3.4-5.fc17.x86_64/build -> /usr/src/kernels/3.3.4-5.fc17.x86_64
Now, I have one hello-1.c (the simple kernel module and a Makefile in my working directory)
The Makefile is:
obj-m += hello-1.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
when in $make i get error:
make -C /lib/modules/3.3.4-5.fc17.x86_64/build M=/root/kerneldev modules
make: *** /lib/modules/3.3.4-5.fc17.x86_64/build: No such file or directory. Stop.
make: *** [all] Error 2
I make same program on Centos-5.x it run successfully , because the /lib/modules/3.3.4-5.fc17.x86_64/build was containing the actual module (not a symlink).
What should be problem ? why such difference?
The message
make: *** /lib/modules/3.3.4-5.fc17.x86_64/build: No such file or directory. Stop.
Is telling you that the directory path after the *** does not exist. Make issues this exact format of error when the -C directory doesn't exist. Other non-existent path situations will result in more words. For example, if the /lib/modules/3.3.4-5.fc17.x86_64/build directory does exist but it contains no makefile, make will specifically say no makefile found.
So the other answers are giving you ideas to help you create that directory with its proper contents.
And this answer is intended to also help people who have the above form of error message and for whom installing 'kernel-devel' will not help, by explaining the message itself.
I have few doubts like, where your issuing the make command.
Your current directory seems to be
M=/root/kerneldev
whether your hello-1.c is in /root/kerneldev folder.
try "yum install kernel-devel"(for kernel headers)
I am trying to compile a hello world module given over here
I have followed the following step.
Downloaded Linux kernel 2.6.35-rc5
extracted to directory /general/source/linux
Complied the entire kernel.
created a dir test in the linux folder.
Created and complied a hello world module as mentioned there.
when I run the insmod command, I get this error
insmod: error inserting 'hello.ko': -1 Invalid module format
How do I sort out this error?
Regards,
Ok the mistake that you are making is the kernel version.
First try
uname -r
You would get the kernel version. The downloaded version mostly likely won't be the kernel version of your system.
So change the make file to
ifeq ($(KERNELRELEASE),)
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
.PHONY: build clean
build:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c
else
$(info Building with KERNELRELEASE = ${KERNELRELEASE})
obj-m := hello.o
endif
Make sure the tabs are in the order as mentioned in the above script.
Your kernel module must match the running kernel. If you want to install this specific module, for example, you'd need to also install the kernel that you've built.
Normally, you'd not build the kernel on your own and use a pre-built version that matches your distribution's kernel. Look for a kernel-headers package in your distribution's repository.
I am trying to run 'make' on a module in User Mode Linux to install a simple makefile. Here is my make file:
obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
When I run this in User Mode Linux I get the following error:
make[1]: Entering directory `/lib/modules/2.6.28/build'
make[1]: *** No rule to make target `modules'. Stop.
make[1]: Leaving directory `/lib/modules/2.6.28/build'
make: *** [default] Error 2
The problem is that no files are present under /lib/modules/. There's no directory for 2.6.28 or build. From what I've read, these should be symlinks to /usr/src, but under /usr/src, I don't see any files under that either.
Sources and headers of your UML kernel must be used to compile module for it.
You can compile it either inside UML or just in main system, but you must to use UML's kernel's headers and build scripts
You need to build and install the version of the kernel you are compiling for. Get the source from kernel.org, configure (I think make menuconfig picks the config up from the running kernel), build, and install it. You can do the build in your home directory under regular user, then of course you would need root to install it.
Edit:
Just in case you missed this - here's User Mode Linux HOWTO. It contains specific items for building and installing kernel and modules. Hope this helps.