LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   make error - No such file or directory (https://www.linuxquestions.org/questions/programming-9/make-error-no-such-file-or-directory-599548/)

srinivas_mn 11-14-2007 06:59 AM

make error - No such file or directory
 
Hi,

I am trying to compile a project in SUSE 10 and encountering error on running make.

I have installed the kernel source code. My program hook.c includes the header 'sys/syscall.h'. The

The Makefile contents are as below:

*************
UNAME=2.6.16.46-0.12-smp
IFLAGS=-I /lib/modules/$(UNAME)/build/include -I /usr/include

obj-m := mako.o
mako-objs := hash/bitwisehash.o hash/scmp.o hash/htbl.o hash/cq.o module.o protect.o hook.o syscall_linker.o vsyscall.o gdt.oEXTRA_CFLAGS += -I /lib/modules/$(UNAME)/build/include -I /usr/include

all:
make -C /lib/modules/$(UNAME)/build M=$(PWD) modules

syscall_linker.o:
gcc -O2 -Wall -c $(IFLAGS) -o syscall_linker.o syscall_linker.s
vsyscall.o:
gcc -O2 -Wall -c $(IFLAGS) -o vsyscall.o vsyscall.s

clean:
make -C /lib/modules/$(UNAME)/build M=$(PWD) clean


***********

On running make, it gives the following error messages:

....../home/srinivas/XForce/Dev/linux_26/hook.c:14:25: error: sys/syscall.h: No such file or directory
In file included from /home/srinivas/XForce/Dev/linux_26/hook.c:17:
/home/srinivas/XForce/Dev/linux_26/fn.h:8: warning: function declaration isn’t a prototype
/home/srinivas/XForce/Dev/linux_26/fn.h:9: warning: function declaration isn’t a prototype ........



I verified the file is available in path '/usr/include/sys/syscall.h'. I have included the path in makefile.

Please advice what could be wrong

Thanks,

Mara 11-14-2007 03:41 PM

From your makefile it looks that EXTRA_CFLAGS is not passed to the compilation (only IFLAGS is used). You may try something like
IFLAGS += $(EXTRA_CFLAGS)

Mara 11-14-2007 03:42 PM

As a sidenote...you shouldn't use files in /usr/include for your kernel things. Rather go with the version from that specific kernel version. With newer kernel, there might be changes causing conflicts and strange errors.

osor 11-14-2007 05:57 PM

Quote:

Originally Posted by srinivas_mn (Post 2958538)
My program hook.c includes the header 'sys/syscall.h'.

Why? This is a userspace header. From kernelspace, just #include <asm/unistd.h>. The only thing you don’t get is the alias syscall numbers (e.g., SYS_open in addition to __NR_open). Since you are not in userspace, just use the __NR_* version.

srinivas_mn 11-16-2007 10:38 PM

Hi, Thank you all for your replies.

I have tried including the header located in the following location:
/usr/src/linux-2.6.16.46-0.12/arch/um/include/syscall.h
but this did not help either:

I am not introducing new system calls, but using the existing system calls. Do I still need to use the <asm/unistd.h>

I would like to point, the same code is compiling fine in SUSE 9.

Please can you elaborate how this has to be handled on newer kernels (SUSE 10)?

Thanks

Mara 11-17-2007 03:41 PM

The question is what do you want from the syscalls. You can't run simple open() or so.

osor 11-17-2007 04:08 PM

Quote:

Originally Posted by srinivas_mn (Post 2961658)
I have tried including the header located in the following location:
/usr/src/linux-2.6.16.46-0.12/arch/um/include/syscall.h
but this did not help either:

I am not introducing new system calls, but using the existing system calls. Do I still need to use the <asm/unistd.h>

You’re not making any sense. First, what do you want to get from the included file?

For example, suppose that in a userspace program you have #include <sys/syscall.h>. What does this mean? Well, on my system, it looks like this. So what do you get? From the first included file (asm/unistd.h), you get all the system call numbers defined as preprocessor macros (e.g., “#define __NR_write 4”). From the second included file (bits/syscall.h), you get the legacy form of the same things (e.g., “#define SYS_write __NR_write”). But neither sys/syscall.h nor bits/syscall.h is available from kernelspace. So if you want the equivalent of #include <sys/syscall.h> in kernelspace, you’ll have to resign yourself to using asm/unistd.h and NOT using the SYS_foo macro forms.

If that’s not what you’re looking for, then you haven’t made yourself clear. The only reason you would include /usr/src/linux/arch/um/include/syscall.h is if you are writing special code for the usermode linux pseudoarch. That is a private header available only to code within the tree.

Suppose you want the function prototypes for the kernelside system calls. For example,
Code:

asmlinkage ssize_t sys_write(unsigned int fd, const char __user *buf, size_t count);
Then, you have to include the relevant file that declares them. On 2.6 kernels, this is linux/syscalls.h. But as Mara stated before, you can’t just use syscalls from the kernel as if you were in userspace. For a better explanation of the limitations and methods for doing this, read here.


All times are GMT -5. The time now is 12:26 PM.