DSP

绝对悲剧の连接错误(调了一个星期)

2019-07-13 14:41发布

在visual DSP++5.0 中要将USB接口部分封装成Library File (.dlb),但是在主程序中调用库函数总是出现连接错误 [Error li1021] the following symbols could not be resoved 但是未解决的符号所在的头文件都已经被包含到Library Project相应的文件中。 无奈之下,开始思考 一、C和CPP的编译链接方式不同。 比方说函数:void Fun();经C编译后会变成_Fun(), 但CPP并非如此。 把未解决符号所在的头文件加了extern “C” 标记。 #ifndef __cplusplus extern "C" { #endif ..... #ifndef __cplusplus } #endif 依然没用。 二、求助google叔叔 错误代码g了一下,历尽千辛万苦找到了http://ez.analog.com/thread/1298;jsessionid=F24B7DE761024B3960A5A50A9AAC5404 问题终于找到了,给我很大启发的是下面一段话: The reason you are receiving this error is that you have not included the ".../Blackfin/lib/src/drivers/sensor/micron/adi_mt9v022.c" file in your project, even though you may already have included the corresponding header file (adi_mt9v022h).
As detailed in the 'Device Driver Overview' section of the Device Drivers and System Services Manual, applications which use off-chip device drivers need to include both the header file (e.g. "adi_mt9v022.h"), and the device driver source file (e.g. "adi_mt9v022.c"). Once both of these files have been added to your project, it should link without error. 大意是即使包含了头文件,但是函数具体实现在C文件中,因此还需要把C文件也包含进来。 因为.dlb是由源文件生成的.doj所组成,.doj就相当于C中的.obj文件。但是当应用程序调用.dlb中函数的时候,就需要对.dlb中的.doj文件进行连接,但是doj中函数无法进行动态链接,所以就报连接错误了。。。 经过上面一番挣扎,问题终于解决,将不能连接的函数所在的C文件包含进来,编译OK,调用OK。USB畅通无阻。。。心情亦如此。