How can I strip symbols from my executable when using Clang and the LLVM ELF ld.LLD linker? - hyperlink

I am building with Clang 9.0.0 and linking with the ld.lld linker
clang++.exe -Wall -fexceptions -m64 -O3 -Xclang -flto-visibility-public-std -std=c++2a -flto=thin -c
I:\Cpp\hello_boost\hello_codeblocks_world\hello_codeblocks_world.cpp -o obj\release\hello_codeblocks_world.o
clang++.exe -o bin\release\hello_codeblocks_world.exe obj\release\hello_codeblocks_world.o -m64 -fuse-ld=lld --strip-all
but, unlike when using the usual GCC linker LD, this option (--strip-all or -s) is not recognized
clang++: error: unsupported option '--strip-all' (or similarly with -s)
Can anyone suggest what I should be doing to strip symbols?
(My release-mode hello_world.exe size is 15 kb for GC but 230 kB for Clang :-( and this is likely to have some adverse effects for no benefit).
Is this not an option for ld.lld ?
Thanks

You might want to use:
-Xlinker --strip-all
You can use this to supply system-specific linker options that GCC does not recognize (gcc manual)
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

Related

Is it possible to pass an argument to wasm-opt with clang

I'm trying to compile a wasm binary with multivalue and O3, however, I keep getting [wasm-validator error in module] unexpected false: Imported multivalue function requires multivalue [--enable-multivalue].
The current flags that I'm using are --target=wasm32-unknown-unknown-wasm -O3 -nostdlib -funroll-loops -Wall -Wno-comment -mllvm -polly -mmultivalue -Xclang -target-abi -Xclang experimental-mv -ffunction-sections -fdata-sections -flto -s -Wl,--export-dynamic,--allow-undefined,--gc-sections.
No, sadly there is no way (today) to modify the wasm-opt command line that clang uses.
This seems like a bug in llvm and really the target-features section of binary should contains multivalue, which should then enable it automatically in wasm-opt. Could you open an llvm bug about this?
For now your best bet might be to run clang without wasm-opt in your PATH.

Build openssl for arm64 iOS simulator

Description
I'm trying build iphonesimulator-only targeted library witn architecture arm64, but linking step failed with error:
${LDCMD:-/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang} -O3 -fvisibility=hidden -miphoneos-version-min=9.0 -fembed-bitcode -fPIC -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk -L. -Wl,-search_paths_first \
-o apps/openssl apps/asn1pars.o apps/ca.o apps/ciphers.o apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o apps/verify.o apps/version.o apps/x509.o \
apps/libapps.a -lssl -lcrypto
ld: building for iOS, but linking in .tbd file (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/lib/libSystem.tbd) built for iOS Simulator, file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/lib/libSystem.tbd' for architecture arm64
Configuraton command:
./Configure iossimulator-xcrun threads no-shared "-fvisibility=hidden -miphoneos-version-min=9.0 -fembed-bitcode -fPIC" no-asm no-hw no-async --prefix=/Users/macosuser/Build/OpenSSL/Install "-arch arm64" "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk"
Configuring OpenSSL version 1.1.1j (0x101010afL) for iossimulator-xcrun
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
Build commands look like this:
...
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -I. -Iinclude -Iapps -O3 -fvisibility=hidden -miphoneos-version-min=9.0 -fembed-bitcode -fPIC -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk -D_REENTRANT -DNDEBUG -MMD -MF apps/x509.d.tmp -MT apps/x509.o -c -o apps/x509.o apps/x509.c
...
Question
I can't figure out why for other architectures (i386, x86_64) the build happens without problems.
Perhaps I am missing some nuance, but I cannot understand which one.
Why do I need this - an application using this library must run on a simulator in a macbook with an M1 processor.
Environment specifications
MacOS 11.4
XCode v12.5
OpenSSL v1.1.1j
Compiler - AppleClang 12.0.5.12050022
Because i'm not an iOS developer, i didn't immediately understand the specifics of building libraries through make for this platform.
The problem was this:
-miphoneos-version-min specifies the deployment target for iOS, but since i am building library for the iOS simulator, me need to use -mios-simulator-version-min.
As a result, the configuration command should look like this:
./Configure iossimulator-xcrun threads no-shared "-fvisibility=hidden -mios-simulator-version-min=9.0 -fembed-bitcode -fPIC" no-asm no-hw no-async --prefix=/Users/macosuser/Build/OpenSSL/Install "-arch arm64" "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk"
If anyone can explain why the -miphoneos-version-min flag works as expected for i386 and x86_64 architectures, i would be grateful.

ld: library not found for -lomp

In macOS Sierra, installation for xgboost with openmp enabled always fails.
From https://xgboost.readthedocs.io/en/latest/build.html,
I've tried:
cp make/config.mk ./config.mk; make -j4
With,
export CC=/usr/local/Cellar/llvm/4.0.0_1/bin/clang
export CXX=/usr/local/Cellar/llvm/4.0.0_1/bin/clang++
export CXX1X=/usr/local/Cellar/llvm/4.0.0_1/bin/clang++
It fails with,
clang-4.0clang-4.0: : warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]warning:
argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
ld: library not found for -lomp
ld: library not found for -lomp
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
llvm support openmp, but it fails with ld: library not found for -lomp
related question
Install xgboost on Mac - ld: library not found
But, clang-omp goes to boneyard, and discontinue with llvm's OpenMP support.
I've drilled down to, (with -v option)
/usr/local/Cellar/llvm/4.0.0_1/bin/clang++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -shared -o lib/libxgboost.so build/learner.o build/logging.o build/c_api/c_api.o build/c_api/c_api_error.o build/common/common.o build/common/hist_util.o build/data/data.o build/data/simple_csr_source.o build/data/simple_dmatrix.o build/data/sparse_page_dmatrix.o build/data/sparse_page_raw_format.o build/data/sparse_page_source.o build/data/sparse_page_writer.o build/gbm/gblinear.o build/gbm/gbm.o build/gbm/gbtree.o build/metric/elementwise_metric.o build/metric/metric.o build/metric/multiclass_metric.o build/metric/rank_metric.o build/objective/multiclass_obj.o build/objective/objective.o build/objective/rank_obj.o build/objective/regression_obj.o build/tree/tree_model.o build/tree/tree_updater.o build/tree/updater_colmaker.o build/tree/updater_fast_hist.o build/tree/updater_histmaker.o build/tree/updater_prune.o build/tree/updater_refresh.o build/tree/updater_skmaker.o build/tree/updater_sync.o dmlc-core/libdmlc.a rabit/lib/librabit.a -pthread -lm -fopenmp
SOLVED
cd /usr/local/lib
ln -s /usr/local/Cellar/llvm/4.0.0_1/lib/libomp.dylib libomp.dylib
llvm installation miss its symbolic link.
In my case I solved adding the following linker flag in addition to -lomp:
-Lpath_to_libomp.dylib_folder
or something like:
-Llib/
In my case I used a version of clang that came with Homebrew's llvm instead of the one that came with the Laptop from the factory, and it worked.

clang -S -emit-llvm and then compile

I want to get exe with clang and llvm with two ways:
clang -O2 1.c -o 1.exe
clang -S -emit-llvm 1.c
llc 1.ll -filetype=obj
link 1.obj -defaultlib: ??? (MSVCRT or libcmt)
but exe files will different and first exe will faster, how to do it equal?
Or how to see what clang use like defaultlib?
hard: windows 64.
You can add the -v flag on your first command line to see the linker invocation clang will use to build your program. As to the first executable being faster, that could be because you didn't pass any optimization flags in your second case.
I don't have a Windows machine handy, but here's some example output from my mac:
$ clang -v -O2 1.c -o 1.exe
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -disable-free -disable-llvm-verifier -main-file-name 1.c -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 236.3 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1 -O2 -fdebug-compilation-dir /Users/carl/Desktop/example -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o /var/folders/mk/0mblc5810cjgs0nylrkjxqbm0000gq/T/1-7ac5d9.o -x c 1.c
clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.3.0
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o 1.exe /var/folders/mk/0mblc5810cjgs0nylrkjxqbm0000gq/T/1-7ac5d9.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a
You can see the link line down at the bottom. Broken down for readability, its:
ld
-demangle
-dynamic
-arch x86_64
-macosx_version_min 10.9.0
-o 1.exe
$(OBJECT_FILE)
-lSystem
libclang_rt.osx.a

How to compile VAMP Plugins to iOS ARMV7

VAMP Plugins by Queen Mary University of London is an amazing collection of BSD licensed software. All these plugins are at the basis of the Sonic Visualizer software
A plug Sdk to build plugins is available as well.
You can build the plugins for OSX / Linux / Win32 targets.
Queen Mart University explain well here the plugin architecture and how to build for different platforms specified above.
A Java version, jVamp is available as well. A Python wrapper also.
But, how to build for the iOS platform ?
So, I tried porting the Makefile to the iOS.
First I changed the file
build/osx/Makefile.osx
in this way:
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
Then build
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
^**
The first issue here is that there is a unsupported architecture.
So the plugins depends on the SDK I had to build that one first:
cd /Users/loreto/Projects/AUDIO/VAMP/vamp-plugin-sdk
make -f build/Makefile.osx
Different errors occurred since I had no OGG/VORBIS library and no LOGG library. So I slightly modified the Makefile.osx removing these dependencies in the HOST_LIB flags. I had to keep libsndfile anyway:
HOST_LIBS = ./libvamp-hostsdk.a -L../10.8/inst/lib -lsndfile -ldl
So I was able to build the static libraries here:
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
Of course these static libs are targeted to arch x86_64 so I need to add armv7 arch:
ARCHFLAGS = -mmacosx-version-min=$(MINVERSION) -arch x86_64 -arch armv7
Then make clean and compile again
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
Type definitions for arm was not found! The problem here is that the right path was
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/arm/_types.h
Ok let's fix this in the Makefile.osx again:
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
then make the static targets:
make -f build/Makefile.osx sdkstatic
Wow it worked! I have a vamp host sdk .a for iOS! (I suppose to have let's say)
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
Ok but let's check with otool, since you never know:
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
Ok, that's the armv7 architecture.
Now, back to the plugins sdk again and change the
build/osx/Makefile.osx
as follows:
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
Ok back again and make:
macbookproloreto:dsp loreto$ make -f build/osx/Makefile.osx
Boom! Another problem:
/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 not found.
But as for Apple Docs here, Apple introduced LAPACK in the Accelerate.frameworks since iOS4.0!
In fact clapack.h is here:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/clapack.h
So let's add this somewhere in the ../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
And now let's make it again, but let me check the arch:
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
Sound good! One level back in the plugins folder now and make
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.
Uhm ok the dsp/ misses the tranforms folder - gosh!
Another error:
clang: error: invalid argument '-install_name qm-vamp-plugins.a' only allowed with '-dynamiclib'
make: *** [qm-vamp-plugins.a] Error 1
Let's fix again the 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
Ok, now the error is architecture undefined symbol errors: to long look at the gist here
like:
"std::cerr", referenced from:
"typeinfo for std::istream", referenced from:
"std::ostream::put(char)""
std::ostream::operator<<(int)",
This reminds me to the boost C++ libraries!
So I need to get boost, compile for iOS then include it in the Makefile and it should work, isn't it ? This could take long...
So do this by now
macbookproloreto:vamp-plugin-sdk loreto$ echo $'\360\237\215\272'
After getting boost as iOS framework distribution from here and adding
-I/Users/loreto/Projects/AUDIO/LIBS/boost-ios/Dist/boost.framework/Headers/
I have the same error...uhm I suppose I'm missing the standard C++ library here!
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
bingo!
So
-I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/libc++.dylib
Error again (doh) !
Tried with no success
-I/usr/lib/libstdc++.dylib
-lstdc++
Stucked on a very simple linking issue.
Again.
macbookproloreto:vamp-plugin-sdk loreto$ echo $'\360\237\215\272'
The most interesting part of the error is the first static library being compiled:
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)
Here we can see that one of the static library compiled does not contain the right architecture.
I have two static libraries here:
lqm-dsp ../vamp-plugin-sdk/libvamp-sdk.a
If I run otool on that I can see that the cpu time is ARM7 for both of them:
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
So what's the matter with Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/libc++.dylib ?
Try commenting in the code the usage of the standard libraries.
It's probably only used for debug.

Resources