Compile Fails

Latest response

Hello, I am using rhel 7.2 and i am trying to make/compile the makefile and this what i get.
" make -C module
make[1]: Entering directory /home/luckyodirile/Downloads/contec/iolib/module'
make -C /usr/src/kernels/3.10.0-327.el7.x86_64 SUBDIRS=
pwd` V=1 modules
make: Entering an unknown directory
make: *** /usr/src/kernels/3.10.0-327.el7.x86_64: No such file or directory. Stop.
make: Leaving an unknown directory
make[1]: *** [iolib.ko] Error 2 "

Here is what the makefiles look like:

DEST_DIR := $(shell uname -r)
KERNEL_SRC := $(shell if [ -d /usr/src/linux ]; then echo /usr/src/linux; else echo /usr/src/kernels/$(DEST_DIR); fi)

all: iolib.ko

iolib.ko: iolib_module.c iolib_user_irq.c
make -C $(KERNEL_SRC) SUBDIRS=pwd V=1 modules

clean :
make -C $(KERNEL_SRC) SUBDIRS=pwd V=1 clean

obj-m := iolib.o

iolib-objs := iolib_module.o iolib_user_irq.o

clean-files := .o *.ko *.mod.[co] *~ ..cmd

install:

Any help and comment would be highly appreciated

Responses

The error message says it cannot find the source kernel directory. Is /usr/src/kernels empty? Then it is because you haven't downloaded/installed the kernel source code.

How to populate the directory /usr/src/kernels/ with kernel source?

yum install kernel-devel

One word of caution is that the version of kernel-devel must match that of the running kernel. yum finds and installs the current version. If you are running an earlier version of kernel, you need to specify the version when installing the kernel-devel package.

Ok thanx for the answers, after going through a couple of steps in registration and subscriptions i got to install the gcc compiler and installed kernel -devel package everything went well.

But when i run the samples i get an error about architectures. Below is the error, I read somewhere that i need to put '-m32' tag in the compiler line. Hope someone can clarify this.

gcc iodebug.o -o iodebug -liolib /bin/ld: i386 architecture of input file `iodebug.o' is incompatible with i386:x86-64 output collect2: error: ld returned 1 exit status make: *** [all] Error 1

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.