Cruisers Forum
 


Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 20-07-2023, 00:53   #1
Registered User

Join Date: Sep 2014
Posts: 16
Compiling for Apple Silicon

Hi,

I understand there is no official support for Apple Silicon universal binary that would allow OpenCPN to run natively on the M1 and M2 equipped macs at this date, but at the same time the developer manual hints of such ("The bellow instructions concentrate on the official x86 build, but should be mostly valid on ARM based systems as well.")

I did an naive attempt to build on my Macbook Air equipped with an M1 processor, but it ultimately failed compiling with error message: CMake Error at CMakeLists.txt:2617 (find_library):
Could not find MPG123 using the following names: mpg123


Just wondering if anyone else has attempted to compile OpenCPN as a universal binary for mac before and if so - did you take notes of the necessary steps? Would be very interesting to see the performance boost gained by not running through the Rosetta emulation layer
moyd is offline   Reply With Quote
Old 20-07-2023, 05:47   #2
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,234
Re: Compiling for Apple Silicon

The issue you see is caused by Homebrew on ARM using /opt/homebrew/ instead of /usr/local and should be pretty straight forward to address.
The performance gain will be pretty much unnoticeable I'm afraid.
nohal is offline   Reply With Quote
Old 21-07-2023, 05:04   #3
Registered User

Join Date: Sep 2014
Posts: 16
Re: Compiling for Apple Silicon

Thanks.. I was able to get around this and a couple other quirks and it compiled successfully for arm64.

I feel its faster/smoother while zooming/panning (CM93) But it could be some kind of confirmation bias setting in

It was a fun exercise anyways
moyd is offline   Reply With Quote
Old 21-07-2023, 06:48   #4
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,465
Re: Compiling for Apple Silicon

moyd...
Would interested in details of how you built for Apple M2 silicon, for reference.


Thanks
Dave
bdbcat is offline   Reply With Quote
Old 21-07-2023, 08:28   #5
Registered User

Join Date: Aug 2019
Location: New England
Boat: Building myself... FTW
Posts: 183
Re: Compiling for Apple Silicon

Quote:
Originally Posted by nohal View Post
The issue you see is caused by Homebrew on ARM using /opt/homebrew/ instead of /usr/local and should be pretty straight forward to address.
The performance gain will be pretty much unnoticeable I'm afraid.
Does symlinking /opt/homebrew/ to /usr/local/ work?

Is anyone interested in a macports port file?
bdgWesternMass is offline   Reply With Quote
Old 21-07-2023, 09:13   #6
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,234
Re: Compiling for Apple Silicon

Quote:
Originally Posted by bdgWesternMass View Post
Does symlinking /opt/homebrew/ to /usr/local/ work?
Not really, there is reason why they use /opt/homebrew on ARM. The proper solution we need to implement is to adjust the cmake hints for ARM arch when building for macOS. Not too much work, but has to be done.
nohal is offline   Reply With Quote
Old 21-07-2023, 10:10   #7
Registered User

Join Date: Aug 2019
Location: New England
Boat: Building myself... FTW
Posts: 183
Re: Compiling for Apple Silicon

Quote:
Originally Posted by nohal View Post
Not really, there is reason why they use /opt/homebrew on ARM. The proper solution we need to implement is to adjust the cmake hints for ARM arch when building for macOS. Not too much work, but has to be done.
I don't understand that answer. There is always reason that path is used and a symlink is always the workaround?


I don't actually need an explanation. I just thought it was strange response.
bdgWesternMass is offline   Reply With Quote
Old 21-07-2023, 10:17   #8
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,234
Re: Compiling for Apple Silicon

If you are interested why Homebrew works the way it does, read for example https://apple.stackexchange.com/ques...e-silicon-macs
nohal is offline   Reply With Quote
Old 22-07-2023, 13:55   #9
Registered User

Join Date: Sep 2014
Posts: 16
Re: Compiling for Apple Silicon

Quote:
Originally Posted by bdbcat View Post
moyd...
Would interested in details of how you built for Apple M2 silicon, for reference.


Thanks
Dave
Well I did not document much, but in general follow the developer manual here: https://opencpn-manuals.github.io/ma...v/mac-osx.html

Install homebrew if you have not already
Install dependencies (I also installed wxwidgets via homebrew)
Clone git repository

I had to change line 2619 in CMakeList.txt to:

if (APPLE)
find_library(
MPG123 NAMES mpg123
PATHS /opt/homebrew/lib/mpg123 #NO_DEFAULT_PATH
REQUIRED
)

from there its back to the docs again so mkdir bulld && cd build && configure .. && make -j4


Please note that I only made it compile, launched it once and played around with it (on land) for a total of 10 minutes or so
moyd is offline   Reply With Quote
Old 30-05-2024, 13:23   #10
Registered User

Join Date: Dec 2017
Location: Circumnavigating - in phases
Boat: Feltz, One Off, 40 ft
Posts: 43
Re: Compiling for Apple Silicon

Interesting conversation. Just tried to setup a development environment on Silicon M3 Sonoma 14.5. Currently the build script generates (too many) errors like:

In file included from /Users/wernertoonk/sources/OpenCPN/model/src/peer_client.cpp:44:
/Users/wernertoonk/sources/OpenCPN/model/include/model/rest_server.h:225:38: error: 'path' is unavailable: introduced in macOS 10.15
virtual bool StartServer(const fs:ath& certificate_location) = 0;

Online I found some (very) recent marks about similar errors, though no solution yet. Perhaps anyone here ran into this before?
wernertoonk is offline   Reply With Quote
Old 30-05-2024, 13:29   #11
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,234
Re: Compiling for Apple Silicon

This thread is outdated, OpenCPN builds just fine on Apple Silicon nowadays, I do it all the time. Just follow the build instructions from https://opencpn-manuals.github.io/ma...v/mac-osx.html
nohal is offline   Reply With Quote
Old 30-05-2024, 14:23   #12
Registered User

Join Date: Dec 2017
Location: Circumnavigating - in phases
Boat: Feltz, One Off, 40 ft
Posts: 43
Re: Compiling for Apple Silicon

Thx Nohal.

I allready found the instructions and followed them quite precisely.
Then while running ci/generic-build-macos.sh I do get the errors as indicated.

Must be some setting ... though I can't figure out which one yet. Will give it another try tomorrow. Bedtime in this timezone.
wernertoonk is offline   Reply With Quote
Old 30-05-2024, 14:32   #13
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,234
Re: Compiling for Apple Silicon

What you see is related to std::filesystem which was missing from macOS standard C++ library before 10.15. That of course makes no sense on Apple Silicon as these ancient versions of macOS existed only for Intel.
The only way I can imagine you could get there is having your environment set to try to build for a very old deployment target. This is usually done using the MACOSX_DEPLOYMENT_TARGET environment variable.
Also, in case you did not start with a clean table, make sure to completely wipe your build directory, which might contain some cached stuff cmake is reusing in case you had it around for some time.
nohal is offline   Reply With Quote
Old 30-05-2024, 14:36   #14
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,234
Re: Compiling for Apple Silicon

You can compare the output you get locally to the log of the ARM macOS 14 CI build we are running - https://github.com/OpenCPN/OpenCPN/a...ob/25584430625
nohal is offline   Reply With Quote
Old 30-05-2024, 15:22   #15
Registered User

Join Date: Dec 2017
Location: Circumnavigating - in phases
Boat: Feltz, One Off, 40 ft
Posts: 43
Re: Compiling for Apple Silicon

Well ... obviously didn't go to sleep and tried it all again. Removed homebrew (it's a new machine) and started all over. Still the same errors: : 'path' is unavailable: introduced in macOS 10.15 ...

I might be misreading / misinterpreting some of the instructions here. If anyone has a clue ... please.
wernertoonk is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Advertise Here


All times are GMT -7. The time now is 12:23.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.