I am using macOS 10.15.7 to build a simple hello world C++ program for macOS arm64 architecture (not iOS). I have Xcode 12 installed. I tried the following:
xcodebuild -project TestApp.xcodeproj clean build ARCHS=arm64 EXCLUDED_ARCHS=""
But received the following error:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
#error Unsupported architecture
and similar other errors.
I supposed I can cross-build for upcoming ARM-based macs from my x86_64 mac, but it doesn't seem to work.
The SDK for macOS Big Sur wasn't released as part of the public Xcode 12.0 release, it only contains the SDK for Catalina (macOS 10.15).
To target macOS Big Sur (and macOS on Apple Silicon), you need the beta SDK (Xcode 12.2 beta).
It works fine when I removed the 'EXCLUDED_ARCHS' part.
Related
I have 16" M1 Pro MacBook Pro. The third party C library (.a) was built with Intel Mac and there's absolutely no way to modify the code or rebuild with M1 Mac. The binary is x64 binary.
My project is using C++ and Objective-C++ (.mm) with Xcode. It is targeted for Mac app and not iOS. I want to link the C library to my project.
The linked library 'libkfunc64.a' is missing one or more architectures
required by this target: arm64.
I checked similar question but it didn't work:
Can Xcode on m1 Mac build targeting Intel
What I want to do is to generate an Intel binary. I don't need a M1 binary or hybrid binary - I can run Intel binary on Rosetta 2 on M1 Mac.
I created a console-app with "-arch x86_64" option for LLVM C++ compiler and it worked. But I don't know how to pass that option on Xcode.
Please tell me how to do it. I am using Xcode 13.3.
Xcode - Targets - Build Settings
Architectures (x86_64) or Excluded Architectures(arm64).
I've only tested the opposite.
Arm64 required, no x86_64.
I don't have Xcode installed on my Mac OS 13.6 but I would like to run c++ on vs code. Is there a way to do that without the need for Xcode to be installed? Also, can I run an older version of Xcode and run c++ without problems?
Note: Would be great if someone posted a link for a tutorial.
You may download and install LLVM 13.0.1 for Darwin or a small part of Xcode, Xcode command line tools: xcode-select --install.
Both will result in installing clang++.
I am trying to port a linux project to macOS. However I can't even setup the build environment on an M1 Macbook Air 2020 (Apple silicon). I installed qt-creator, cmake, qt 5.15 and 6.1 using homebrew. I added the qt versions and cmake in the qt-creator settings. When I want to put everything together in the kits tab, I get the error in the title.
Checking the compilers tab, I realized that the autodetected clang compilers are x86 only. So I cloned the x86 clang++ entry and changed the ABI from x64 to arm. This should work I though, since clang++ is a unversial binary as file /usr/bin/clang++ reports
/usr/bin/clang++: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/clang++ (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/clang++ (for architecture arm64e): Mach-O 64-bit executable arm64e
What do I have to do to make Qt Creator able to build universal binaries? Or at least any build at all?
You need to install Qt 6.2 version which brings support for macOS on Apple Silicon. Porting tasks were tracked under this bug report. Currently, Qt5 doesn't support building for M1 chip.
In addition to updating to Qt6.2 you also need to update your Qt Creator version to Qt Creator 6. Alternatively, you can try the build flags below with Qt Creator 5.
As Qt Creator 5 is built as a non-universal binary, it will default to producing x86_64 binaries, regardless of which architecture your machine is. To build for arm64, add -DCMAKE_OSX_ARCHITECTURES=arm64 explicitly to the "Initial CMake parameters" of the project build settings, or QMAKE_APPLE_DEVICE_ARCHS=arm64 to the qmake "Additional arguments" field.
Apple has recently launched Macs based on the Apple silicon processor which is Apples in house arm64 based processor.
I am using pyinstaller 3.4 and Python 2.7.18 to create application for Mac.
I tried on Catalina machine with latest Xcode 12. But pyinstaller creates build only for intel arch.
Is there a way to create build with Apple silicon arm64 target.
I recently installed fortran on my Macbook Pro mid 2011 that is running OS X Yosemite. When I try to compile code, I get this:
gfortran: warning: couldn’t understand kern.osversion ‘14.0.0 ld: library not found for -lcrt1.o collect2: error: ld returned 1 exit status
This is due to the fact that Mac OS X's headers are not C99/C++98 compatible.
See bug 61407 at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61407. That bug report provides a patch.
Try installing Xcode command line tools as described at http://hpc.sourceforge.net
I also installed full gcc binary for Yosemite from http://hpc.sourceforge.net
Seemed to solve this problem.
JTN
Install the 5.0 version of gcc and/or gfortran from http://hpc.sourceforge.net
Works perfectly for OS X Yosemite