I have a C program which compiles and runs fine under Linux without any warnings, but when trying to compile it on SunOS, I get the following warning:
test.c: In function `my_function':
test.c:412: warning: implicit declaration of function `strerror_r'
Undefined first referenced
symbol in file
strerror_r /var/tmp/ccRiPoGl.o
ld: fatal: Symbol referencing errors. No output written to test
collect2: ld returned 1 exit status
make: *** [test] Error 1
Any ideas?
The “implicit declaration” warning is telling you that none of the headers you have
#included have defined that function, and the “undefined symbol” warning is telling you that the function itself isn’t defined in any of the libraries that you’re linking in.Taken together, this implies that C library you’re compiling against doesn’t provide the
strerror_rfunction. You’ll have to roll your own alternative.For example, if you’re using
pthreads, you could do this: