Arm Community
Site
Search
User
Site
Search
User
Groups
Arm Research
DesignStart
Education Hub
Graphics and Gaming
High Performance Computing
Innovation
Multimedia
Open Source Software and Platforms
Physical
Processors
Security
System
Software Tools
TrustZone for Armv8-M
中文社区
Blog
Announcements
Artificial Intelligence
Automotive
Healthcare
HPC
Infrastructure
Innovation
Internet of Things
Machine Learning
Mobile
Smart Homes
Wearables
Forums
All developer forums
IP Product forums
Tool & Software forums
Pelion IoT Platform
Support
Open a support case
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community Help
More
Cancel
Developer Community
Tools and Software
Software Tools
Jump...
Cancel
Software Tools
Keil forum
Problem with GCC and string.h and stdlib
Tools, Software and IDEs blog
Forums
Videos & Files
Help
Jump...
Cancel
New
State
Not Answered
Replies
2 replies
Subscribers
2 subscribers
Views
6709 views
Users
0 members are here
Arm Compiler
Keil
GCC
uVision
GNU
Related
Problem with GCC and string.h and stdlib
Offline
nehal nehal
over 7 years ago
Note: This was originally posted on 8th October 2008 at
http://forums.arm.com
Hi everyone,
i have following trouble with keil arm gnu compiler. i have recently moved to gnu and now i am having hard time to set it up.
description of problem: i am using real view arm compiler uvison3.5. i am using gnu chain tool set for aduc7021 (analog device) arm. when i tried to compile my code it gives me following errors:
"error: undefined reference to 'memcpy'
error: undefined reference to '_divsi3'
error: undefined reference to 'strcat'
error: undefined reference to 'memset'""
i tried to include string.h and stdlib.h in my project but it didn't help.
so if anybody can explain what is going on then it would be a great help.
thanks
nehal
Parents
0
Offline
Jacob Bramley
over 7 years ago
Note: This was originally posted on 9th October 2008 at
http://forums.arm.com
It appears that you haven't linked the standard libraries correctly.
It's important to realize the difference between the compiler and the linker.
The
compiler
takes your source files and translates them into object files. Typically, these objects will include the assembly source and a number of symbols which the linker will use. The compiler doesn't know or care where resources (such as
memcpy
or
__divsi3
) exist, provided that they're declared in a header somewhere. Your C headers just tell the compiler "you can use this function, and here's its prototype".
The
linker
takes your object files and glues them all together. This generally entails resolving symbols to addresses and fitting your code into a memory structure. However, the headers you specified to the compiler mean nothing here; they just tell the compiler which symbols to add to the object file so the linker knows what to look for. The linker will search through all objects and any linked libraries for the symbols, and it will complain if it can't find them. That seems to be what's happening in your case.
IDEs such as uVision often hide this relationship from the user, but it is important to understand.
Having said that, the functions you listed are part of the standard C library, and as such they should be linked by default. You generally have to explicitly tell the linker to exclude the standard libraries, though it is common to exclude them for embedded targets and so your IDE may be configured to do that by default.
I'm not familiar with uVision so I can't really help you with finding the correct options...
Cancel
Up
0
Down
Reply
Accept answer
Cancel
Reply
0
Offline
Jacob Bramley
over 7 years ago
Note: This was originally posted on 9th October 2008 at
http://forums.arm.com
It appears that you haven't linked the standard libraries correctly.
It's important to realize the difference between the compiler and the linker.
The
compiler
takes your source files and translates them into object files. Typically, these objects will include the assembly source and a number of symbols which the linker will use. The compiler doesn't know or care where resources (such as
memcpy
or
__divsi3
) exist, provided that they're declared in a header somewhere. Your C headers just tell the compiler "you can use this function, and here's its prototype".
The
linker
takes your object files and glues them all together. This generally entails resolving symbols to addresses and fitting your code into a memory structure. However, the headers you specified to the compiler mean nothing here; they just tell the compiler which symbols to add to the object file so the linker knows what to look for. The linker will search through all objects and any linked libraries for the symbols, and it will complain if it can't find them. That seems to be what's happening in your case.
IDEs such as uVision often hide this relationship from the user, but it is important to understand.
Having said that, the functions you listed are part of the standard C library, and as such they should be linked by default. You generally have to explicitly tell the linker to exclude the standard libraries, though it is common to exclude them for embedded targets and so your IDE may be configured to do that by default.
I'm not familiar with uVision so I can't really help you with finding the correct options...
Cancel
Up
0
Down
Reply
Accept answer
Cancel
Children
No data
More questions in this forum
By title
By date
By reply count
By view count
By most asked
By votes
By quality
Descending
Ascending
All recent questions
Unread questions
Questions you've participated in
Questions you've asked
Unanswered questions
Answered questions
Questions with suggested answers
Questions with no replies
Not Answered
hi does anyone know how to turn on exceptions for c++ in keil uvision? i got a coursework due tommorow and i want to see if my code works with exceptions turned on urgent help will be apppreciated
0
177
views
1
reply
Latest
10 days ago
by
R.Kopsch
Not Answered
QCA400x undefined symbol Driver_SPI
0
wifi
Keil
175
views
1
reply
Latest
10 days ago
by
Andy Neil
Not Answered
Keil uVision STM32 H755 correct options for targets
0
105
views
0
replies
Started
11 days ago
by
Ton_
Answered
MQTTClient.h vs stm32f7xx.h
0
815
views
6
replies
Latest
12 days ago
by
Andy Neil
Not Answered
getting error as error C141: syntax error near 'void', expected '__asm' at linevoid lcdcmd(unsigned char val)
0
522
views
5
replies
Latest
12 days ago
by
Andy Neil
<
>
View all questions in Keil forum