-->

symbol(s) not found for architecture i386 about op

2019-09-18 13:56发布

问题:

I am studying opencv for ios now.After I download example codes from github.com/macmade, i complie and run the program, everything is OK. However, when i add some opencv codes as bellow:

IplImage* img = 0;
int height,width,step,channels;
uchar* data;
int hIndex,wIndex,cIndex;
img = cvLoadImage("tapme.png",CV_LOAD_IMAGE_COLOR);
if (!img) {
    NSLog(@"img cannot load");
    return;
}

height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels;
data = (uchar*)img->imageData;

NSLog(@"%d:%d:%d:%d",height,width,step,channels);

Then i compile the program again, everything is OK too. But when errors happen when linking:

Undefined symbols for architecture i386:
"_cvLoadImage", referenced from:
-[MainViewController showPic:] in MainViewController.o

I have tried almost all methods in stackoverflow, but the result is still not so good. Anyone have a good idea to fix the bug, waiting for ur help and thank u.

回答1:

When you build for the simulator, the linker will need a library for i386 architecture. When you build for a device, the linker will need a library for arm architecture. Do your simulator build settings point to the correct library?