如何将 lame 编译为 iPhone 的 armv6 和 armv7 的静态库 (.a)? [英] How can I compile lame as static library(.a) for armv6 and armv7 of iPhone?

查看:14
本文介绍了如何将 lame 编译为 iPhone 的 armv6 和 armv7 的静态库 (.a)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LAME(http://lame.sourceforge.net/) 是一个用 c 语言编写的库.它可以将 PCM 声音文件转换为 MP3 文件.我用它在 iPhone 上将声音文件转换为 MP3 文件.源PCM声音文件由麦克风录制.

为了将 LAME 包含到我的 XCode 项目中,我需要将 LAME 编译为 3 个静态库 (.a),用于 i386(IOS 模拟器)、armv6 和 armv7.

经过大量的搜索,我已经成功地为 i368 版本(iOS 模拟器)编译了一个静态库.这是命令:

./configure CFLAGS="-isysroot/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk" CC="/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386" --prefix=/Volumes/Data/test/i386 --host="arm-apple-darwin9"制作&&进行安装

问题是我无法为 armv6 和 armv7 编译.我试过这个命令,但它报告一个错误.有没有人有解决方案?

./configure CFLAGS="-isysroot/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk" CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6" --prefix=/Volumes/Data/test/arm6 --host="arm-apple-darwin9"制作&&进行安装

错误是:

console.c:25:21: 错误:curses.h: 没有那个文件或目录console.c:27:20: 错误: term.h: 没有那个文件或目录console.c:在函数‘get_termcap_string’中:console.c:92: 警告:函数‘tgetstr’的隐式声明console.c:92: 警告:赋值使指针从整数而不进行强制转换console.c:在函数‘get_termcap_number’中:console.c:102: 警告:函数‘tgetnum’的隐式声明console.c:在函数apply_termcap_settings"中:console.c:115: 警告:函数‘tgetent’的隐式声明make[2]: *** [console.o] 错误 1make[1]: *** [all-recursive] 错误 1make: *** [all] 错误 2

当我安装 ncurses 时,它报告了这个:

../curses.h:60:25: 错误: ncurses_dll.h: 没有那个文件或目录在 console.c:25 包含的文件中:../curses.h:250: 警告:返回类型默认为‘int’../curses.h:在函数‘NCURSES_EXPORT_VAR’中:../curses.h:250: 错误:acs_map"之前的预期声明说明符../curses.h:340: 错误:为参数SCREEN"指定的存储类../curses.h:341: 错误:为参数WINDOW"指定的存储类../curses.h:343: 错误:为参数attr_t"指定了存储类../curses.h:388: 警告:空声明../curses.h:401: 错误:'attr_t' 之前的预期说明符限定符列表../curses.h:443: 警告: 空声明../curses.h:542: 错误:为参数NCURSES_OUTC"指定的存储类../curses.h:551: 错误:在addch"之前预期="、、"、;"、asm"或__attribute__"../curses.h:552: 错误:在‘addchnstr’之前预期‘=’、‘,’、‘;’、‘asm’或‘__attribute__’../curses.h:553: 错误:在‘addchstr’之前预期‘=’、‘,’、‘;’、‘asm’或‘__attribute__’../curses.h:554: 错误:在‘addnstr’之前预期‘=’、‘,’、‘;’、‘asm’或‘__attribute__’

有人可以给我一种将 LAME 编译为 armv6 和 armv7 的静态库 (.a) 的方法吗?

解决方案

您错过了几个步骤.首先,您根本不想构建前端,因为无论如何您只能将 LAME 用作库.您还必须静态构建库,否则您将无法将其构建到您的项目中.

基本上,您必须设置源代码树并编译四次,一次用于模拟器 (i686)、iPhone (armv6)、iPad (armv7) 和 iPhone 5 (armv7s),然后将 .a 文件一起 lipo 成一个万能图书馆.当您编译项目的其余部分时,Xcode 链接器将为您整理其他所有内容.

我使用这个 shell 脚本构建了一个通用的 libmp3lame.a 文件.请注意,这使用 Xcode 4.3 路径和 iOS 5.1 编译器.

#!/bin/bashSDK_VERSION="5.1"mkdir 构建函数 build_lame(){使 distclean./配置 CFLAGS="-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/${SDK}.platform/Developer/SDKs/${SDK}${SDK_VERSION}.sdk" CC="/Applications/Xcode.app/Contents/Developer/Platforms/${SDK}.platform/Developer/usr/bin/gcc -arch ${PLATFORM}" --prefix=/Users/mcrute/Desktop/lame --host="arm-apple-darwin9" --disable-shared --启用静态--disable-decoder --禁用前端制作cp "libmp3lame/.libs/libmp3lame.a" "build/libmp3lame-${PLATFORM}.a"}平台=i686"SDK="iPhone模拟器"建造跛脚平台=armv6"SDK="iPhoneOS"建造跛脚平台=armv7"建造跛脚平台=armv7s"建造跛脚lipo -create build/* -output build/libmp3lame.a

将 ./build 中的 libmp3lame.a 文件和 include 目录中的 lame.h 文件放入您的 Xcode 项目中,您应该准备好在模拟器或真实设备中使用 lame.

LAME(http://lame.sourceforge.net/) is a library written in c language. It can convert PCM sound files to MP3 files. I use it to convert sound files to MP3 files on iPhone. The source PCM sound files is recorded by microphone.

In order to include the LAME into my XCode Project, I need to compile the LAME to 3 static libraries(.a), for i386(IOS Simulator), armv6 and armv7.

After a lot of search, I have complied a static library for i368 version(iOS Simulator) successfully. Here is commands:

./configure 
    CFLAGS="-isysroot  /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk" 
    CC="/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386" 
    --prefix=/Volumes/Data/test/i386 
    --host="arm-apple-darwin9"

make && make install

The problem is I can not compile for armv6 and armv7. I have tried this commands but it report an error. Is there anybody have solutions?

./configure 
    CFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk" 
    CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6" 
    --prefix=/Volumes/Data/test/arm6 
    --host="arm-apple-darwin9"

make && make install

The error is:

console.c:25:21: error: curses.h: No such file or directory
console.c:27:20: error: term.h: No such file or directory
console.c: In function ‘get_termcap_string’:
console.c:92: warning: implicit declaration of function ‘tgetstr’
console.c:92: warning: assignment makes pointer from integer without a cast
console.c: In function ‘get_termcap_number’:
console.c:102: warning: implicit declaration of function ‘tgetnum’
console.c: In function ‘apply_termcap_settings’:
console.c:115: warning: implicit declaration of function ‘tgetent’
make[2]: *** [console.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

When I install ncurses, It reported this:

../curses.h:60:25: error: ncurses_dll.h: No such file or directory
In file included from console.c:25:
../curses.h:250: warning: return type defaults to ‘int’
../curses.h: In function ‘NCURSES_EXPORT_VAR’:
../curses.h:250: error: expected declaration specifiers before ‘acs_map’
../curses.h:340: error: storage class specified for parameter ‘SCREEN’
../curses.h:341: error: storage class specified for parameter ‘WINDOW’
../curses.h:343: error: storage class specified for parameter ‘attr_t’
../curses.h:388: warning: empty declaration
../curses.h:401: error: expected specifier-qualifier-list before ‘attr_t’
../curses.h:443: warning: empty declaration
../curses.h:542: error: storage class specified for parameter ‘NCURSES_OUTC’
../curses.h:551: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘addch’
../curses.h:552: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘addchnstr’
../curses.h:553: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘addchstr’
../curses.h:554: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘addnstr’

Is there somebody can give me a way to compile LAME to static library(.a) for the armv6 and armv7?

解决方案

You're missing a few steps. First of all you don't want to build the frontend at all since you'll only be able to use LAME as a library anyhow. You also have to build the library statically otherwise you won't be able to build it into your project.

Basically, you have to setup the source tree and compile it four times, once for the simulator (i686), iPhone (armv6), iPad (armv7) and iPhone 5 (armv7s) then lipo the .a files together into a universal library. The Xcode linker will sort everything else out for you when you compile the rest of your project.

I used this shell script to build a universal libmp3lame.a file. Note this uses Xcode 4.3 paths and iOS 5.1 compilers.

#!/bin/bash

SDK_VERSION="5.1"

mkdir build

function build_lame()
{
    make distclean

    ./configure 
        CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/${SDK}.platform/Developer/SDKs/${SDK}${SDK_VERSION}.sdk" 
        CC="/Applications/Xcode.app/Contents/Developer/Platforms/${SDK}.platform/Developer/usr/bin/gcc -arch ${PLATFORM}" 
        --prefix=/Users/mcrute/Desktop/lame 
        --host="arm-apple-darwin9" 
        --disable-shared 
        --enable-static 
        --disable-decoder 
        --disable-frontend

    make
    cp "libmp3lame/.libs/libmp3lame.a" "build/libmp3lame-${PLATFORM}.a"
}

PLATFORM="i686"
SDK="iPhoneSimulator"
build_lame

PLATFORM="armv6"
SDK="iPhoneOS"
build_lame

PLATFORM="armv7"
build_lame

PLATFORM="armv7s"
build_lame

lipo -create build/* -output build/libmp3lame.a

Take the libmp3lame.a file from ./build along with the lame.h file from the include directory and drop them in your Xcode project and you should be ready to use lame in either the simulator or a real device.

这篇关于如何将 lame 编译为 iPhone 的 armv6 和 armv7 的静态库 (.a)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆