Datatable for ARM architecture? - datatable

import datatable as dt
Throws an ImportError:
ImportError: dlopen(miniforge3/lib/python3.9/site-packages/datatable/lib/_datatable.cpython-39-darwin.so, 0x0002): tried: 'miniforge3/lib/python3.9/site-packages/datatable/lib/_datatable.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
Is there an ARM version in development?

This was resolved in https://github.com/h2oai/datatable/issues/3003#issuecomment-866386747
Running lipo -info `which clang++ will return
Architectures in the fat file: /usr/bin/clang++ are: x86_64 arm64e so you need to switch to arm64e only.
To switch to arm64 for compilation, run
env /usr/bin/arch -arm64 /bin/zsh --login
https://vineethbharadwaj.medium.com/m1-mac-switching-terminal-between-x86-64-and-arm64-e45f324184d9 details how to make aliases in your .zshrc for quickly switching between x86 and arm64.

Related

Build FFTW for Apple M1 and the older intel devices

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

Building objdump on osx to allow disassembling arm64 objects

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.

How to link fftw3 in Xcode? (Mac)

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

Library not loaded: /usr/lib/libxslt.1.dylib error loading library after installing with CPAN

I was attempting to install XML::LibXSLT via CPAN, this seemed to work fine, until I attempted to load Google Chrome, or Microsoft Office. I am getting an error launching these programs with the following errors:
Dyld Error Message:
Library not loaded: /usr/lib/libxslt.1.dylib
Referenced from: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks
/DictionaryServices.framework/Versions/A/DictionaryServices
Reason: no suitable image found. Did find:
/usr/lib/libxslt.1.dylib: mach-o, but wrong architecture
/usr/lib/libxslt.1.dylib: mach-o, but wrong architecture
Obviously the problem is the new dylibs that XSLT installed, but these all seem to be X86_64 so I shouldn't be seeing any issues with this, I am running Mac OS X 10.6.8.
When running file /opt/local/lib/libxslt.dylib
I get:
/opt/local/lib/libxslt.dylib: Mach-O 64-bit dynamically linked shared library x86_64
as is the same with the libxslt.1.dylib.
Is there a way to solve this issue, and reinstate the original files that must have been replaced?
Edit: If were to get a copy of these Libraries from another Mac 10.6.8 64 bit and replace my apparantly confused ones with these, would this at least solve the issue of them being all mixed up.
Also running
[/usr/lib]$ ls | grep libxslt gives me :
libxslt 2.dylib
libxslt-plugins
libxslt.1.dylib
libxslt.a
libxslt.dylib
libxslt.la
libxslt.pc
Did you install into or otherwise replace the original Apple-supplied libraries in /usr/lib? You should never do that. Otherwise, you'll likely break other parts of OS X that depend on those libraries. You should restore the original libraries from a backup or reinstall OS X. If you want newer versions, you should install them elsewhere, like in /usr/local/lib. Or better yet you should be using a third-party package manager, like Homebrew or MacPorts; in fact, you appear to be using MacPorts, judging from the /opt/local/lib path. Use that and don't alter system files in /usr (other than /usr/local) or /System/Library.
This may be relevant: How to compile universal binaries on Mac OS X.
I ran into this same issue where I had re-compiled libxslt and libxml to support python bindings, then started getting the /usr/lib/libxslt.1.dylib: mach-o, but wrong architecture error and an immediate crash when starting some apps (Specifically Synergy, which is a 32-bit/i386 app)
I solved this by recompiling libxml2 and libxslt using these configure options:
./configure CFLAGS="-arch i386 -arch x86_64" \
CXXFLAGS="-arch i386 -arch x86_64" \
LDFLAGS="-arch i386 -arch x86_64" \
--disable-dependency-tracking
Now libxml2 and libxslt libraries are properly showing as universal binaries:
$ file /usr/local/lib/libxslt.1.dylib /usr/local/lib/libxslt.1.dylib: Mach-O universal binary with 2 architectures
/usr/local/lib/libxslt.1.dylib (for architecture i386): Mach-O dynamically linked shared library i386
/usr/local/lib/libxslt.1.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
$ file /usr/local/lib/libxml2.2.dylib
/usr/local/lib/libxml2.2.dylib: Mach-O universal binary with 2 architectures
/usr/local/lib/libxml2.2.dylib (for architecture i386): Mach-O dynamically linked shared library i386
/usr/local/lib/libxml2.2.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64

How to build mach-0 for different architectures?

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

Resources