首先给出lame库的地址:http://download.youkuaiyun.com/detail/ysy441088327/4174609
作者博客:http://blog.youkuaiyun.com/ysy441088327/article/details/7392842
最近在使用lame库将CAF转换为MP3时遇到一个编译错误,此时的模拟器处于64bit位环境下,错误如下:
ld: warning: ignoring file /Users/apple/Desktop/论文批阅系统/论文批阅系统/libmp3lame.a, missing required architecture x86_64 in file /Users/apple/Desktop/论文批阅系统/论文批阅系统/libmp3lame.a (3 slices)
Undefined symbols for architecture x86_64:
"_lame_close", referenced from:
-[VoiceAnnotation convertCAFtoMP3] in VoiceAnnotation.o
"_lame_encode_buffer_interleaved", referenced from:
-[VoiceAnnotation convertCAFtoMP3] in VoiceAnnotation.o
"_lame_encode_flush", referenced from:
-[VoiceAnnotation convertCAFtoMP3] in VoiceAnnotation.o
"_lame_init", referenced from:
-[VoiceAnnotation convertCAFtoMP3] in VoiceAnnotation.o
"_lame_init_params", referenced from:
-[VoiceAnnotation convertCAFtoMP3] in VoiceAnnotation.o
"_lame_set_VBR", referenced from:
-[VoiceAnnotation convertCAFtoMP3] in VoiceAnnotation.o
"_lame_set_in_samplerate", referenced from:
-[VoiceAnnotation convertCAFtoMP3] in VoiceAnnotation.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command fai
解决方法如下:
首先打开工程 —— Build Settings,找到Architectures选项,修改如下:
补一张图:
将Standard architectures(including 64-bit)(armv7, armv7s, arm64)选项改为上面的Standard architectures(armv7, armv7s)就可以了。
再Build或者Run就没问题了。
顺便科普一下:
armv6、armv7、armv7s是arm CPU的指令集,一般是向下兼容的。如iPhone4sCPU支持armv7,但它会兼容armv6,只是使用armv6指令可能无法充分发挥它的特性。同理iPhone5是完全支持armv7的,所以不用担心armv7的库不能在iPhone5上跑,一般情况是不会出问题的。但需要提醒的是,苹果是自Xcode4.5之后,就放弃了对armv6的支持,换言之,就是Xcode4.5正常情况是不能编译armv6库的(当然据说通过特殊手段可以支持,之前在网有看到一些在神的帖子,感兴趣的可以搜搜)。
arm64,应该就是新推出的armv8了。
个人看来是该库并不支持arm64架构,产生了和64位不兼容的问题,所以出现了编译错误。