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

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

问题描述

我对_sbrk有问题.在编译的链接阶段,我使用下面的comand链接我的对象,并获得对_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.a和libgcc.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/.

我一直在互联网上搜索_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. Soo 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.

Ziga.

我解决了这个问题,并将在此处发布解决方案,以便我回馈一些东西. 社区.函数_sbrk位于用于ARM的NXP CDL软件包中.包裹 可以在此处下载(链接适用于所有尚不知道的人): http://www.lpclinux.com/Downloads/WebHome 在子文件夹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: http://www.lpclinux.com/Downloads/WebHome 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.

最美好的祝愿和成功.

推荐答案

这有帮助:

-mcpu = cortex-m4 -mthumb -specs = nano.specs -specs = nosys.specs -mfpu = fpv4-sp-d16 -mfloat-abi = hard

-mcpu=cortex-m4 -mthumb -specs=nano.specs -specs=nosys.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard

重要的开关似乎"为:

-specs = nano.specs -specs = nosys.specs

-specs=nano.specs -specs=nosys.specs

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

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