Return-Path: Received: from bay0-omc3-s38.bay0.hotmail.com (bay0-omc3-s38.bay0.hotmail.com [65.54.246.238]) by ozlabs.org (Postfix) with ESMTP id F1FC867B71 for ; Wed, 20 Sep 2006 23:48:31 +1000 (EST) Message-ID: From: "Ming Liu" To: linuxppc-embedded@ozlabs.org Subject: how an application program utilizes the driver. Date: Wed, 20 Sep 2006 13:48:25 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=gb2312; format=flowed List-Id: Linux on Embedded PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Dear all, Maybe this question sounds stupid for most software engineers. But I really have much confusion on this topic. So I have to ask for explanation. My situation is: I want to write a driver for my custom device.(In the driver there are some functions defined to read or write my device.) Then in my application program, I use these defined functions to operate my hardware device. I think this is a normal process to operate the hardware with driver+app, right? My driver is defined in drv_hello.c. I have compiled it into a module drv_hello.ko and it could be insmoded or rmmoded correctly. It looks like: //drv_hello.c #include #include #include MODULE_LICENSE("Dual BSD/GPL"); void show_hello(){ printk("hello.\n"); } static int hello_init(void){ printk(KERN_ALERT "module starts.\n"); return 0; } static void hello_exit(void){ printk(KERN_ALERT "module exits.\n"); } module_init(hello_init); module_exit(hello_exit); EXPORT_SYMBOL(show_hello); In my application program app_hello.c, I use the function show_hello to achieve the simple task: print "hello" on the console. Here is my app program: //app_hello.c extern void show_hello(); int main(int argc, char** argv) { show_hello(); return 0; } Then, here comes my problem: I don't know how to compile my application program and then it could dynamically refer to the function show_hello() defined in the memory area of the driver module. How can I tell the compiler and linker that the app program is expected to be linked with the driver module dynamically? If possible, please give me a detailed explanation. Waiting for your suggestion. Thanks for your help. Regards Ming _________________________________________________________________ 与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn