gpt4 book ai didi

ios - 如何将VAMP插件编译到iOS ARMV7

转载 作者:可可西里 更新时间:2023-11-01 02:58:53 25 4
gpt4 key购买 nike

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

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

女王市场大学(Queen Mart University)很好地解释了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

当然,这些静态库的目标是arch 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,Apple自iOS 4.0起在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/错过了tranforms文件夹-天哪!

另一个错误:
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

好的,现在的错误是体系结构 undefined symbol 错误:请仔细阅读 here的要旨
喜欢:
  "std::cerr", referenced from:
"typeinfo for std::istream", referenced from:
"std::ostream::put(char)""
std::ostream::operator<<(int)",

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

因此,我需要 boost 功能,针对iOS进行编译,然后将其包含在Makefile中,它应该可以工作,不是吗?这可能需要很长时间...

所以现在就这样做
macbookproloreto:vamp-plugin-sdk loreto$ echo $'\360\237\215\272'

here获得作为iOS框架分发的 boost 功能并添加后

-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'

该错误最有趣的部分是正在编译的第一个静态库:
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有什么问题?

最佳答案

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

它可能仅用于调试。

关于ios - 如何将VAMP插件编译到iOS ARMV7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19439407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com