对 _sbrk 的未定义引用 [英] Undefined reference to _sbrk

查看:55
本文介绍了对 _sbrk 的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 _sbrk 时遇到问题.在编译的链接阶段,我使用下面的命令来链接我的对象,并且我得到了对 _sbrk 的未定义引用.

I am having a problem with _sbrk. In a link phase of compilation i use below comand to link my objects and i get undefined reference to _sbrk.

arm-none-eabi-ld -static -T linkerscript.ld -o exe timer_example.o /home/ziga/projects/cs_lite/arm-none-eabi/lib/libc.a /home/ziga/projects/cs_lite/lib/gcc/arm-none-eabi/4.5.1/libgcc.a

我正在为 arm926ej-s 和 ARM 模式编译,所以我想我选择了正确的 multilib (libc.alibgcc.a) 位于文件夹 home/ziga/projects/cs_lite/arm-none-eabi/lib/ 中.

I am compiling for arm926ej-s and in ARM mode so i think i have chosen the right multilib (libc.a and libgcc.a) which is located in folder home/ziga/projects/cs_lite/arm-none-eabi/lib/.

我一直在 Internet 上搜索 _sbrk 函数,它是某种内存管理调用,不包含在标准 C 库中,因为它依赖于微处理器.那么我必须自己编写 _sbrk 函数吗?我该怎么做?你有 arm926ej-s 的例子吗?写完这个函数后,我打算把它编译成一个对象文件,并将它与其他对象、库链接在一起.

I have been searching internet for _sbrk function and it is some sort of a memory managment call which isnt included in standard C libraries as it is dependant on microprocessor. So do I have to write _sbrk function on my own? How do I do it? Do you have any example for arm926ej-s? After writing this function I intend to compile it into an object file and link it together with other objects, libraries.

推荐答案

我解决了这个问题,并将在此处发布解决方案,以便我回馈社区.函数 _sbrk 位于 ARM 的 NXP CDL 包内.包可供下载(链接适用于所有不知道的人) 这里 在子文件夹 CDL_v005/csps/lpc313x/bsps/ea3131/source 中,您将找到名为 libnosys_gnu.c 的源文件,该文件应添加到项目中并编译为对象文件,然后链接到可执行文件以及其他对象和库.

I solved this problem and will post solution here so i give something back to comunity. The function _sbrk is located inside NXP CDL package for ARM. Package is available for download (link is for all who dont know this already) here in subfolder CDL_v005/csps/lpc313x/bsps/ea3131/source you will find source file named libnosys_gnu.c which should be added to the project and compiled to object file and after that linked to executable file alongside other objects and libraries.

最良好的祝愿和很多成功.

Best wishes and a lot of success.

这篇关于对 _sbrk 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆