Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » undefined reference to strcmp
undefined reference to strcmp [message #813762] Mon, 05 March 2012 12:16 Go to next message
Eclipse UserFriend
Hi everybody,

maybe it is a stupid question, but I am stuck on it.
I am using an arm-none-eabi toolchain. when I use a function such as strcmp(..); I get un error: undefined reference to strcmp in this case, as you may see from the attached file.

this function is defined in the string.h header file, which I have included in my workspace.index.php/fa/7405/0/

Please advice!

Regards,

Pauindex.php/fa/7405/0/
Re: undefined reference to strcmp [message #813840 is a reply to message #813762] Mon, 05 March 2012 14:26 Go to previous messageGo to next message
Eclipse UserFriend
I don't see a #include for string.h in your source file. You have to tell the compiler what header files your program includes before it will look for them.
Re: undefined reference to strcmp [message #814274 is a reply to message #813840] Tue, 06 March 2012 03:51 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for your prompt reply!
Maybe I did not explain myself. That header file was already in the project although you did not see it, it is defined in the "include" zone, such as:
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_conf.h"
#include "stm32f10x.h" /* S'hi defineix el tipus de MCU utilitzat*/
#include "stm32f10x_it.h"
#include "string.h"


In the path & Symbols (properties of the project) I have add the path where those header files are in order to use their functions. (Please have a look to the file attached)

Maybe the problem is in my makefile (file attached), where I have not defined where to find that header file. I found this makefile in the web and I adapted to my project.

As I said before any idea will be welcome.

Pau
  • Attachment: path_Symbols.jpg
    (Size: 152.75KB, Downloaded 453 times)
  • Attachment: Makefile
    (Size: 4.15KB, Downloaded 457 times)
Re: undefined reference to strcmp [message #814480 is a reply to message #814274] Tue, 06 March 2012 08:58 Go to previous messageGo to next message
Eclipse UserFriend
You must use angle brackets for system includes.
#include <string.h>

Re: undefined reference to strcmp [message #815150 is a reply to message #814480] Wed, 07 March 2012 04:39 Go to previous message
Eclipse UserFriend
Yeah, thanks Axel for your reply!

you are absolutly right! Although, apparently the problem is not there! I have done the modifications and I still get the error.
I reckon that my problem is inside the makefile, which while it is linking it does not find these functions.
I am saying this because the output of the makefile:

...
..linking
arm-none-eabi-ld -g -v -nostartfiles -Map ./main.map -T./lib/stm32_flash.ld -o ./main.out obj/main.o obj/system_stm32f10x.o obj/stm32f10x_gpio.o obj/stm32f10x_rcc.o obj/stm32f10x_it.o obj/stm32f10x_exti.o obj/stm32f10x_pwr.o obj/stm32f10x_dbgmcu.o obj/stm32f10x_usart.o obj/stm32f10x_can.o obj/stm32f10x_iwdg.o obj/misc.o obj/startup_stm32f10x_md.o libgcc.a
GNU ld (GNU Binutils) 2.21
obj/main.o: In function `main':
C:\eclipse\workspace\STM32-BUS_CAN_LoopBack/main.c:85: undefined reference to `strcpy'
C:\eclipse\workspace\STM32-BUS_CAN_LoopBack/main.c:86: undefined reference to `strcmp'

make: *** [main.out] Error 1

Thanks again.
Previous Topic:link file with header (permanent)
Next Topic:Problem extending console
Goto Forum:
  


Current Time: Mon Jul 07 21:18:36 EDT 2025

Powered by FUDForum. Page generated in 0.25822 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top