I'm quiet new to module coding and I need to run some calculation that uses the GMP library in a module.
So the first question: is it generally possible to run GMP in kernel? For testing, I wrote this Module:
#include <linux/init.h>
#include <linux/module.h>
#include <gmp.h>
int hallo_init(void)
{
mpz_t testFactor;
mpz_init( testFactor, NULL);
mpz_set_str(testFactor, "19", 10);
int length = (int) mpz_sizeinbase(testFactor,2);
printk(KERN_ALERT "That is testFactor: %x \n",length);
return 0;
}
void hallo_exit(void)
{
printk(KERN_ALERT "exit \n");
}
module_init(hallo_init);
module_exit(hallo_exit);
I run it with the following command:
sudo make -C /lib/modules/$(uname -r)/build M=$PWD modules -lgmp
The makefile consists of
obj-m := gmpFile.o
I also tried to use the -lgmp in the makefile:
obj-m := halloGmp.o
ccflags-y := -lgmp
But I always get a Fatal error: gmp.h: No such file or directory
Any suggestions? Would be thankful for help!