RE: Linker can't find symbol _environ in Framework
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:46:44 -0700
- Thread-topic: 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:
This email sent to email@hidden