The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [pups] Stupid question..
@ 2001-01-15 14:53 Martijn van Buul
  0 siblings, 0 replies; only message in thread
From: Martijn van Buul @ 2001-01-15 14:53 UTC (permalink / raw)


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 at 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 at 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 at minnie.cs.adfa.edu.au)
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 at minnie.cs.adfa.edu.au>; Tue, 16 Jan 2001 09:22:55 +1100 (EST)
	(envelope-from wkt at henry.cs.adfa.edu.au)
Received: (from wkt at localhost)
	by henry.cs.adfa.edu.au (8.11.1/8.9.3) id f0FMTm309828
	for pups at 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 at minnie.cs.adfa.edu.au>; Tue, 16 Jan 2001 09:17:00 +1100 (EST)
	(envelope-from sms at moe.2bsd.com)
Received: (from sms at localhost)
	by moe.2bsd.com (8.10.1/8.10.1) id f0FMFjJ26746
	for pups at 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@moe.2bsd.com>
Message-Id: <200101152215.f0FMFjJ26746 at moe.2bsd.com>
To: pups at minnie.cs.adfa.edu.au
Subject: Re: [pups] Stupid question..
Sender: owner-pups at minnie.cs.adfa.edu.au
Precedence: bulk

Hi -

> From: Martijn van Buul <pino at 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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-01-15 14:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-15 14:53 [pups] Stupid question Martijn van Buul

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 NNTP newsgroup(s).