Open DannyCork opened 3 years ago
+1000 this
+2000 on this.
more than being "nice to have", barrier 2.3.3 release will not start on my m1 macbook air. does it work at all for others?
more than being "nice to have", barrier 2.3.3 release will not start on my m1 macbook air. does it work at all for others?
... sorry for the distraction: this was a configuration + gatekeeper problem. i've got it running now on my m1 laptop.
I believe https://github.com/Homebrew/brew/issues/7857#issuecomment-748170325 may resolve the qt
dependency used in the build_dist.sh.in for macOS. I might have some time to take a crack at building it on my m1 Mac mini over the holidays. Running on Rosetta 2 seems to be fine so far between my MacOS and Windows machines however.
I just tried building from source on an M1 but it fails after some time.
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [bin/barrier] Error 1 make[1]: [src/gui/CMakeFiles/barrier.dir/all] Error 2 make: *** [all] Error 2
I have been using barrier mostly fine between windows (server) and mini m1 (client), but the CPU usage spikes sometimes up to 25% and I get severe lag if the CPU is otherwise stressed.
I just built 2.3.3 on my M1 mac. You need to fix the OPENSSL_ROOT definition in CMakeLists.txt. Here's a diff that removes the hard-coded path for homebrew:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c56b30be..7c2b461b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -329,9 +329,8 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
${OPENSSL_ROOT}/lib/libcrypto.a
z
)
- elseif (IS_DIRECTORY /usr/local/opt/openssl AND BREW_PROGRAM)
- # brew
- set (OPENSSL_ROOT /usr/local/opt/openssl)
+ elseif (BREW_PROGRAM)
+ exec_program(brew ARGS "--prefix openssl" OUTPUT_VARIABLE OPENSSL_ROOT)
include_directories (BEFORE SYSTEM ${OPENSSL_ROOT}/include)
Also, I modified clean_build.sh to target 11.1 instead of 10.9. Not sure if it matters; I had just changed that prior to discovering the root cause of the OPENSSL issue, and never bothered changing it back, since I'm just building for my personal M1 MacBook, which obviously does not run MacOS 10.9.
diff --git a/clean_build.sh b/clean_build.sh
index 3a92d8b9..9cdaa6dc 100755
--- a/clean_build.sh
+++ b/clean_build.sh
@@ -14,7 +14,7 @@ if [ "$(uname)" = "Darwin" ]; then
# OSX needs a lot of extra help, poor thing
# run the osx_environment.sh script to fix paths
. ./osx_environment.sh
- B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 $B_CMAKE_FLAGS"
+ B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=11.1 $B_CMAKE_FLAGS"
fi
# allow local customizations to build environment
[ -r ./build_env.sh ] && . ./build_env.sh
@@ -28,5 +28,6 @@ mkdir build || exit 1
cd build || exit 1
echo Starting Barrier $B_BUILD_TYPE build...
$B_CMAKE $B_CMAKE_FLAGS .. || exit 1
+export VERBOSE=1
make || exit 1
echo "Build completed successfully"
Also, I modified clean_build.sh to target 11.1 instead of 10.9. Not sure if it matters; I had just changed that prior to discovering the root cause of the OPENSSL issue, and never bothered changing it back, since I'm just building for my personal M1 MacBook, which obviously does not run MacOS 10.9.
I was able to build barrier on my M1 MacBook without making the clean_build.sh changes. It does throw a few warnings related to mismatching build targets between 11.1 and releases in the 10.X series, but it builds and seems to run just fine.
I was unable to make an M1 native build that launched. I was able to get it to compile, but then got the following error when attempting to launch it (by double clicking on the built Barrier.app
):
Process: barrier [36614]
Path: /Users/USER/*/Barrier.app/Contents/MacOS/barrier
Identifier: barrier
Version: 2.3.3-release (2.3.3-release)
Code Type: ARM-64 (Native)
Parent Process: ??? [1]
Responsible: barrier [36614]
User ID: 501
Date/Time: 2021-03-10 10:18:39.148 -0500
OS Version: macOS 11.2.2 (20D80)
Report Version: 12
Anonymous UUID: 9CF9DE70-97CA-4210-920E-5AD5E3D1EC2C
Sleep/Wake UUID: 6885CD96-C2A3-4C5C-8E21-890195218D06
Time Awake Since Boot: 32000 seconds
Time Since Wake: 1000 seconds
System Integrity Protection: enabled
Crashed Thread: 0
Exception Type: EXC_BAD_ACCESS (Code Signature Invalid)
Exception Codes: 0x0000000000000032, 0x0000000100338000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace CODESIGNING, Code 0x2
kernel messages:
VM Regions Near 0x100338000:
__LINKEDIT 1002cc000-100338000 [ 432K] r--/r-- SM=COW /Users/*/Barrier.app/Contents/MacOS/barrier
--> mapped file 100338000-10033c000 [ 16K] r--/r-x SM=PRV Object_id=55af5927
__TEXT 100538000-1005b4000 [ 496K] r-x/r-x SM=COW /usr/lib/dyld
Application Specific Information:
dyld: launch, loading dependent libraries
@loader_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets
Thread 0 Crashed:
0 dyld 0x0000000100594780 bcmp + 16
1 dyld 0x0000000100555408 ImageLoaderMachO::validateFirstPages(linkedit_data_command const*, int, unsigned char const*, unsigned long, long long, ImageLoader::LinkContext const&) + 136
2 dyld 0x000000010055c3b8 ImageLoaderMachOCompressed::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, encryption_info_command const*, ImageLoader::LinkContext const&) + 268
3 dyld 0x0000000100553ffc ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) + 172
4 dyld 0x000000010053c290 dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) + 668
5 dyld 0x0000000100544dd8 dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 1328
6 dyld 0x0000000100544824 dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 208
7 dyld 0x000000010054443c dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 856
8 dyld 0x0000000100543cf0 dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 212
9 dyld 0x000000010053be0c dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 468
10 dyld 0x000000010053b9b0 dyld::load(char const*, dyld::LoadContext const&, unsigned int&) + 196
11 dyld 0x000000010054577c dyld::libraryLocator(char const*, bool, char const*, ImageLoader::RPathChain const*, unsigned int&) + 56
12 dyld 0x000000010054f9d4 ImageLoader::recursiveLoadLibraries(ImageLoader::LinkContext const&, bool, ImageLoader::RPathChain const&, char const*) + 344
13 dyld 0x000000010054e1ac ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, bool, ImageLoader::RPathChain const&, char const*) + 160
14 dyld 0x000000010053e5f4 dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&, unsigned int) + 328
15 dyld 0x0000000100540928 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 6764
16 dyld 0x0000000100539258 dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 476
17 dyld 0x0000000100539038 _dyld_start + 56
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000100338000 x1: 0x000000016fdd5c10 x2: 0x0000000000000c28 x3: 0x0000000000040001
x4: 0x0000000000000003 x5: 0x0000000000000000 x6: 0x00000001005bc280 x7: 0x0000000000000000
x8: 0x0000000000000000 x9: 0x000000016fdd6400 x10: 0x0000000000000001 x11: 0x0001803000000000
x12: 0x0000000000000032 x13: 0x0004000000000000 x14: 0x000000000056f408 x15: 0x000000016fdd6380
x16: 0x00000000000000c5 x17: 0x0000000000000000 x18: 0x0000000000000000 x19: 0x00000001005c15c0
x20: 0x0000000000000c38 x21: 0x000000016fdd5c10 x22: 0x0000000100338000 x23: 0x0000000000000003
x24: 0x000000016fdd6838 x25: 0x000000016fdddd28 x26: 0x000000016fdddea0 x27: 0x000000016fdd5c10
x28: 0x000000000000000c fp: 0x000000016fdd5610 lr: 0x0000000100555408
sp: 0x000000016fdd55d0 pc: 0x0000000100594780 cpsr: 0x20000000
far: 0x0000000100338000 esr: 0x92000007
Binary Images:
0x100020000 - 0x100297fff +barrier (2.3.3-release - 2.3.3-release) <D3DCDA20-1DE9-3F42-B036-A87C328F9791> /Users/USER/*/Barrier.app/Contents/MacOS/barrier
0x100538000 - 0x1005b3fff dyld (832.7.3) <4AB185B3-DC20-3C03-A193-67C0E6C589D7> /usr/lib/dyld
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 2797049
thread_create: 0
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=3728K resident=0K(0%) swapped_out_or_unallocated=3728K(100%)
Writable regions: Total=8384K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=8384K(100%)
VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced)
=========== ======= =======
STACK GUARD 56.0M 1
Stack 8176K 1
__DATA 256K 3
__DATA_CONST 208K 2
__LINKEDIT 720K 3
__TEXT 3024K 2
mapped file 16K 1
=========== ======= =======
TOTAL 68.1M 13
I needed to make @caparomula's suggested changes to clean_build.sh
to get it to build and additionally had to do the following:
Install both qt
and qt5
. Barrier looks for qt
, not just qt5
, and will error out if it's not present.
$ brew install qt qt5 openssl pkg-config
Tell CMake about the location of qt5
:
$ export CMAKE_PREFIX_PATH=/opt/homebrew/opt/qt5/
Issue both of @caparomula's suggested patches.
Then build!
$ ./clean_build.sh
Any thoughts on how to fix this?
You need to sign the binary. I'm pretty new to development on Apple devices, and it took me a while to figure it out. Unfortunately, I don't recall the actual steps I took to sign my binary. But basically you need to get a certificate from Apple (I think I did this via xcode using my free developer account), then use the 'codesign' command line tool to sign the binary. Be sure to do a 'deep' signing so it gets all of the contents. I wish I could give you more specific details, but it's one of those things I just sort of figured out and then promptly forgot. But you should be able to figure it out with a little googling and experimentation. Or maybe someone with a bit more savvy can chime in.
@zachlatta I'm trying to build it too... gets me to the same error... PD: your building for DEBUG, for release, you really gonna need Signing as @caparomula is saying.
Maybe someone more savvy can help us (im not a PC/Mac programmer so y really don't know).
I'm using this wiki: https://github.com/debauchee/barrier-wiki/blob/master/Building-on-macOS.md And this #1162 PR as src.
Same Namespace CODESIGNING, Code 0x2
error.
Hi all,
I faced the same problem and the solution stays in what @caporomula says in his note. Once the clean_build.sh
is over, go to <barrier_repo>>/build/bundle
and sign Barrier.app
, or install Barrier.app from .dmg and sign it there:
➜ bundle git:(master) ✗ codesign --force --deep --sign - /Applications/Barrier.app
/Applications/Barrier.app: replacing existing signature
➜ bundle git:(master) ✗
Then you can launch /Applications/Barrier.app and everything should work.
➜ bundle git:(master) ✗ codesign --force --deep --sign - /Applications/Barrier.app /Applications/Barrier.app: replacing existing signature
YES! It work flawless!!!
Unable to build.
Undefined symbols for architecture arm64:
"_BIO_ctrl", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_BIO_free_all", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_BIO_new", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_BIO_s_file", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_ERR_load_BIO_strings", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_EVP_PKEY_free", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_EVP_PKEY_get_bits", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_EVP_PKEY_get_id", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_EVP_PKEY_type", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_OPENSSL_init_crypto", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_PEM_read_bio_X509", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_X509_free", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
"_X509_get_pubkey", referenced from:
SslCertificate::isCertificateValid(QString const&) in SslCertificate.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/barrier] Error 1
make[1]: *** [src/gui/CMakeFiles/barrier.dir/all] Error 2
make: *** [all] Error 2
I just got it to work with the modifications suggested above.
In clean_build.sh
, change the build target to macOS 12.0:
B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 $B_CMAKE_FLAGS"
In CMakeLists.txt
, replace:
- elseif (IS_DIRECTORY /usr/local/opt/openssl AND BREW_PROGRAM)
- # brew
- set (OPENSSL_ROOT /usr/local/opt/openssl)
+ elseif (BREW_PROGRAM)
+ exec_program(brew ARGS "--prefix openssl" OUTPUT_VARIABLE OPENSSL_ROOT)
Then once it's built:
cp ./build/bundle/Barrier.app /Applications/Barrier.app
codesign --force --deep --sign - /Applications/Barrier.app
Should be all you have to do to get it working. If you enable 20 threads on the make
command on an M1 Max, the whole thing builds in under 30 seconds. 😃
I just got it to work with the modifications suggested above.
In
clean_build.sh
, change the build target to macOS 12.0:B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 $B_CMAKE_FLAGS"
In
CMakeLists.txt
, replace:- elseif (IS_DIRECTORY /usr/local/opt/openssl AND BREW_PROGRAM) - # brew - set (OPENSSL_ROOT /usr/local/opt/openssl) + elseif (BREW_PROGRAM) + exec_program(brew ARGS "--prefix openssl" OUTPUT_VARIABLE OPENSSL_ROOT)
Then once it's built:
cp ./build/bundle/Barrier.app /Applications/Barrier.app codesign --force --deep --sign - /Applications/Barrier.app
Should be all you have to do to get it working. If you enable 20 threads on the
make
command on an M1 Max, the whole thing builds in under 30 seconds. 😃
I run it,but terminal tell me "Please install xcode" ,if i want to build it ,i have to install more than 60gb xocde?
Obviously, you need Xcode for all macOS development.
I am trying to compile it on M1 mac using the instruction above but I am getting the following error: OS: macOS 12.1 21C52 arm64 Xcode Version: 13.2.1 (13C100) CMake: 3.22.1
I am trying to compile it on M1 mac using the instruction above but I am getting the following error: OS: macOS 12.1 21C52 arm64 Xcode Version: 13.2.1 (13C100) CMake: 3.22.1
CMakeError.log CMakeOutput.log
https://github.com/debauchee/barrier/issues/960#issuecomment-967382235
The build is working now after some modification to the path of SDK in clean_build.sh
:
From:
B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 $B_CMAKE_FLAGS"
To:
B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 $B_CMAKE_FLAGS"
Somehow the build was not not working when copying the
bundle/Barrier.app
to/Application/Barrier.app
and signing the application.
It worked when I build with release which gave the file Barrier.dmg
:
In order to build a Barrier.dmg run below command:
export B_BUILD_TYPE=Release ./clean_build.sh
and then install the application. Also, sign the application with following:
codesign --force --deep --sign - /Applications/Barrier.app
Now open the Barrier and Hopefully it will work!
Would it be possible for those who was able to compile it for apple silicon, to share the dmg version.
Internet connection in my country sucks and downloading full Xcode is problematic here.
I downloaded Xcode command line version, which took me 3 days, but that was not enough apparently.
Added a version/SDK test to this and just opened a pull request for the changes -- works perfectly here on my M1 MacBook Air as an Apple Silicon app in macOS Monterey 12.2.1.
https://github.com/debauchee/barrier/pull/1562
Published a pre-release off my fork that someone can test:
thank you Jason. it works perfectly and can confirm that it uses apple silicon on my Macbook Pro with M1 chip in Monterey 12.1.
@thejasonfisher thank you!
Please add support as soon as possible. It is showing system call error when I try to use my Macbook air with M1 chip as a server on client's side.
Added a version/SDK test to this and just opened a pull request for the changes -- works perfectly here on my M1 MacBook Air as an Apple Silicon app in macOS Monterey 12.2.1.
1562
Published a pre-release off my fork that someone can test:
This works perfectly, Thanks Jason
This works on my Mac M1 Mini running 12.3 Thanks Jason, you are a legend
Confirming Jason is a legend. Feels smoother too, less laggy. @thejasonfisher
I can confirm it also works on a M1 Max
Here is the exact command sequence: git clone https://github.com/debauchee/barrier.git cd barrier gh pr checkout 1562 xcode-select --install sudo xcode-select -s /Applications/Xcode.app/Contents/Developer sudo xcodebuild -license brew install openssl bash clean_build.sh
Then copy the build/bin/barrier.app to /Applications: codesign -f -s "TYPE_YOUR_DEVELOPER_SIG_HERE" --deep /Applications/Barrier.app
You might need to go to developer.apple.com and get your developer certificate if you haven't compiled an apple app before.
^^ This seemed to work for me, except I also had to brew install cmake qt qt5
before bash clean_build.sh
in the steps above.
Then I did:
cp -Rv build/bundle/Barrier.app /Applications/Barrier.app
codesign --force --deep --sign - /Applications/Barrier.app
And seems good!
This worked for me combining all above. Thanks a lot guys!
brew install cmake qt qt5 openssl
git clone https://github.com/debauchee/barrier.git
cd barrier
git checkout afe950d1
xcode-select --install
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
bash clean_build.sh
cp -Rv build/bundle/Barrier.app /Applications/Barrier.app
codesign --force --deep --sign - /Applications/Barrier.app
open /Applications/Barrier.app
how to do if no 'TYPE_YOUR_DEVELOPER_SIG_HERE'
can someone please, compile it, and upload it to a google drive or whatever? :D
https://github.com/debauchee/barrier/issues/1395.
Maybe everyone who wants an arm
release should check this thread. Qt5
not support arm
. Only by migrating to Qt6
, an arm
release can be made. Some comments above may be misleading.
Though building on arm
mac maybe success, and the executable is runable.
I've successfully built both barrier, and now InputLeap (the supported fork) on M1 Mac w/o too much trouble.
If you have all the bits and pieces needed to build installed with HomeBrew, I think all I had to do was to change the Deployment Target to 13.1 in the "clean_build.sh" file.
Edited to add:
I don't really know what I'm doing, but if you want to join the fun, here's my most recent build: https://1drv.ms/f/s!AioKbdTrI-m1gZxLsCeYXmHIo0wkdQ?e=aLBq78
Download the .app file, and install it in Applications. Please have a backup and don't yell at me if it turns your dog into a sloth
Edit 2: I tried creating a 'Release Build' - DMG file here -> https://1drv.ms/u/s!AioKbdTrI-m1gZ0VfUFNH-fIR2xDog?e=vAimV3
-J
@joshin42 the 'Release Build' crashs for me because the signature is invalid. Didn't tested the debug build tho.
Edit: I just codesign it with my self signed dev certificate. Works fine now.
^^ This seemed to work for me, except I also had to
brew install cmake qt qt5
beforebash clean_build.sh
in the steps above.Then I did:
cp -Rv build/bundle/Barrier.app /Applications/Barrier.app codesign --force --deep --sign - /Applications/Barrier.app
And seems good!
Tanks for its. Works for me.
Would be nice to have a native M1 build please. Is it as simple as recompiling on an M1 machine? Thanks.