From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mumit Khan To: ssiddiqi@ipass.net Cc: gnu-win32@cygnus.com, egcs-bugs@cygnus.com Subject: Re: G77 fork problems Date: Sun, 31 Jan 1999 23:52:00 -0000 Message-id: <199901182352.RAA21811@modi.xraylith.wisc.edu> References: <36A37EBC.C60EF81D@inspirepharm.com> X-SW-Source: 1999-01n/msg00492.html "Suhaib M. Siddiqi" writes: > Has anyone any suggestions why G77 (EGCS-1.1.1) gives undefined > refernece to fork_. I get same problem on RedHat Linux 5.2 with > EGCS-1.1.1 and Cygnus-B20 with EGCS-1.1.1. > > gridu.f: undefined reference to `fork_' > collect2: ld returned 1 exit status. You have to write a "wrapper" function callable from g77. Take a look at the files in libf2c/libU77 (in egcs-1.1.1 source code) on how to do this. Here's a start. Note that it's completely untested -- the includes I've used (eg., unistd.h) may not even exist on your system, pid_t may not be the same as g77 "integer" type, etc etc. /* g77fork.c -- simple fork wrapper for g77 on systems that support fork. */ #include #include static integer G77_fork_0 (void) { return fork (); } int fork_ (void) { return G77_fork_0 (); } Here's a trivial test program (nope, I didn't run it, so don't know if it'll even compile): c c forktest.f c program forktest external fork, getpid integer fork, pid, getpid c write (*,*) 'parent pid = ', getpid () pid = fork () if (pid .eq. 0) then write (*,*) 'Child process. Child pid = ', getpid () else write (*,*) 'Parent process. pid = ', pid end if call exit (0) end Now you should be able to do the following: $ g77 -o forktest forktest.f g77fork.c Regards, Mumit - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request@cygnus.com" with one line of text: "help".