You may come across this error “undefined reference to strrev” while coding in C. The function ‘strrev’ can be other string function.
You may also be surprised- your code is working fine on one of the systems while it is not working on other systems.
C:\Users\ANIRUD~1\AppData\Local\Temp\ccjLOzro.o(.text+0xbb):<c_prog_file_name>.c: undefined reference to strrev
The functions strrev()
available in the string.h
library. Functions strrev()
including some other string function such as like strupr
, strlwr
, strrev
, which are only available in ANSI C (Turbo C/C++) and are not available in standard C-GCC compiler.
It’s not about the system. It is about C compiler you are using.
If you are running this program on GCC compiler, it will throw error message as <prog_name>.c: undefined reference to strrev
.
Unfortunately, you cannot use strrev function here.
In this case, you have to write the complete function that works the same as an inbuilt function.
You might be facing the same issue while using strstr function. You can write your own code to implement strstr() function.
You can check out the C program for palindrome. Run it on the multiple compilers. This program gets compiled and run successfully on ANSI C compiler. Whereas it throws an error if you are running it on GCC compiler.
Hope this helps you to resolve your issue. If you still have any questions, please ask in the comment.
Happy Programming!
Thanks for sharing your knowledge! keep it up!
Welcome, Kylo!
How to run
strrev
function on Online compilers like GDB. IS is not taking it as a function while running the code!!Vinay, I think that
strrev
is not present in the GDB compiler. Moreover, can you please share the exact error you are gettinbg?