[Solved] Undefined reference to strrev | Error Code in C
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.
Error message “Undefined reference to strrev”:
C:\Users\ANIRUD~1\AppData\Local\Temp\ccjLOzro.o(.text+0xbb):<c_prog_file_name>.c: undefined reference to strrev
strrev() available in the
string.h library. Functions
strrev() including some other string function such as like
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.
How to solve this issue on GCC compiler?
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.