如何将VAMP插件编译为iOS ARMV7

时间:2013-10-18 00:07:37

标签: ios audio boost makefile lapack

VAMP伦敦大学玛丽皇后大学的插件是BSD许可软件的精彩集合。所有这些插件都是Sonic Visualizer软件的基础 我也可以使用A plug Sdk来构建插件。

您可以为OSX / Linux / Win32目标构建插件。

Queen Mart大学很好地解释了here插件架构以及如何为上面指定的不同平台构建。

Java版本,jVamp也可用。也是一个Python包装器。

但是,如何为iOS平台构建?

所以,我尝试将Makefile移植到iOS。

首先我更改了文件

build/osx/Makefile.osx

以这种方式:

CFLAGS := -O3 -ftree-vectorize -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch x86_64 -I../vamp-plugin-sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/ -DUSE_PTHREADS

CXXFLAGS  := $(CFLAGS)

LDFLAGS   := -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch x86_64 -lqm-dsp ../vamp-plugin-sdk/libvamp-sdk.a -framework Accelerate -lpthread -exported_symbols_list=vamp-plugin.list -install_name qm-vamp-plugins.a

PLUGIN_EXT   := .a

include build/general/Makefile.inc

然后建立

macbookproloreto:qm-vamp-plugins loreto$ make -f build/osx/Makefile.osx
cc -O3 -ftree-vectorize -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch x86_64 -I../vamp-plugin-sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/ -DUSE_PTHREADS -I. -I../qm-dsp   -c -o g2cstubs.o g2cstubs.c
c++ -O3 -ftree-vectorize -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch x86_64 -I../vamp-plugin-sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/ -DUSE_PTHREADS -I. -I../qm-dsp   -c -o plugins/AdaptiveSpectrogram.o plugins/AdaptiveSpectrogram.cpp
In file included from plugins/AdaptiveSpectrogram.cpp:15:
In file included from plugins/AdaptiveSpectrogram.h:18:
In file included from ../vamp-plugin-sdk/vamp-sdk/Plugin.h:40:
In file included from /usr/bin/../lib/c++/v1/string:430:
In file included from /usr/bin/../lib/c++/v1/iosfwd:90:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/wchar.h:70:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/_types.h:27:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/sys/_types.h:32:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/sys/cdefs.h:655:2: **error: Unsupported
      architecture
#error Unsupported architecture
 ^**

这里的第一个问题是架构不受支持。

所以插件取决于我必须首先构建那个的SDK:

cd /Users/loreto/Projects/AUDIO/VAMP/vamp-plugin-sdk
make -f build/Makefile.osx

由于我没有OGG/VORBIS库而没有LOGG库,因此发生了不同的错误。所以我稍微修改了Makefile.osx,删除了HOST_LIB标志中的这些依赖项。无论如何我必须保留libsndfile

HOST_LIBS       = ./libvamp-hostsdk.a -L../10.8/inst/lib -lsndfile -ldl

所以我能够在这里构建静态库:

macbookproloreto:vamp-plugin-sdk loreto$ ls -l *.a
-rw-r--r--  1 loreto  staff  709840 17 Ott 23:56 libvamp-hostsdk.a
-rw-r--r--  1 loreto  staff  183720 17 Ott 23:56 libvamp-sdk.a

当然这些静态库的目标是拱形x86_64所以我需要添加armv7 arch:

ARCHFLAGS = -mmacosx-version-min=$(MINVERSION) -arch x86_64 -arch armv7

然后再清理并再次编译

macbookproloreto:vamp-plugin-sdk loreto$ make -f build/Makefile.osx clean
macbookproloreto:vamp-plugin-sdk loreto$ make -f build/Makefile.osx
c++ -mmacosx-version-min=10.8 -arch x86_64 -arch armv7 -O2 -Wall -I. -I../10.8/inst/include -fPIC   -c -o src/vamp-sdk/PluginAdapter.o src/vamp-sdk/PluginAdapter.cpp
In file included from src/vamp-sdk/PluginAdapter.cpp:37:
In file included from ./vamp-sdk/PluginAdapter.h:40:
In file included from /usr/include/c++/4.2.1/map:64:
In file included from /usr/include/c++/4.2.1/bits/stl_tree.h:68:
In file included from /usr/include/c++/4.2.1/bits/stl_algobase.h:65:
In file included from /usr/include/c++/4.2.1/bits/c++config.h:41:
In file included from /usr/include/c++/4.2.1/bits/os_defines.h:61:
In file included from /usr/include/unistd.h:71:
In file included from /usr/include/_types.h:27:
In file included from /usr/include/sys/_types.h:33:
/usr/include/machine/_types.h:34:10: fatal error: 'arm/_types.h' file not found
#include "arm/_types.h"
         ^
1 error generated.
make: *** [src/vamp-sdk/PluginAdapter.o] Error 1

未找到arm的类型定义!这里的问题是正确的道路是

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/arm/_types.h

好的,让我们再次在Makefile.osx中解决这个问题:

ARCHFLAGS = -mmacosx-version-min=$(MINVERSION) -arch armv7
CFLAGS          = $(ARCHFLAGS) -fPIC --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/
CXXFLAGS        = $(ARCHFLAGS) -O2 -Wall -I. -fPIC
CPPFLAGS        ="-pipe -no-cpp-precomp -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk

然后制作静态目标:

make -f build/Makefile.osx sdkstatic

哇有效!我有一个适用于iOS的鞋面主机sdk .a!(我想让我们说)

macbookproloreto:vamp-plugin-sdk loreto$ ls -l *.a
-rw-r--r--  1 loreto  staff  301176 18 Ott 00:35 libvamp-hostsdk.a
-rw-r--r--  1 loreto  staff   76024 18 Ott 00:35 libvamp-sdk.a

好的,但是让我们查看otool,因为你永远不知道:

macbookproloreto:vamp-plugin-sdk loreto$ otool -hv libvamp-sdk.a
Archive : libvamp-sdk.a
libvamp-sdk.a(PluginAdapter.o):
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
   MH_MAGIC     ARM         V7  0x00      OBJECT     4       1128 SUBSECTIONS_VIA_SYMBOLS
libvamp-sdk.a(RealTime.o):
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
   MH_MAGIC     ARM         V7  0x00      OBJECT     4       1060 SUBSECTIONS_VIA_SYMBOLS
libvamp-sdk.a(FFT.o):
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
   MH_MAGIC     ARM         V7  0x00      OBJECT     4        584 SUBSECTIONS_VIA_SYMBOLS
libvamp-sdk.a(acsymbols.o):
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
   MH_MAGIC     ARM         V7  0x00      OBJECT     3        500 SUBSECTIONS_VIA_SYMBOLS

好的,这就是armv7架构。

现在,再次回到插件sdk并更改

build/osx/Makefile.osx

如下:

CFLAGS := -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/ -DUSE_PTHREADS

CXXFLAGS  := $(CFLAGS)

include build/general/Makefile.inc

好的回来再说:

macbookproloreto:dsp loreto$ make -f build/osx/Makefile.osx

轰!另一个问题:

/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/ -DUSE_PTHREADS -I.   -c -o dsp/wavelet/Wavelet.o dsp/wavelet/Wavelet.cpp
cc -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/ -DUSE_PTHREADS -I.   -c -o hmm/hmm.o hmm/hmm.c
hmm/hmm.c:21:10: fatal error: 'clapack.h' file not found
#include <clapack.h>            /* LAPACK for matrix inversion */
         ^
1 error generated.
make: *** [hmm/hmm.o] Error 1
macbookproloreto:dsp loreto$ vi build/osx/Makefile.osx 

找不到LAPACK。

但对于Apple Docs here,自iOS4.0起,Apple在Accelerate.frameworks中引入了LAPACK!

实际上clapack.h在这里:     /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/clapack.h

所以让我们在../dsp/build/Makefile.osx

中添加它
CFLAGS := -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/ -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/ -DUSE_PTHREADS

现在让我们再来一次,但让我检查一下拱门:

macbookproloreto:dsp loreto$ otool -hv libqm-dsp.a 
Archive : libqm-dsp.a
libqm-dsp.a(Pitch.o):
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
   MH_MAGIC     ARM         V7  0x00      OBJECT     4        516 SUBSECTIONS_VIA_SYMBOLS
libqm-dsp.a(Chromagram.o):
Mach header

听起来不错!现在返回plugins文件夹中的一个级别并生成

In file included from plugins/AdaptiveSpectrogram.cpp:15:
plugins/AdaptiveSpectrogram.h:22:10: fatal error: 'dsp/transforms/FFT.h' file not found
#include <dsp/transforms/FFT.h>
         ^
1 error generated.

嗯,好吧,dsp /错过了转换文件夹 - 天哪!

另一个错误:

clang: error: invalid argument '-install_name qm-vamp-plugins.a' only allowed with '-dynamiclib'
make: *** [qm-vamp-plugins.a] Error 1

让我们再次修复Makefile.osx:

CFLAGS := -O3 -ftree-vectorize -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch armv7 -I../vamp-plugin-sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/ -DUSE_PTHREADS

CXXFLAGS  := $(CFLAGS)

LDFLAGS   := -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch armv7 -lqm-dsp ../vamp-plugin-sdk/libvamp-sdk.a -framework Accelerate -lpthread

好的,现在错误是架构未定义的符号错误:要长期查看要点here 像:

  "std::cerr", referenced from:
  "typeinfo for std::istream", referenced from:
  "std::ostream::put(char)""
  std::ostream::operator<<(int)",

这让我想起了boost C ++库!

所以我需要得到提升,为iOS编译然后将它包含在Makefile中它应该可以工作,不是吗?这可能需要很长时间......

现在这样做

macbookproloreto:vamp-plugin-sdk loreto$ echo $'\360\237\215\272'

http://i.stack.imgur.com/ff3kp.png

here获得iOS框架分发并添加

之后

-I / Users / loreto / Projects / AUDIO / LIBS / boost-ios / Dist / boost.framework / Headers /

我有同样的错误......呃,我想我在这里错过了标准的C ++库!

macbookproloreto:Headers loreto$ locate libc++.dylib | grep iPhoneOS7.0
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/libc++.dylib

宾果!

所以

-I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/libc++.dylib

再次出错(doh)!

没有成功的尝试

    -I/usr/lib/libstdc++.dylib
   -lstdc++

坚持一个非常简单的链接问题。

再次

macbookproloreto:vamp-plugin-sdk loreto$ echo $'\360\237\215\272'

http://i.stack.imgur.com/ff3kp.png

错误中最有趣的部分是第一个正在编译的静态库:

make -f build/osx/Makefile.osx

c++ -o qm-vamp-plugins.a g2cstubs.o plugins/AdaptiveSpectrogram.o plugins/BarBeatTrack.o plugins/BeatTrack.o plugins/DWT.o plugins/OnsetDetect.o plugins/ChromagramPlugin.o plugins/ConstantQSpectrogram.o plugins/KeyDetect.o plugins/MFCCPlugin.o plugins/SegmenterPlugin.o plugins/SimilarityPlugin.o plugins/TonalChangeDetect.o plugins/Transcription.o libmain.o -L../qm-dsp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -arch armv7 -lqm-dsp ../vamp-plugin-sdk/libvamp-sdk.a -framework Accelerate -lpthread
Undefined symbols for architecture armv7:
  "std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const", referenced from:
      _VampPlugin::Vamp::RealTime::toString() const in libvamp-sdk.a(RealTime.o)
      _VampPlugin::Vamp::RealTime::toText(bool) const in libvamp-sdk.a(RealTime.o)
  "std::basic_ios<char, std::char_traits<char> >::widen(char) const", referenced from:
      _VampPlugin::Vamp::PluginAdapterBase::Impl::getDescriptor() in libvamp-sdk.a(PluginAdapter.o)

在这里,我们可以看到编译的静态库之一不包含正确的体系结构。

我这里有两个静态库:

lqm-dsp ../vamp-plugin-sdk/libvamp-sdk.a

如果我运行otool,我可以看到两者的cpu时间都是ARM7:

macbookproloreto:qm-vamp-plugins loreto$ otool -hv ../vamp-plugin-sdk/libvamp-sdk.a
Archive : ../vamp-plugin-sdk/libvamp-sdk.a
../vamp-plugin-sdk/libvamp-sdk.a(PluginAdapter.o):
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
   MH_MAGIC     ARM         V7  0x00      OBJECT     4       1128 SUBSECTIONS_VIA_SYMBOLS

那么Developer / SDKs / iPhoneOS7.0.sdk / usr / lib / libc ++。dylib是什么问题?

1 个答案:

答案 0 :(得分:2)

尝试在代码中注释标准库的用法。

它可能只用于调试。