title: Unknown symbol when loading a kernel module but the symbol is exported in kernel
body: <p>I am writing a kernel module to manipute GPIOs. In initialization, the moduel needs to change the muplex of GPIOs. </p>
  
  <p>[tld.c]</p>
  
  <pre><code>#include &lt;mach-omap2/mux.h&gt;
  </code></pre>
  
  <p>.
  .
  .</p>
  
  <pre><code>int open_gpio(void){
      int result;
      result = gpio_request_array(leds_gpios, ARRAY_SIZE(leds_gpios));
      if(result != 0) {
          printk("tld: cannot request gpio ports\n");
      }
  
      result = gpio_direction_output(LED_LE_PIN, 0);
  
      omap_mux_set_gpio(OMAP_MUX_MODE7, LED_LE_PIN);
      if(result != 0) {
          printk("tld: cannot change GPIO muplex.\n");
          gpio_free_array(leds_gpios, ARRAY_SIZE(leds_gpios));
      }
      return result;
  } 
  
  static int tld_init(void) { 
          .
          .
      /* open gpio ports */
      result = open_gpio();
          .
          .
  }
      .
  module_init(tld_init);
      .
  </code></pre>
  
  <p>Function omap_mux_set_gpio() is declared in Kernel_Source/arch/arm/mach-omap2/mux.h. So I include it in the source file. </p>
  
  <p>The Makefile is also customized.</p>
  
  <p>[Makefile]</p>
  
  <pre><code>CONFIG_CROSS_COMPILE =
  CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
  
  ARCH        ?= arm
  
  SOURCE_DIR ?= /home/me/kerner_source
  
  AS      = $(CROSS_COMPILE)as
  LD      = $(CROSS_COMPILE)ld
  CC      = $(CROSS_COMPILE)gcc
  CPP     = $(CC) -E
  AR      = $(CROSS_COMPILE)ar
  NM      = $(CROSS_COMPILE)nm
  STRIP       = $(CROSS_COMPILE)strip
  OBJCOPY     = $(CROSS_COMPILE)objcopy
  OBJDUMP     = $(CROSS_COMPILE)objdump
  
  obj-m += tld.o
  ccflags-y += -I$(SOURCE_DIR)/arch/arm
  
  
  all:
  make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(SOURCE_DIR) M=$(PWD) modules
  
  clean:
  rm *.o *.ko *.mod.*
  </code></pre>
  
  <p>I can get it compiled but there is warning:</p>
  
  <p><strong>WARNING: "omap_mux_set_gpio" [/home/me/projects/tld.ko] undefined!</strong></p>
  
  <p>When i run insmod, there is error in dmesg:</p>
  
  <p><strong>tld: Unknown symbol omap_mux_set_gpio (err 0)</strong></p>
  
  <p>I have checked the kernel symbol list by runing:</p>
  
  <p>cat /proc/kallsyms | grep omap_mux_set_gpio</p>
  
  <p>An function called omap_mux_set_gpio does exist. </p>
  
  <p>I think the way I include the header file probably is causing the problem. The mux.h belongs to the kernel itself but i treat it like an external one.</p>
  
  <p>What is right way to do it? </p>
  
  <p>Thank you very much.</p>