public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Is it possible to define the root directory in a cross compiled program
@ 2021-01-05  1:34 Roger Kaufman
  2021-01-05  3:17 ` Brian Inglis
  0 siblings, 1 reply; 9+ messages in thread
From: Roger Kaufman @ 2021-01-05  1:34 UTC (permalink / raw)
  To: cygwin

When I cross compile the following program, opening /dev/null fails and 
instead the whole install path of /cygwin64/dev/null is visible.

Is there a way to make fopen respect / as the root directory in a cross 
compiled program for windows?

example output...

Roger@interocitor:~
$ x86_64-w64-mingw32-g++ -o writenull.exe write2null.cc

Roger@interocitor:~
$ writenull.exe
/dev/null did not succeed


Roger@interocitor:~
$ gcc -o writenull write2null.cc

Roger@interocitor:~
$ writenull
/cygwin64/dev/null did not succeed


C Code that was compiled...

#include <cstdio>

int main(int argc, char **argv)
{
   FILE *errfile1 = fopen("/dev/null", "w");
   if (!errfile1) // must be a valid pointer
     errfile1 = stderr;

   FILE *errfile2 = fopen("/cygwin64/dev/null", "w");
   if (!errfile2) // must be a valid pointer
     errfile2 = stderr;

   fprintf(errfile1, "/dev/null did not succeed\n");
   fprintf(errfile2, "/cygwin64/dev/null did not succeed\n");

   return 0;
}

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-01-05 23:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05  1:34 Is it possible to define the root directory in a cross compiled program Roger Kaufman
2021-01-05  3:17 ` Brian Inglis
2021-01-05 13:34   ` Eliot Moss
2021-01-05 15:02     ` Bill Stewart
2021-01-05 15:09       ` Eliot Moss
2021-01-05 16:49   ` Roger Kaufman
2021-01-05 17:06     ` Brian Inglis
2021-01-05 21:04   ` Andrey Repin
2021-01-05 23:07     ` Hans-Bernhard Bröker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).