Unresolved Symbol (转)

原创 2004年10月17日 11:37:00
How to avoid the unresolved symbols error
If you keep getting an unresolved symbols error when using ALSA modules, the solution is very simple: Clean the kernel's source tree.

Change directory to the kernel source tree. If you want to keep the same config, I advise :

cp .config /tmp (not inside the current directory, it will get erased)
make mrproper
cp /tmp/.config .
make oldconfig
make dep
make bzImage
make modules
make modules_install
- Copy your new kernel image file bzImage to your boot device location as you'd normally do.

Then, recompile ALSA.

I know that this is not directly ALSA related, but it could take place
in the FAQ, as it definitely prevents ALSA from working.
Try this: In the alsa-driver directory,

rm config.cache
./configure [your options]
make clean
make
and then, as root, do:
make install
rmmod -a /_ these make sure no old modules are hanging around in memory
rmmod -a /
Maybe some partially-compiled files are left over from a previous attempt.
Remove all of the ALSA kernel modules before you do "make install". Do a
"find /lib/modules/`uname -r` -name 'snd*.o'" to make sure they're all gone.


On Thu, 8 Mar 2001, Narayana, Venkat A. wrote:

> Hi,
> I am learning to write kernel modules, and while experimenting
> with a simple module, i got
> " hello.o: unresolved symbol printk_Rsmp_1b7d4074" error
> while loading this module via insmod hello.o command.
>
> I noticed that /proc/ksyms contains printk symbol.
>
> What is that i am doing which is not correct?
> Help me out.

As other people have pointed out this has to do with versioning.

The simple answer to the question is that you need to include modversions.h
before the header file for printk if you want the module to load into a kernel with CONFIG_MODVERSIONS turned on.

You could do this in two ways:
  • in each of your c files, at the top (before you #include linux/kernel.h), you could have:

  • or in your makefile, you could have


Now, I'll try and explain how it all works. (Jay, a section on this is definitely needed in the module programming guide ;).

Okay, this can be a bit difficult to explain, but I'll give it a go. I've probably got some of it wrong. Someone will correct me.

(all this assumes CONFIG_MODVERSIONS is turned on)

  • the kernel is compiled with -include /usr/src/linux/modversions.h. What this effectively means is that modversions.h is included at the top of every c file in the kernel.
  • so what does this do? Well, if you have a look at modversions.h, it includes loads of .ver files. Each of these files have loads of lines like (in ksyms.ver)

this winds up having a #define along the line of

#define printk printk_R1b7d4074

  • so what does this do? Well, now everywhere printk is mentioned it gets
replaced by printk_R1b7d4074 by the preprocessor. So when the kernel is compiled
there is no such function as printk, there is only one called printk_R1b7d4074.

  • so if you want to write a module that uses the 'printk' function(sorry, I mean the printk_R1b7d4074 function) you're going to have to include modversions.h before printk is defined.

Another question you might ask is how the .ver files get generated?

  • well the basic command is along the lines of

  • the gcc command puts the c file through the preprocessor with __GENKSYMS__ defined
  • the output of this is passed through to genkyms which generates output like

where the 1b7d4074 depends on the kernel version you supply.

Hi,

I have gone through an alsa compilation which went well, but the loading of the module came back with the following error :


I then went to the FAQ which said that it was because my kernel was incorrectly configured andalso because I had missed out the soundcore code (CONFIG_SOUND=y).

I was surprised because I had just recompiled that kernel, ensuring that I had added the right options.

Apparently -- I noticed this on some kernel mailing lists -- the usage of the kernel modversions facility (CONFIG_MODVERSIONS) is not always correctly taken into account by the fastdep kernel makefiles reconfiguration system.

The result is weird symbol names for some symbols.

error LNK2001: unresolved external symbol "const type_info::`vftable'"

error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@) 1>HNPCI...
  • shejiannan
  • shejiannan
  • 2013年08月06日 16:09
  • 2728

Unresolved Symbol (转)

How to avoid the unresolved symbols errorIf you keep getting an unresolved symbols error when using ...
  • jinnie
  • jinnie
  • 2004年10月17日 11:37
  • 4131

unresolved external symbol __错误解决

在用VC6.0写程序调试时,初学者总是会遇到一些错误,比如,从网上下载的源代码,编译通过了,连接却出错误了。针对这些错误主要是因为MFC类库没有引用所出现的问题。 类似错误提示: ...
  • zyllong
  • zyllong
  • 2014年09月25日 09:26
  • 515

unresolved external symbol __imp___CrtDbgReportW referenced in function

unresolved external symbol __imp___CrtDbgReportW referenced in function "public: class facedata & __...
  • BikeyTang
  • BikeyTang
  • 2014年06月06日 12:31
  • 1312

VS2005 VS05 编译错误 unresolved external symbol __imp__TransparentBlt@44 解决 方法

使用到Transparentblt 函数,编译出错编译错误提示:SHOWTEXT.obj : error LNK2001: unresolved external symbol __imp__Tran...
  • mynameislinduan
  • mynameislinduan
  • 2010年12月21日 00:33
  • 1559

vc++程序编译连接时出现了unresolved external symbol错误

一般在调试时用debug,而在发布时用release.而有些在debug下做的设置,在release下没有设,导致程序无法正常编译。以后一定要注意呀。我的一个vc++程序用了动态链接库(dll),此动...
  • precipitant
  • precipitant
  • 2006年10月19日 16:54
  • 2587

关于VC6.0中 运行错误 unresolved external symbol _WinMain@16的解决

  • 2015年05月31日 16:16
  • 58KB
  • 下载

SM2算法第十六篇:解决 unresolved external symbol 无法解析 _send@16

(1) vc网络编程中遇到一个编译问题,原来是少了WSOCK32.LIB。 在 project-->settings-->Link-->Object/Library modules 中加入库...
  • qq_30866297
  • qq_30866297
  • 2016年05月20日 00:29
  • 1087

【编译问题】error LNK2001: unresolved external symbol __iob

【问题描述】 某ocx项目(vs2010)调用某静态lib(vs2008下编译的),报error LNK2001: unresolved external symbol __iob 【解决...
  • shineych
  • shineych
  • 2014年01月15日 10:01
  • 2285

unresolved external symbol __endthreadex错误解决

在用VC6.0写程序调试时,初学者总是会遇到一些错误,针对如下错误主要是因为MFC类库没有引用所出现的问题。 错误现象: nafxcwd.lib(thrdcore.obj) : error LNK...
  • vbskj
  • vbskj
  • 2011年11月07日 14:33
  • 648
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Unresolved Symbol (转)
举报原因:
原因补充:

(最多只允许输入30个字)