LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to use c functions in linux kernel mode (https://www.linuxquestions.org/questions/linux-general-1/how-to-use-c-functions-in-linux-kernel-mode-203822/)

pwangee 07-11-2004 04:48 PM

how to use c functions in linux kernel mode
 
Hi,

I used some c functions in my program such as pow, log, puts. When I try to make the program work as a module, it gives some errors.

% /usr/local/sbin/click-install wp-wire-dem.click
/usr/local/lib/click.o: unresolved symbol pow
/usr/local/lib/click.o: unresolved symbol log
/usr/local/lib/click.o: unresolved symbol puts
/usr/local/lib/click.o: unresolved symbol printf
click-install: ‘/sbin/insmod /usr/local/lib/click.o’ failed

Can I use the c functions in the kernel program? If can, how to use it? Thanks

Peng
:confused:

kevinalm 07-11-2004 05:14 PM

I don't know anything about kernel programing myself, but I do know there is a Kernel Programming Howto. Check the Linux Documentation Project website.

SciYro 07-11-2004 06:29 PM

as far as i know, you cant use glibc in kernel mode, or any lib in the kernel, you have to use what the kernel provides

kevinalm 07-12-2004 04:30 PM

Quote:

Originally posted by SciYro
as far as i know, you cant use glibc in kernel mode, or any lib in the kernel, you have to use what the kernel provides
Maybe you could link statically to the libs? Just a thought.

jspenguin 07-12-2004 09:48 PM

Quote:

Originally posted by kevinalm
Maybe you could link statically to the libs? Just a thought.
Probably won't work. The C library expects to be run in usermode, and it could seriously confuse it if you run it in kernel mode. If you just need a small function like pow, you can hunt through the C library source and just copy the function into your code. As long as your module is GPL or LGPL there should be no licensing issues.

kevinalm 07-12-2004 10:21 PM

I thought that was what static linking did, copy the relavent code from the library into your executable. I could be wrong though, I frequently am. ;)
Regards.


All times are GMT -5. The time now is 10:15 AM.