user6655110
user6655110

Reputation:

I'm trying to make a system call in Ubuntu 12.04.1. I'm running into an error compiling my hello.c file

I'm trying to make a system call in Ubuntu 12.04.1. I'm getting an error compiling my hello.c file:

#include <linux/kernel.h>
asmlinkage long sys_hello(void) {
    printk("hello world\n");
    return 0;
}

It shows the error:

error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘long’ asmlinkage long sys_hello(void)

Upvotes: 1

Views: 285

Answers (3)

Manish Kumar
Manish Kumar

Reputation: 558

All the system calls must be compiled into the kernel. You need to do this within the kernel build system.you cannot use it outside the kernel or shared object.

Upvotes: 0

user149341
user149341

Reputation:

I'm trying to make a system call in Ubuntu 12.04.1.

Assuming you mean you're trying to create a system call: kernel modules cannot add system calls. All system calls must be compiled into the kernel.

Upvotes: 0

Florian Weimer
Florian Weimer

Reputation: 33717

I assume you are trying to build a kernel module. You need to do this within the kernel build system. You cannot compile it as a regular application or shared object. The easiest way probably is to patch the module into the Ubuntu kernel tree and build it using these instructions.

Upvotes: 0

Related Questions