Undefined symbols for architecture i386:

First of all, hello everyone, pleased to be around here, hope we'll get along nicely 🙂

Now onto my problem:

If I try to use a global variable(yes, I know it's not the best way to do it, but I need only some colors to play to play around with) I get this error(s)

I included this time a color, a string and an int, just to test them all out. Even only "analyzing" gives me the error(s).


I tried #importing the "xxx.h" where these variables are declared to several files where I need them(one at a time to see if something is wrong). I even tried not #importing them anywhere, just declaring them. still the error(s) occur. I even tried making myself a class method, but as I said, even only declaring them gives me the error(s).


Any help please? I searched the web up and down, haven't found anything close to my problem. Other remotely close problems were fixed by adding the required framework in the "link binary with libraries" tab.


Eventually I'll just set them from the settings view to a file and use local variables on each of my other views that retrive the values from the file ... if nothing works 😟


my Architectures value is Standard, Base SDK is Latest(4.3), Supported Platforms is iphonesimulator iphoneos, Valid architectures value is armv6 armv7

Guess I'm missing a settings value somwhere :S



Ld /Users/home/Library/Developer/Xcode/DerivedData/myappname-cvxzlcdwwvzoctboksiqc rlzhzvx/Build/Products/Debug-iphonesimulator/myappname.app/myappname normal i386

cd "/Users/home/Desktop/Programele invatare/myappname"

setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr /bin:/usr/bin:/bin:/usr/sbin:/sbin"

/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3 .sdk -L/Users/home/Library/Developer/Xcode/DerivedData/myappname-cvxzlcdwwvzoctboksi qcrlzhzvx/Build/Products/Debug-iphonesimulator -F/Users/home/Library/Developer/Xcode/DerivedData/myappname-cvxzlcdwwvzoctboksi qcrlzhzvx/Build/Products/Debug-iphonesimulator -filelist /Users/home/Library/Developer/Xcode/DerivedData/myappname-cvxzlcdwwvzoctboksiqc rlzhzvx/Build/Intermediates/myappname.build/Debug-iphonesimulator/myappname.buil d/Objects-normal/i386/myappname.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -framework AudioToolbox -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/home/Library/Developer/Xcode/DerivedData/myappname-cvxzlcdwwvzoctboksiqc rlzhzvx/Build/Products/Debug-iphonesimulator/myappname.app/myappname


Undefined symbols for architecture i386:

"_awesomeString", referenced from:

+[Constants myVariables] in Constants.o

"_gBlackColor", referenced from:

+[Constants myVariables] in Constants.o

"_gDefaultColor", referenced from:

+[Constants myVariables] in Constants.o

"_gGrayColor", referenced from:

+[Constants myVariables] in Constants.o

"_gJadeColor", referenced from:

+[Constants myVariables] in Constants.o

"_kBlueColor", referenced from:

+[Constants myVariables] in Constants.o

"_myInteger", referenced from:

+[Constants myVariables] in Constants.o

ld: symbol(s) not found for architecture i386

collect2: ld returned 1 exit status


Thank you,

Roland.

Mac mini, Mac OS X (10.6.8)

Posted on Jul 7, 2011 1:15 PM

Reply
6 replies

Jul 7, 2011 3:28 PM in response to xnav

.m file

#import <UIKit/UIKit.h>

#import <Foundation/Foundation.h>


extern UIColor *gBlueColor;

extern UIColor *gDefaultColor;

extern UIColor *gJadeColor;

extern UIColor *gGrayColor;

extern UIColor *gBlackColor;

extern UIColor *gBackgroundColor;

extern UIColor *gTextColor;

extern NSString *awesomeString;


extern int myInteger;



@interface Constants : NSObject


+ (void)myVariables;


@end

.h file

#import "Constants.h"



@implementation Constants


+ (void)myVariables

{

gBlueColor = [UIColor colorWithRed:0.827 green:0.927 blue:1 alpha:1];

gDefaultColor = [UIColor colorWithRed:0.996 green:0.969 blue:0.831 alpha:1];

gJadeColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"jadepattern.png"]];

gGrayColor = [UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1];

gBlackColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];

awesomeString = @"afsa";

myInteger = 10;

}

@end

As for the other places I'm trying to use these, I do #import "Constants.h".

I also tried:

* Only create the Constants.h file, declare them there and instantiate them values directly where I wanna use them. still no.

* Without the + (void)myVariables, simply instantiate them directly in the @implementation body, obviously a newb mistake 😟

* Also tried not using a Constant.h file and declaring them in "myappdelegate.h"(or any other file.h for that matter), instantiate them in the .m, #import "myappdelegate.h" where I wanna use them, but still a nono.


autocompletion finds the variables wherever I import the declaration header, it also colors them properly, I get no compiler errors either. untill I build/analyze/run.



The more I wait a for a solution, the more I'm afraid I'm doing a really silly mistake 🙂

Jul 7, 2011 3:33 PM in response to xnav

xnav wrote:


Also check out this tutorial first.

sigh. as I said. it was something SO easy 😟

I changed the Constants.m file to

#import "Constants.h"



@implementation Constants

@end

UIColor *kBlueColor;

UIColor *gDefaultColor;

UIColor *gJadeColor;

UIColor *gGrayColor;

UIColor *gBlackColor;

UIColor *gBackgroundColor;

UIColor *gTextColor;

NSString *awesomeString;

int myInteger;

and now it works. I feel so silly, lol. Ill even confess I visited that page at one point and only skimmed it, so Ill feel even more silly and teach myself a lesson lol 🙂


thanks xnav, to bad I cant change to "correct answer" 😟

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Undefined symbols for architecture i386:

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.