Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
109.14k stars 10.5k forks source link

macOS: meson.build:1:0: ERROR: Compiler cc can not compile programs. #2886

Open zhangsean opened 2 years ago

zhangsean commented 2 years ago

Environment

Describe the bug Hi, I got an error when building on macOS with prebuild server.

git clone https://github.com/Genymobile/scrcpy
cd scrcpy
./install_release.sh
...
[scrcpy] Verifying prebuilt server...
scrcpy-server: OK
[scrcpy] Building client...
The Meson build system
Version: 0.56.0
Source dir: /Users/sean/android/scrcpy
Build dir: /Users/sean/android/scrcpy/build-auto
Build type: native build
Project name: scrcpy
Project version: 1.21

meson.build:1:0: ERROR: Compiler cc can not compile programs.

A full log can be found at /Users/sean/android/scrcpy/build-auto/meson-logs/meson-log.txt

meson-log.txt

$ cc -v
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

$ cc /Users/sean/android/scrcpy/build-auto/meson-private/sanitycheckc.c -o /Users/sean/android/scrcpy/build-auto/meson-private/sanitycheckc.exe -pipe
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)

$ cc /Users/sean/android/scrcpy/build-auto/meson-private/sanitycheckc.c -o /Users/sean/android/scrcpy/build-auto/meson-private/sanitycheckc.exe -pipe -v
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
 "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx11.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name sanitycheckc.c -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -munwind-tables -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 711 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0 -internal-isystem /usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -fdebug-compilation-dir /Users/sean/android/scrcpy -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+nullptrToBoolConversion -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNeonImmediateRangeCheck -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+revert09abecef7bbf -mllvm -disable-aligned-alloc-awareness=1 -mllvm -enable-dse-memoryssa=0 -o /var/folders/bx/sfq__14j77dfhzqy29pw5pxr0000gp/T/sanitycheckc-7a195b.o -x c /Users/sean/android/scrcpy/build-auto/meson-private/sanitycheckc.c
clang -cc1 version 13.0.0 (clang-1300.0.29.3) default target x86_64-apple-darwin20.6.0
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include
 /Library/Developer/CommandLineTools/usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 11.0.0 11.0.0 -o /Users/sean/android/scrcpy/build-auto/meson-private/sanitycheckc.exe /var/folders/bx/sfq__14j77dfhzqy29pw5pxr0000gp/T/sanitycheckc-7a195b.o -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rom1v commented 2 years ago

It seems a system library is missing.

Similar issue and solution (for linux): https://github.com/FeralInteractive/gamemode/issues/137

zhangsean commented 2 years ago

I had read the issue, but it can't fix my error.

$ brew install gcc-multilib
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "gcc-multilib".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

$ brew install build-essential
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "build-essential".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

I got the command in meson-log.txt.

 "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 11.0.0 11.0.0 -o /Users/sean/android/scrcpy/build-auto/meson-private/sanitycheckc.exe /var/folders/bx/sfq__14j77dfhzqy29pw5pxr0000gp/T/sanitycheckc-7a195b.o -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -lSystem

But the library follow -lSystem is just there.

$ ls -lh /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a
-rw-r--r--  1 root  wheel   518K  8  4 08:20 /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a

Is there any other problem to fix?