使用Microchip C30编译器为Openpicus编译时链接错误

时间:2014-06-17 06:47:43

标签: c compiler-errors linker-errors dynamic-linking microchip

我正在编译一个包含大量外部库的项目。该项目有一些警告,但我相信它不应该妨碍创建.hex文件。因此,当我编译项目时,我得到一个链接错误列表。

Compiling C:\liblwm2m\Libs\ExternalLib\heap.s

*                     Total program memory used (bytes):        0x28ef3  (167667) 64%

*                        Total data memory used (bytes):         0x360a  (13834) 84%
x_object_device.o(.text+0x688):C:\liblwm2m\Libs\ExternalLib\object_device.c: undefined reference to `strdup'
x_object_device.o(.text+0x68a):C:\liblwm2m\Libs\ExternalLib\object_device.c: undefined reference to `strdup'
x_object_device.o(.text+0x6b6):C:\liblwm2m\Libs\ExternalLib\object_device.c: undefined reference to `strdup'
x_object_device.o(.text+0x6b8):C:\liblwm2m\Libs\ExternalLib\object_device.c: undefined reference to `strdup'
x_object_device.o(.text+0x6e4):C:\liblwm2m\Libs\ExternalLib\object_device.c: undefined reference to `strdup'
x_object_device.o(.text+0x6e6):C:\liblwm2m\Libs\ExternalLib\object_device.c: more undefined references to `strdup' follow
x_observe.o(.text+0x3c2):C:\liblwm2m\Libs\ExternalLib\observe.c: undefined reference to `object_read'
x_observe.o(.text+0x3c4):C:\liblwm2m\Libs\ExternalLib\observe.c: undefined reference to `object_read'
x_liblwm2m.o(.text+0x86):C:\liblwm2m\Libs\ExternalLib\liblwm2m.c: undefined reference to `strdup'
x_liblwm2m.o(.text+0x88):C:\liblwm2m\Libs\ExternalLib\liblwm2m.c: undefined reference to `strdup'
x_management.o(.text+0x48):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_read'
x_management.o(.text+0x4a):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_read'
x_management.o(.text+0xa6):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_create'
x_management.o(.text+0xa8):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_create'
x_management.o(.text+0x154):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_isInstanceNew'
x_management.o(.text+0x156):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_isInstanceNew'
x_management.o(.text+0x16e):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_create'
x_management.o(.text+0x170):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_create'
x_management.o(.text+0x188):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_write'
x_management.o(.text+0x18a):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_write'
x_management.o(.text+0x1a2):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_execute'
x_management.o(.text+0x1a4):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_execute'
x_management.o(.text+0x1da):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_write'
x_management.o(.text+0x1dc):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_write'
x_management.o(.text+0x208):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_delete'
x_management.o(.text+0x20a):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_delete'
x_registration.o(.text+0x8c):C:\liblwm2m\Libs\ExternalLib\registration.c: undefined reference to `prv_getRegisterPayload'
x_registration.o(.text+0x8e):C:\liblwm2m\Libs\ExternalLib\registration.c: undefined reference to `prv_getRegisterPayload'
  C:\Program Files\Microchip\MPLAB C30\bin\bin/pic30-coff-bin2hex.exe: a.cof could not be opened.
The system cannot find the file specified.
---------------------------------- COMPILING ERROR ---------------------------------------

这里strdup函数是openpicus支持的,我也声明了它。让我感到惊讶的是程序正确编译但会引发链接错误。有什么想法吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

这些是代码中的错误 对strdup' undefined reference to object_read'的未定义引用 对object_create' undefined reference to object_isInstanceNew'的未定义引用 对object_create' undefined reference to object_write'的未定义引用 对object_execute' undefined reference to object_write'的未定义引用 对object_delete' undefined reference to prv_getRegisterPayload'的未定义引用 附:这些不是警告!!

错误表示没有定义函数" strdup",...," prv_getRegisterPayload"。链接器找不到对这些例程的引用,并以链接时错误终止。没有链接意味着没有生成hex文件,这是所有工具链的标准行为。

检查您附加到项目的库。添加具有这些例程的引用/定义的库,然后代码应该构建正常。

产生类似错误的伪代码如下:

extern void parabola ();
int main(void)
{
    parabola ();   // ERROR here "undefined reference to `parabola'
}

- 抛物线函数的定义在哪里?不应该

void parabola ()
{}
int main(void)
{
    parabola ();   // Builds like magic
}