i followed script on ( How do I link third party libraries like fftw3 and sndfile to an iPhone project in Xcode? )
but i got an Error. firstly by configuration :
./configure --host=arm-apple-darwin --target=arm-apple-darwin
--enable-float --enable-neon .... checking whether C compiler accepts -march=armv7 -mfpu=neon... no configure: error: Need a compiler with support for -march=armv7 -mfpu=neon
and at the end by copying the ARM library to a temporary location :
lipo -arch armv7 $RESULT_DIR/libfftw3f_armv7.a -arch armv7s
$RESULT_DIR/libfftw3f_armv7s.a -arch i386 $RESULT_DIR/libfftw3f_i386.a
-arch x86_64 $RESULT_DIR/libfftw3f_x86_64.a -arch arm64 $RESULT_DIR/libfftw3f_arm64.a -create -output $RESULT_DIR/libfftw3f.a
lipo: unknown architecture specification flag: arm64 in specifying
input file -arch arm64 ios-library/libfftw3f_arm64.a
lipo: known
architecture flags are: any little big ppc64 x86_64 ppc970-64 ppc i386
m68k hppa sparc m88k i860 veo arm ppc601 ppc603 ppc603e ppc603ev
ppc604 ppc604e ppc750 ppc7400 ppc7450 ppc970 i486 i486SX pentium i586
pentpro i686 pentIIm3 pentIIm5 pentium4 m68030 m68040 hppa7100LC veo1
veo2 veo3 veo4 armv4t armv5 xscale armv6 armv6m armv7 armv7f armv7s
armv7k armv7m armv7em
lipo: Usage: lipo [input_file] ... [-arch
input_file] ... [-info] [-detailed_info] [-output output_file]
[-create] [-arch_blank ] [-thin ] [-remove ] ... [-extract ] ...
[-extract_family ] ... [-verify_arch ...] [-replace ] ...
i am using the gcc49 and Mac OS X 10.9.2, iOS 7.1. any idea ? thanks
by First Error, the configure should be like this:
./configure --host=arm-apple-darwin --target=arm-apple-darwin --enable-float
( without --enable-neon )
and the second Error, its because the libraries are all from the arch x86_64. they should have the right architecture ( libfftw3f_i386.a should have the arch. i386.a and libfftw3f_armv7s.a the arch. armv7s.a and so on )
i could make the right library for FFTW by using macports (or u can use homebrew) to install a universal build of the library for use with OpenFrameworks.
type this into a terminal window:
sudo port install fftw-3 +universal
the port install command will place the fftw3.h header file in your_HD/opt/local/include folder, and the libfftw3.a library in your_HD/opt/local/lib folder. To use the library in your OF project, add these two files to your project via the menu option Project -> Add to project...
thanks for every help and special thanks #Adam Freeman
Related
I'm trying to build a universal binary of ffmpeg on MacOS, by compiling it twice (for arm64 and x86_64) and then using the lipo tool to combine the resulting binaries. I'm on an M1 Mac, so uname -m returns arm64 on my machine.
When running the configure script like so:
./configure --arch=x86_64
It outputs:
install prefix /usr/local
source path .
C compiler gcc
C library
ARCH c (generic)
...
And after running make, inspecting the built binaries with lipo -archs reveals that it's building them for arm64.
The result is the same if I add --enable-crosscompile to the configure call.
Based on this post, I also tried --arch=x86, but that had the exact same result, configure script displayed arch as c (generic) and inspecting artefacts with lipo shows they are built for arm64 architecture.
Does anyone have any ideas? Why is the configure script just refusing to build for x86_64?
You can speify -cc to make clang compile x86_64 binary.
Try:
./configure --enable-cross-compile --prefix=./install_x86_64 --arch=x86_64 --cc='clang -arch x86_64'
Note: don't forget to clear the outdated files by
make distclean
By the way, I have successfully built universal binrary of FFmpeg, you can refer to my build scripts. make_compile.py compile both x86_64 and arm64 binraries, and make_universal.py use lipo to generate universal binrary.
Reference
https://ffmpeg.org/platform.html
https://github.com/FFmpeg/gas-preprocessor
I built FFTW on my Apple m1 computer. When I run lipo -info libfftw3.a (which is located in .libs/libfftw3.a). It says it is of architecture ARM64.
In my Xcode I set the build target to 10.11, for backward compatibility.
Now when I add the FFTW library into my Xcode project, it complains:
The linked library 'libfftw3.a' is missing one or more architectures
required by this target: x86_64.
How can I solve this? Do I need to build the library in an Intel device and create a universal library with these two libraries together (using lipo) or what's the right way to solve this?
You can configure it also with this line and it will build x86_64 & arm64 binary.
./configure CFLAGS="-arch arm64 -arch x86_64 -mmacosx-version-min=11.0"
In order to build a static library for both Intel and Apple silicon archictures, I need to build FFTW for both arch individually and then make an universal library. Here is how I do it.
Go to FFTW root folder
Build for Intel arch
./configure --prefix=/path/to/build/folder/lib-intel CFLAGS="-arch x86_64 -mmacosx-version-min=10.11”
make
make install
Build for arm64
./configure --prefix=/path/to/build/folder/lib-arm64 CFLAGS="-mmacosx-version-min=10.11”
make
make install
Make an universal build
lipo -create path/to/build/folder/lib-intel/libfftw3.a path/to/build/folder/lib-intel/libfftw3.a -output libfftw3_universal.a
Include libfftw3_universal.a in the Xcode project
I'm trying to disassemble openSSL that I've built for iOS targeting arm64 architecture with objdump (from GNU binutil) giving it following options:
./objdump openssl -f (file headers), -t (symbol table), and -h (section headers)
but getting following error:
BFD: bfd_mach_o_scan: unknown architecture 0x100000c/0x0
objdump: ./openssl: File format not recognized
TARGET:
BFD: bfd_mach_o_scan: unknown architecture 0x100000c/0x0
The objdump -v 2.21.1 that I've built with following options:
./configure CC="gcc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -arch i386" CXX="g++ -arch i386" -disable-werror -enable-install-libiberty -enable-targets=arm-eabi
was working fine with all arm 32-bit architectures but failed to disassemble arm64.
Does anyone know how to build objdump to allow calling:
./objdump openssl -f (file headers), -t (symbol table), and -h (section headers)
for binary that was build targeting arm64?
Thanks in advance
The objdump you're using doesn't know about the arm64 arch. 0x100000c/0x0 is the cputype (CPU_TYPE_ARM64) and cpusubtype CPU_SUBTYPE_ARM64_ALL.
Why use objdump? The otool(1) program works well and is included in the Xcode developer tools / command line tools package. The command line options are a little different but one look at the man page will make it clear how to use it.
This may be a very silly question, but I'm new to developing on Macs and am having a hard time with the universal binaries.
I've got an application that I'm compiling in QT Creator, which according to lipo is producing i386 architecture outputs. As I understand it, that means it is producing Mac OS X 32 bit outputs.
The application depends on two external libraries. One of these libraries I'm compiling by calling ./config first, and then make. ./config states that it is "Configured for darwin-i386-cc". However, after running make, and calling lipo on the result, the architecture is reported as x86_64.
Similarly, I have another external library. That one has no configure script, and I compile it simply by calling make. The output from this one too is x86_64.
How can I compile these two external libraries so that they produce something compatible with my application's i386 output? Better yet, how can I compile these two external libraries to produce universal libraries so I can produce a universal binary from my application that works on both 32 and 64 bit?
Also, based on the current state of the Mac world, are there any other platforms that I should be expected to target to create a proper, user-friendly Mac OS X universal binary?
Finally got it working.
In order to control the architecture of the target, I manually went in and edited the Makefiles.
For one of them, I added to the end of the line that starts with CFLAGS: -arch i386 -arch x86_64 -arch ppc
This produced a universal binary.
For the other, when I did the same thing, the compile would error out. I had to cycle through and only put one arch at a time, and then after I produced all three, I called lipo on them with the -create flag to create a universal binary.
for ./configure, you can use this:
./configure CFLAGS="-arch i386 -arch x86_64" CXXFLAGS="-arch i386 -arch x86_64" LDFLAGS="-arch i386 -arch x86_64" --disable-dependency-tracking
--disable-dependency-tracking is important or gcc/g++ will refuse to compile code.
I can't answer the main part of your question, because I always use Xcode rather than make. But as for that last part, if you support OS versions earlier than 10.6, you may need to compile for PowerPC (arch. code "ppc") as well.
I have some dylibs to load from python with ctypes. I can load libbass.dylib without problem, but I can't load the self-compiled libmp3lame.dylib. Here is the error I get.
OSError: dlopen(libmp3lame.dylib, 6):
no suitable image found. Did find:
libmp3lame.dylib: mach-o, but wrong
architecture
Then, I inspect the file type of those libs. Here is the result of libbass.dylib:
libbass.dylib: Mach-O universal binary with 2 architectures
libbass.dylib (for architecture i386): Mach-O dynamically linked shared library i386
libbass.dylib (for architecture ppc): Mach-O dynamically linked shared library ppc
And here is the self-compiled one:
libmp3lame.dylib: Mach-O 64-bit dynamically linked shared library x86_64
I did compile the lame library with the install instructions:
./configure
make
make install
I'm new to mac system, here comes the problem: how to build the libmp3lame.dylib so that it supports different architecture I want?
Thanks.
Just run:
CFLAGS="-arch i386 -arch x86_64 -arch pcc" ./configure
For further information, see http://developer.apple.com/library/mac/#technotes/tn2005/tn2137.html