mm24
mm24

Reputation: 9596

ZBar: Undefined symbols for architecture armv7

I am using the zBar library on an iOS 8 project and I get these compiler warnings:

Undefined symbols for architecture armv7:
  "_iconv", referenced from:
      _qr_code_data_list_extract_text in libzbar.a(qrdectxt.o)
  "_iconv_open", referenced from:
      _qr_code_data_list_extract_text in libzbar.a(qrdectxt.o)
  "_iconv_close", referenced from:
      _qr_code_data_list_extract_text in libzbar.a(qrdectxt.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I followed this suggestion putting the frameworks in order and this is how I import them:

enter image description here

I assume that the library libzbar.a was created for armv6 processors and as I am targeting iOS 8 with armv7 it conflicts. Is there a way to resolve this without me changing my project architecture targets?

Upvotes: 3

Views: 2257

Answers (3)

Rahul Patel
Rahul Patel

Reputation: 5886

Try to add libiconv.dylib in frameworks. I dont think it is armv7 problem. It should run after adding missing framework.

Upvotes: 12

Vitalii Gozhenko
Vitalii Gozhenko

Reputation: 9354

Maybe using native iOS barcode scanner will be better option? I also using ZBar in one of my projects, but after iOS 7, I start to use native, and became very happy :)

http://www.infragistics.com/community/blogs/torrey-betts/archive/2013/10/10/scanning-barcodes-with-ios-7-objective-c.aspx

Setup

self.output = [[AVCaptureMetadataOutput alloc] init];
dispatch_queue_t metadataQueue = dispatch_queue_create("com.youproject.capturebarcode", 0);

[self.output setMetadataObjectsDelegate:self queue:metadataQueue];
if ([self.session canAddOutput:self.output]) {
    [self.session addOutput:self.output];
}

And handle delegate code

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection
{
    [metadataObjects enumerateObjectsUsingBlock:^(AVMetadataObject *obj, NSUInteger idx, BOOL *stop) {
     if ([obj isKindOfClass:[AVMetadataMachineReadableCodeObject class]]) {
         AVMetadataMachineReadableCodeObject *code = (AVMetadataMachineReadableCodeObject *) [self.layer transformedMetadataObjectForMetadataObject:obj];
         if ([self.delegate respondsToSelector:@selector(barcodeReader:didReadBarcode:)]) {
             [self.delegate barcodeReader:self didReadBarcode:code.stringValue];
             self.delegate = nil;
         }
     }
    }];
}

Upvotes: 1

Sanjay Mohnani
Sanjay Mohnani

Reputation: 5967

Yes, you are right 'the library libzbar.a was created for armv6 architecture' and not for armv7.

If you are trying to provide support for armv7 architecture then in that case you need to build the library for armv7 architecture and it could be only done by developer of the library(since source is needed to build the static library).

Basically a fat(static library) file is created using static libraries for i386(simulator) and armv7(any required architectures) and shipped with the SDK of the static library which works on simulator as well as device.

The fat file is created by executing a lipo command on individual architecture static libraries.

Upvotes: 0

Related Questions