Hey.
I'm playing around with a /53 running 2.11BSD, trying to port some
software, and I have a (probably stupid) problem: environ.
When I write a simple program like
#include <stdio.h>
extern char **environ;
void main(argc, argv)
int argc;
char **argv;
{
printf("Hello world!");
environ=environ;
}
and compile & link it using cc ("cc -o test test.c"), things go fine,
however if I link things manually ("cc -c test.c ; ld -o test test.o -lc")
I get an unresolved _environ. By some experimentation, I noticed that
including /lib/crt0.o in the linker helps to some extent - however,
the binary generated by cc works like a charm, while the manually
linked version quits with a bus error. Any ideas?
--
Martijn van Buul - Pino(a)dohd.org -
http://www.stack.nl/~martijnb/
Geek code: G-- - Visit OuterSpace: mud.stack.nl 3333
Kees J. Bot: The sum of CPU power and user brain power is a constant.
Received: (from major@localhost)
by minnie.cs.adfa.edu.au (8.9.3/8.9.3) id JAA08435
for pups-liszt; Tue, 16 Jan 2001 09:22:57 +1100 (EST)
(envelope-from owner-pups(a)minnie.cs.adfa.edu.au)
From "Steven M. Schultz"
<sms(a)moe.2bsd.com> Tue Jan 16 08:15:45 2001
Received: from
henry.cs.adfa.edu.au (henry.cs.adfa.edu.au [131.236.21.158])
by minnie.cs.adfa.edu.au (8.9.3/8.9.3) with ESMTP id JAA08430
for <pups(a)minnie.cs.adfa.edu.au>; Tue, 16 Jan 2001 09:22:55 +1100 (EST)
(envelope-from wkt(a)henry.cs.adfa.edu.au)
Received: (from wkt@localhost)
by henry.cs.adfa.edu.au (8.11.1/8.9.3) id f0FMTm309828
for pups(a)minnie.cs.adfa.edu.au; Tue, 16 Jan 2001 09:29:48 +1100 (EST)
(envelope-from wkt)
Received: from
moe.2bsd.com (
MOE.2BSD.COM [206.139.202.200])
by minnie.cs.adfa.edu.au (8.9.3/8.9.3) with ESMTP id JAA08355
for <pups(a)minnie.cs.adfa.edu.au>; Tue, 16 Jan 2001 09:17:00 +1100 (EST)
(envelope-from sms(a)moe.2bsd.com)
Received: (from sms@localhost)
by
moe.2bsd.com (8.10.1/8.10.1) id f0FMFjJ26746
for pups(a)minnie.cs.adfa.edu.au; Mon, 15 Jan 2001 14:15:45 -0800 (PST)
Date: Mon, 15 Jan 2001 14:15:45 -0800 (PST)
From: "Steven M. Schultz" <sms(a)moe.2bsd.com>
Message-Id: <200101152215.f0FMFjJ26746(a)moe.2bsd.com>
To: pups(a)minnie.cs.adfa.edu.au
Subject: Re: [pups] Stupid question..
Sender: owner-pups(a)minnie.cs.adfa.edu.au
Precedence: bulk
Hi -
From: Martijn van Buul <pino(a)dohd.org>
however if I link things manually ("cc -c test.c ; ld -o test test.o -lc")
I get an unresolved _environ. By some experimentation, I noticed that
including /lib/crt0.o in the linker helps to some extent - however,
the binary generated by cc works like a charm, while the manually
linked version quits with a bus error. Any ideas?
Try placing /lib/crt0.o before the test.o:
ld -o test /lib/crt0.o test.o -lc
on another note it's usually not a good idea to call a program 'test'
because when you are least expecting it you will end up running
/bin/test and wonder what is wrong.
Steven