How to build a Go app that can cross-macOS-version? - macos

Here is my recently created macOS app: https://github.com/evillt/macmineable-release
and here is my facing issue: https://github.com/evillt/macmineable-release/issues/18
I built the app on my machine it can run normally on any BigSur device, even M1 devices, but can not run on Catalina(10.15).
So what I want is to build a version that can run on multi-macOS-version with a single app.
Huge thanks for any suggestions!
update
My device is MacBook Pro 2015, Intel I5 chip, Big Sur 11.5.2.
I build this app on my device, it can run normally on:
My device
MacBook 12-inch Big Sur 11.0
Other M1 devices (Big Sur 11.0 or above)
But can not run on MacBook Pro Intel I7 Catalina 10.15.7. The issue here.
That is all I know.

You need to change the CC compile go uses during your builds.
go env CC
clang
which most likely uses the version in /usr/bin/clang
if you have Xcode installed - or really just the Command Line Tools you can see a variety of versions for the last few major releases e.g.:
$ find /Library/Developer/CommandLineTools -name clang
/Library/Developer/CommandLineTools/usr/bin/clang
/Library/Developer/CommandLineTools/usr/lib/clang
/Library/Developer/CommandLineTools/usr/lib/swift/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/A/lib/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/A/lib/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/A/lib/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang
so to build against an older SDK like MaxOSX10.15, set CC to the explicit version you need for your go build like so:
CC=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang go build

I have good experience building as a Unix executable and packaging as a Mac app, by using the instructions manual at
https://medium.com/#mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
build Unix exec file
go build -o bin/{program} {program}
Packaging the application on macOS (Big Sur) and installing it on macOS (High Sierra) was successful.

Related

Installing OMNeT++ on M1 MacBook

Followed instructions given in https://doc.omnetpp.org/omnetpp/InstallGuide.pdf
OMNeT++ Version - omnetpp-5.6.2
Device - MacBook Air M1 (MacOS Big Sur Version 11.4)
Encountered the following problems.
$. setenv -> didn't work (worked after replacing "." with "source")
$./configure -> gives the following error.
configure: error: Qtenv cannot find qmake -- maybe it is not in the PATH or has some exotic name (tested names were: qmake qmake-qt5 qmake5) - disabling Qtenv. You can try setting the QT_PATH variable in configure.user to a valid location
$ make -> gives the following error.
Makefile:54: Makefile.inc: No such file or directory
make: *** No rule to make target `Makefile.inc'. Stop.
Is it possible to get OMNeT++ working on M1 Macs? Any help would be greatly appreciated.
Thanks in advance.
There is no native support for M1 processors, especially because omnet++ 5.6 was released way before the M1 release, but you can run omnet with Rosetta2 in x86_64 mode. You would still get pretty decent performance. With x86_64 emulation I measured similar performance like on my last year high end AMD laptop. Native mode would give you a 25% boost compared to that.
To turn on the emulation for a shell window, start a new shell with
$ arch -x86_64 /bin/zsh --login
and then continue in that shell with
$ source setenv
$ ./configure
$ make
run everything from that shell window (as usual).
NOTE: OMNeT++ 5.6 relies on the system-wide installed JRE to run the IDE. That may NOT be present on your system if you are running on ARM. OMNeT++ 6 and 5.7 comes with a built-in private JRE, so the IDE should work with those versions also in intel emulation mode.
ps: OMNeT++ 6 may get native M1 support (this depends on the availability of some dependencies (JavaVM, Qt etc.). I'm also considering an ARM based docker image, that would allow running at native performance (as long as you have an XServer installed).

Is it possible to run Xcode11 in macOS Big Sur?

I get following error:
The version of Xcode installed on this Mac is not compatible with macOS Big Sur. Download the latest version for free from the App Store.
This is on a M1 Mac (ARM, Apple Silicon).
I was able to bypass the macOS denial-prompt, to run Xcode 11.7 on Big Sur (11.0.1) on my M1 MacBook Air, by running the executable directly from Terminal– for example:
/Applications/Xcode.app/Contents/MacOS/Xcode
I just needed to compile, archive, and export a specific app, and it at least worked for that.

Desperately trying to build open source tools (octave) on a Mac 10.6 Snow Leopard (involves Xcode, gcc, fink)

The ironic thing is that all this used to work on my Mac, but Apple no longer supports 10.5.8, so I was forced to update to Snow Leopard, 10.6. And everything broke (thank you Apple).
On the surface, it seems simple. Build an open source package like octave under Snow Leopard (Mac OS X 10.6)
Apple has made this difficult, to say the least. They no longer download XCode for older operating systems unless you are a paid developer. My Macbook pro 2.16Ghz cannot load Lion, so that option is not available.
My old fink doesn't work because it was old. In order to build a new one, I need Xcode 3.2, which I can't get (see above).
I downloaded a free gcc 4.2, and it works fine.
So in order to try to build octave, it's the old style gnu install:
./configure
make
make install
./configure fails because there is no fortran installed. That's a special case because the install of gcc didn't include fortran. So a fallback would be building a complete gcc which I have done in the past.
downloaded gcc 4.9:
gcc-4.9-20130728
inside, gcc49
gcc can't build because it needs the three subsidiary packages gmp, mpfr and mpc
I am now trying to build these, so that I can bootstrap a complete gcc build, but in the meantime, is there any simpler way to bootstrap these things? I find it hard to understand why no binaries are available for:
fink
octave
which would solve part of my current problems.
You can still get XCode. You just have to be registered on Apple Developer, but you do not have to pay for the license. You then download it through the Mac App store, or you can get a link that opens it in the App store here. Finally, you have to install the command line tools from within Xcode. These can be found under the Components tab of the Download Preferences panel.
Let me know if that does not help. My iMac running 10.6 is currently in for repairs, so I am on my 10.7 laptop and cannot test all the specifics yet.

How to use g++ in terminal in mac?

I've installed Xcode and I can compile .cpp files in Xcode. However, I wanna use g++ in Terminal but command not found: g++ now.
My OS is Mountain Lion Xcode version is 4.4.
You need to download and install the Command Line Tools for OSX Mountain Lion from Apple Developer (you'll need a Apple ID which is free to sign up for). This will install GCC (including g++) so you can build direct from Terminal
The exact package currently is Command Line Tools (OS X Mountain Lion) for Xcode - September 2012
Description about the package from Apple:
This package enables UNIX-style development via Terminal by installing command line developer tools, as well as Mac OS X SDK frameworks and headers. Many useful tools are included, such as the Apple LLVM compiler, linker, and Make. If you use Xcode, these tools are also embedded within the Xcode IDE, and can be installed on your system using the Downloads preferences pane within Xcode 4.5.
Note that when you run "g++" with Xcode 4.5 installed, you're picking up llvm-g++-4.2 (based on gcc 4.2.1) -- a provided, but no longer supported compiler on the platform. I'd strongly recommend using clang++ instead, the actively supported/developed compiler on the platform.

Installing openCV on Lion OS 10.7.4 Xcode 4.3.2

I'm trying to install openCV on university's iMac,
but the problem is our university's network is so strict.
and I couldn't install openCV using MacPorts.
I tried google to look for a way to install but it all failed
i guess because it is kind of old ways and because my network is so strict.
So if anybody knows a way that I can download a ready framework with how to use it inside
Xcode. or at least a framework with how to install it to work with Xcode.
or a way to download from the source and compile it then install it in Xcode
please.
Because I tried the cmake way and I still have no luck to get it work.
thanks in advance.
sources I used:
http://salemsayed.me/?p=240
http://opencv.willowgarage.com/wiki/InstallGuide
http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port
http://www.ient.rwth-aachen.de/cms/software/opencv/
I'm using Lion + Xcode 4.x branch, with OpenCV svn trunk. Everything works fine. You have to install cmake first, then get the code from the svn following the instructions at http://code.opencv.org . The compilation process worked fine for me for all the core modules + the Qt module + the GPU module + TBB acceleration.
The instructions are the same as the Linux platform.
After setting up cmake configuration in a terminal (using ccmake for a more interactive tool),
I set the architecture to x86_64 (on my MBP Core 2 Duo), the target directory to /usr/local/(the default), and I have Intel TBB installed in /usr/local/.
Cmake generates the makefiles for you, so you just have to type make -j2 to compile, then sudo make install. If you're working on a workstation, then you have more CPU power, and you can replace the value 2 by more, e.g. 8.

Resources