First disclosure: I am not much of a C programmer. I am trying to compile a set of C and Fortran codes with much pedigree, using a Makefile to generate an executable for engineering computation. I am using gcc 4.7.1 on sgi Irix (6.5.30). During compilation of the main program, first I get a warning on 'Implicit declaration of function 'setenv'. Subsequently, after generating all the objective 'o' files, the compilation ends with an error :
ld32: Error 33: Unresolved data symbol "setenv"
Commenting out the single line where the 'setenv' is defined allows the compilation to succeed and generate the executable file. However the line with setenv is crucial to the program.
This led me to write a test code and confirm the same problem :
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
int main()
{
setenv("FILE","/usr/bin/example.c",50);
printf("File = %s\n", getenv("FILE"));
return 0;
}
Based on all the suggestions I have found while googling here on stack exchange and other sites, I tried including different headers like
#define _POSIX_C_SOURCE
and
#define _GNU_SOURCE
before any #define statements. I have also tried compiling with -std=c99
as well as -D_XOPEN_SOURCE
and -D_GNU_SOURCE
with no luck.
I have also tried compiling the test program with Irix's native C compiler (cc and c99) and I get the same error:
Unresolved text symbol 'setenv'
Can someone please provide a helping hand on what else I should look for in my system and or environment variables in order to resolve this error?
It indeed looks like IRIX libc does not support the setenv()
command. You will have to rewrite it with putenv()
like this:
putenv("FILE=/usr/bin/example.c");
See also the IRIX putenv() manpage. Looking for setenv()
there does not show any hits, so I assume, this function is missing (note: IRIX 6.5.30 is from 2006)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With