3

I was trying to make a sample code run download by the link

http://www.magtek.com/support/software/downloads/sw/99510108.zip

This is a card reader api ,here is a sample code.When I run this code I got the error:

ld: warning: ignoring file /Users/gaurav.garg/Downloads/99510108/SampleCode/Lib/libMTSCRA.a, missing required architecture i386 in file
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_MTSCRA", referenced from:
      objc-class-ref in MagTekDemoAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The class MTSCRA is only a header file,And the solution that I have cheked That we have to add the .m file in compiled source path of build build phase of target...but unfortunately I don't have the MTSCRA.m file.MTscra.h have the AudioToolBox and externalAccesory framework.

Gaurav Garg
  • 130
  • 8

3 Answers3

8

Actually the problem is that MagTek provides you two separate .a files.

If you look at the one in the Release-iphoneos and run the following command:

> lipo -info libMTSCRA.a 
Architectures in the fat file: libMTSCRA.a are: armv7 (cputype (12) cpusubtype (11))

Likewise if you look at the one in Release-iphonesimulator...

> lipo -info libMTSCRA.a 
input file libMTSCRA.a is not a fat file
Non-fat file: libMTSCRA.a is architecture: i386

So the real answer is to create a new libMTSCRA.a for DEBUG that is n-way FAT by combining the two using lib tool and then creating separate DEBUG and RELEASE library search paths.

To start you would go to the directory above where MagTek keeps the two different versions of libMTSCRA.a When you are there, you will run the following command:

libtool -static -o libMTSCRA_FAT.a Release-iphoneos/libMTSCRA.a Release-iphonesimulator/libMTSCRA.a 

When you examine the output file, you should see:

>lipo -info libMTSCRA_FAT.a 
Architectures in the fat file: libMTSCRA.a are: armv7 (cputype (12) cpusubtype (11)) i386 

Then in your project, create two folders (aka groups) "debug" & "release" and then restructure the DEBUG and RELEASE Library Search Paths to use these respective directories.

Lastly, rename libMTSCRA_FAT.a to libMTSCRA.a and place it in the debug search path keeping the iOS (armv7 (cputype (12) cpusubtype (11))) in release. The reason we do this is because while it might be ok to use this newly created .a file in debug mode it is considered bad taste to push this into production because we have no way to confirm that the merged lib is 100% what we intended ( the merge of the archs ).

Et voilà !

Alex Horovitz
  • 81
  • 1
  • 1
3
Undefined symbols for architecture i386:

It means that the library you are linking against does not have symbols for i386. Which means you can not use the simulator. You will need to run the sample on the device or get the version of the library created for the simulator.

bstahlhood
  • 2,006
  • 13
  • 10
  • @bastahlhood:I am getting this error when run on device: **Error launching remote program: No such file or directory (/Users/gaurav.garg/Library/Developer/Xcode/DerivedData/MagTekDemo-eojqpfzujdtekwftlqbzzyfmuwng/Build/Products/Debug-iphoneos/MTDemo.SCRA.app/MTDemo.SCRA).** I am running it by the developer profile.I have cleaned it many times also. And the build is installed but not open at instant.We manullay open the app. – Gaurav Garg Jun 08 '12 at 23:50
  • @bastahlhood:Found it.we have to quit the xcode i.e. restrat the app.Thanks – Gaurav Garg Jun 09 '12 at 02:04
  • 1
    I ran into the exact same issue recently. I found that conditional linking worked. The Magtek demo included both iphoneos and iphone-simulator symbols. http://stackoverflow.com/questions/1211854/xcode-conditional-build-settings-based-on-architecture-device-arm-vs-simulat – subv3rsion Mar 12 '13 at 14:46
0

You need to make sure you are including all of the Frameworks that are required by that library.

Matt Hudson
  • 7,329
  • 5
  • 49
  • 66
  • :What frameworks that needed I don't know.....However there are Audiotoolbox,ExternalAccessory framework are added already with 3 basic framework.One more thing that Mtscra.h file has imported Foundation,AudioToolbox,**AudioUnit**,ExternalAccessory but In framework when I add the **Audiounit** framework It shows another error that Audiounit frmework not found – Gaurav Garg Jun 07 '12 at 22:18
  • That's almost assuredly your issue. – Matt Hudson Jun 08 '12 at 16:14
  • Add these as well CoreAudio.framework and AudioToolbox.framework for AudioUnit – Matt Hudson Jun 08 '12 at 16:15