• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Linker can't find symbol _environ in Framework
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Linker can't find symbol _environ in Framework


  • Subject: RE: Linker can't find symbol _environ in Framework
  • From: "David Litwin" <email@hidden>
  • Date: Tue, 2 May 2006 13:57:31 -0700
  • Thread-topic: Linker can't find symbol _environ in Framework

Ack.  That's twice today I've hit 'send' before giving things a decent
check.

You can't pass &env to _NSGetEnviron as it takes void.  The code should
look more like:

void PrintEnv(void)
{
	char*** envPtr = _NSGetEnviron();	// pointer to the real
'environ'
	char** environ = *envPtr;
	while (*environ != NULL)
	{
		printf("%s\n", *environ);
		environ++;
	}
}

David Litwin
BigFix, Inc.

-----Original Message-----
From: David Litwin
Subject: RE: Linker can't find symbol _environ in Framework

>From looking at it, this file won't help you link against _environ, but
will help you solve the problem. crt_externs.h defines char***
_NSGetEnviron(void), so your framework code will have to be modified to
change its uses of environ to a variable it passes to this routine
before use:

void PrintEnv(void)
{
	char** env;
	_NSGetEnviron(&env);
	while (*env != NULL)
	{
		printf("%s\n", *env);
		env++;
	}
}

I haven't done so myself yet so if I've got it wrong I'm guessing Eric
will tell us.

David Litwin
BigFix

-----Original Message-----
From: Jerry Krinock
Sent: Tuesday, May 02, 2006 1:09 PM
To: Eric Albert; XCode Users
Subject: Re: Linker can't find symbol _environ in Framework

on 06/05/02 12:18, Eric Albert at email@hidden wrote:

> The right solution to this problem is actually to
> #include <crt_externs.h>
> in the file in your library or framework code which references
environ.
>
> Hope this helps,
> Eric

I just tried that Eric, but still get the same linker error.  I know you
spelled that filename correctly, because I get "file not found" if I
mis-spell it.

Here's a demo you can do in 5 minutes:

1.  Use Xcode 2.2.1.
2.  New Cocoa framework.
3.  To the project, add the following 7 files from
    developer.apple.com/samplecode/MoreIsBetter

    MoreCFQ.c           version 1.7
    MoreCFQ.h           version 1.9
    MoreSecurity.c      version 1.11
    MoreSecurity.h      version 1.8
    MoreUNIX.c          version 1.7
    MoreUNIX.h          version 1.3
    MoreSetup.h         version 1.14

4.  To the project, from /System/Library add Security.framework
5.  Build.

Expected Result: Success.
Actual Result: Linker error: Undefined symbols: _environ

Variation:
Repeat the experiment but instead of Cocoa in step 2 use Carbon.
Same results.

Variation:
Add to top of MoreSecurity.c:
#include <crt_externs.h>
Same results.

I wish a nice simple fix like that would work!


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
.com

This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
.com

This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Linker can't find symbol _environ in Framework
      • From: Eric Albert <email@hidden>
  • Prev by Date: Re: [Q] is there any good replacement for the Xcode?
  • Next by Date: Re: [Q] is there any good replacement for the Xcode?
  • Previous by thread: RE: Linker can't find symbol _environ in Framework
  • Next by thread: Re: Linker can't find symbol _environ in Framework
  • Index(es):
    • Date
    • Thread