- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am programming a CY8C5488AXI psoc. The program built successfully in the past. Now (after a few months), when I build it, I get the following error ( using PSoC Creator v4.4. with toolchain ARM GCC 5.4-2016-q2-update):
C:\ELENTECH Projects\Distiller Control\PSoC\Distiller_Control\Distiller_Control_Proto.cydsn/proj_support.c:2176: undefined reference to `roundf'
collect2.exe: error: ld returned 1 exit status
The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.
--------------- Build Failed: 12/22/2021 10:17:52 ---------------
This error refers to the following statement that calls roundf() (supposedly in math library):
temp = roundf(DAC_ONEDEGREE_COUNT * ((float) degrees));
The program has the #include <math.h> statement, which should declare the roundf() function.
Any suggestions/comments?
Thanks!
Solved! Go to Solution.
- Labels:
-
PSoC Creator & Designer Software
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @guag_1662311,
Could you please try the below:
In Creator go to Project -> Build Settings -> Linker -> General
Add "m" (without the quotes) into Additional Libraries. This will add the math library "Libm.a" to your project.
Please let us know if this solves your problem.
Thanks,
Krupashankar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
guag,
Suggestion: You can download earlier versions of Creator.
I've never used rountf() but I have used other functions in math lib with math.h.
It appears the math.h has no reference to the roundf() in the file. This can be verified by looking at the math.h file.
I've added the roundf() function to a project. Here's what I noticed:
I find the reference in math.h however it is ghosted
extern float roundf _PARAMS((float));
The ghosting is because the pre-compiler variable __ISO_C_VISIBLE is not defined. See the conditional compile below.
#if __ISO_C_VISIBLE >= 1999
I don't know the "official" way of turning this conditional compile variable on. However I when I compiled, I got no complaints about the function being undefined.
I'm using Creator 4.3 with great success.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In PSoC Creator, you can define preprocessor defines here:
Go to Project > Build Settings > ARM GCC Y.X > Compiler > General > Preprocessor Definitions. You can add:
__ISO_C_VISIBLE=XYZ
In your case, XYZ should be a number equal or higher than 1999.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I added the command to the preprocessor definitions as shown below. Still getting the undefined reference to `roundf' build error. Where is math.h in the toolchain directory? It was installed with the default settings.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @guag_1662311,
Could you please try the below:
In Creator go to Project -> Build Settings -> Linker -> General
Add "m" (without the quotes) into Additional Libraries. This will add the math library "Libm.a" to your project.
Please let us know if this solves your problem.
Thanks,
Krupashankar