fopen fails on aix

John v/d Kamp blade_@dds.nl
Mon Mar 5 06:10:00 GMT 2001


Hi,

For my work, I have to port a program from the default cc compiler on AIX
to gcc/g++. But this is not completly going smoothly. The problem I am
facing now is that fopen(...) lets my program exit, with sometimes
different return codes, and no error message whatsoever.
The compiler is g++ 2.95.2
The linker is GNU ld 2.9.1 and seems to use libraries from
/apps/oss/lib/gcc-lib/rs6000-ibm-aix4.2.1.0/2.95.2 and /lib because of
missing (why, I don't know) libraries, like libg.a, libm.a and libc.a (is
this normal?)

simple example of a failing program:
---8<---

#include <stdio.h>

int main(int argc, char *argv[])
{
  FILE *f = NULL;
  f = fopen(argv[1], "r");	// does not execute corretly
  if (!f) {			// never reached!
    printf("Can't open %s.\n", argv[1]);
    return -1;
  }
  printf("file %s is now open.\n", argv[1]);
  fclose(f);
  return 0;
}

$ g++ -Wall -g -static -o ftest filetest.cpp
$ ./ftest filetest.cpp

$ echo $?
80
$

--->8---

Anybody knows what's going on?
Thanks for any pointers,

John



More information about the Gcc-help mailing list