clementine-player / Clementine

:tangerine: Clementine Music Player
https://www.clementine-player.org/
GNU General Public License v3.0
3.75k stars 676 forks source link

Trying to build for Mac OS Big Sur: cmake problem #6983

Open trg818 opened 3 years ago

trg818 commented 3 years ago

Hi,

I have taken up again my effort to build Clementine for my new MacBook Pro, which runs with an M1 processor under Big Sur (11.2.3). My starting point was to try and build it with Homebrew, following these instructions. They are not up to date, however, and I needed to revise them but have now got stuck at the cmake step in this sequence:

# install cryptopp by hand, because there is no brew for it
export CXXFLAGS="-std=c++11 -stdlib=libc++ -DCRYPTOPP_DATA_DIR='\"$PREFIX/share/cryptopp/\"'"
make
make test
sudo make install PREFIX=/usr/local
# install Clementine
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install --cask cmake
# missing: cryptopp
brew install glib pkgconfig boost protobuf protobuf-c qt gettext gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav
brew install libcdio
brew install --build-from-source chromaprint
brew tap tomahawk-player/homebrew-tomahawkqt5
brew install tomahawk-player/homebrew-tomahawkqt5/liblastfm
sudo ln -s /usr/local/include/lastfm /usr/local/include/lastfm5
export Qt5_DIR=/usr/local/opt/qt5/lib/cmake
export Qt5LinguistTools_DIR=/usr/local/Cellar/qt/5.11.2/lib/cmake/Qt5LinguistTools
export GST_SCANNER_PATH=/usr/local/Cellar/gstreamer/1.14.4/libexec/gstreamer-1.0/gst-plugin-scanner
export GST_PLUGIN_PATH=/usr/local/lib/gstreamer-1.0
export PATH="/usr/local/opt/gettext/bin:$PATH"
git clone https://github.com/clementine-player/Clementine
cd Clementine/bin
cmake ..
make -j8

The problem is that cmake doesn't find libraries that should be installed:

-- Could NOT find ALSA (missing: ALSA_LIBRARY ALSA_INCLUDE_DIR) 
-- Checking for module 'libcdio'
--   No package 'libcdio' found
-- Checking for module 'libchromaprint'
--   No package 'libchromaprint' found
CMake Error at /opt/local/share/cmake-3.19/Modules/FindPkgConfig.cmake:553 (message):
  A required package was not found
Call Stack (most recent call first):
  /opt/local/share/cmake-3.19/Modules/FindPkgConfig.cmake:741 (_pkg_check_modules_internal)
  CMakeLists.txt:62 (pkg_check_modules)

-- Configuring incomplete, errors occurred!

I don't know how to resolve this. I think the ALSA thing is not a problem, because this is not Linux. The line in `CMakeLists.txt' refers to cryptopp, which should also be there, but it's not clear to me whether the crash is due to that. Can anybody give me advice on how to deal with this?

hatstand commented 3 years ago

Probably the best documentation for this: https://github.com/clementine-player/Clementine/blob/master/.github/workflows/all.yml#L883

trg818 commented 3 years ago

I tried the env variables and options shown there adapted to my configuration, but the error message remains. I can't see from that file what paths I would have to set to make cmake find the libraries.

jbroadus commented 3 years ago

Looks like brew on M1 should be using /opt/homebrew/ instead of /usr/local/. I don't know if that means that the prefix needs to be changed as well.

https://brew.sh/2020/12/01/homebrew-2.6.0/

trg818 commented 3 years ago

That's a good point, and I corrected it and started over - but the error remains: cryptopp is still not found. To be precise, the manual installation of cryptopp I did now was into /opt/local, so I wouldn't put something into /opt/homebrew that isn't from Homebrew, but I did then set links to the executable cryptest.exe, the include files, and the libraries to where they would be in Homebrew. Strangely, libcdio and libchromaprint aren't found either, although those were installed with Homebrew, and they are actually there. However, the final error, and the one that seems to result in the crash, concerns cryptopp, as the line in CMakeList.txt the message refers to reads: pkg_search_module(CRYPTOPP cryptopp libcrypto++) I don't know what to do with this, though.

jbroadus commented 3 years ago

Is that a warning or an error? It doesn't look like it should be a required package unless spotify is being forced on.

This also isn't found on the official build: https://github.com/clementine-player/Clementine/runs/2374187572?check_suite_focus=true#step:5:114

libchromaprint defintely is required.

jbroadus commented 3 years ago

You could try to locate the conf on the command line: pkgconf --libs libchromaprint

And running cmake with --debug-find might be helpful as well.

trg818 commented 3 years ago

Thanks, this took me a few steps further, but there is still some trouble. It turned out that I apparently needed the brew pkg-config, and with pkg-config --libs libchromaprint I got the recommendation to amend my $PKG_CONFIG_PATH, which I did by export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/homebrew/lib/pkgconfig. Now libchromaprint, libcdio, and even libcryptopp were found, and at least the config part was apparently completed without fatal errors.

After a failure of CMake I found that I also had to install glew, so I did that too, and CMake also completed. So now it's the last(?) step, make that fails with a rather lengthy chain of errors that I'll attach here. scr-err.txt All of them seem to be related somehow to the Qt library, but being no expert in this, I can't make much of this.

jbroadus commented 3 years ago

I think this is the problem where it's picking up Qt6 instead of Qt5. https://github.com/clementine-player/Clementine/blob/master/Brewfile#L17

trg818 commented 3 years ago

I suspected something like that, but how can I enforce the use of Qt5 then? I did set a few shell variables related to it, but I am not aware a flag or option I could set.

jbroadus commented 3 years ago

If you don't need Qt6, can you just uninstall it and install qt@5? Sorry, I'm not familiar with homebrew.

jbroadus commented 3 years ago

If you want both Qt5 and Qt6 installations, you could try setting Qt5_DIR to the correct path.

kfr2359 commented 3 years ago

With Qt6 installed make fails because of some include errors, and Qt5_DIR is set correctly. Seems like headers of qt5 and qt6 are in the same location, didn't check it. After uninstalling it, make is successful. Anyway, I've managed to build dmg for M1, setting up correct symbolic links and envs, but at launch Clementine crashes:

Process:               clementine [13462]
Path:                  /Applications/clementine.app/Contents/MacOS/clementine
Identifier:            org.clementine-player.clementine
Version:               1.4 rc2 (4096.1.4.0.0)
Code Type:             ARM-64 (Native)
Parent Process:        ??? [1]
Responsible:           clementine [13462]
User ID:               501

Date/Time:             2021-04-20 21:39:29.619 +0300
OS Version:            macOS 11.2.3 (20D91)
Report Version:        12
Anonymous UUID:        DADE9BE9-C778-4FD1-AD96-2A9A8AA5A59E

Sleep/Wake UUID:       A6DD0F66-AFD4-4166-A6CC-0B99B68D0F15

Time Awake Since Boot: 450000 seconds
Time Since Wake:       1000 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_BAD_ACCESS (Code Signature Invalid)
Exception Codes:       0x0000000000000032, 0x0000000106588000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace CODESIGNING, Code 0x2

kernel messages:

VM Regions Near 0x106588000:
    __LINKEDIT                  105acc000-106588000    [ 10.7M] r--/r-- SM=COW  /Applications/clementine.app/Contents/MacOS/clementine
--> mapped file                 106588000-10658c000    [   16K] r--/r-x SM=PRV  Object_id=7fa7576b
    __TEXT                      106798000-106814000    [  496K] r-x/r-x SM=COW  /usr/lib/dyld

Application Specific Information:
dyld: launch, loading dependent libraries
@executable_path/../Frameworks/libprotobuf.26.dylib

Thread 0 Crashed:
0   dyld                            0x00000001067f4780 bcmp + 16
1   dyld                            0x00000001067b5408 ImageLoaderMachO::validateFirstPages(linkedit_data_command const*, int, unsigned char const*, unsigned long, long long, ImageLoader::LinkContext const&) + 136
2   dyld                            0x00000001067bc3b8 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                            0x00000001067b3ffc ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) + 172
4   dyld                            0x000000010679c290 dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) + 668
5   dyld                            0x00000001067a4dd8 dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 1328
6   dyld                            0x00000001067a4824 dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 208
7   dyld                            0x00000001067a433c dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 600
8   dyld                            0x00000001067a3cf0 dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 212
9   dyld                            0x000000010679be0c dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 468
10  dyld                            0x000000010679b9b0 dyld::load(char const*, dyld::LoadContext const&, unsigned int&) + 196
11  dyld                            0x00000001067a577c dyld::libraryLocator(char const*, bool, char const*, ImageLoader::RPathChain const*, unsigned int&) + 56
12  dyld                            0x00000001067af9d4 ImageLoader::recursiveLoadLibraries(ImageLoader::LinkContext const&, bool, ImageLoader::RPathChain const&, char const*) + 344
13  dyld                            0x00000001067ae1ac ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, bool, ImageLoader::RPathChain const&, char const*) + 160
14  dyld                            0x000000010679e5f4 dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&, unsigned int) + 328
15  dyld                            0x00000001067a0928 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 6764
16  dyld                            0x0000000106799258 dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 476
17  dyld                            0x0000000106799038 _dyld_start + 56

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000106588000   x1: 0x000000016b5fd890   x2: 0x0000000000000828   x3: 0x0000000000040001
    x4: 0x0000000000000003   x5: 0x0000000000000000   x6: 0x000000010681c280   x7: 0x0000000000000000
    x8: 0x0000000000000000   x9: 0x000000016b5fdfd0  x10: 0x0000000000000001  x11: 0x0001803000000000
   x12: 0x0000000000000032  x13: 0x0004000000000000  x14: 0x000000000023fb20  x15: 0x000000016b5fdf50
   x16: 0x00000000000000c5  x17: 0x0000000000000000  x18: 0x0000000000000000  x19: 0x00000001068218f0
   x20: 0x0000000000000838  x21: 0x000000016b5fd890  x22: 0x0000000106588000  x23: 0x0000000000000003
   x24: 0x000000016b5fe0b8  x25: 0x000000016b6059a8  x26: 0x000000016b605b20  x27: 0x000000016b5fd890
   x28: 0x0000000000000003   fp: 0x000000016b5fd290   lr: 0x00000001067b5408
    sp: 0x000000016b5fd250   pc: 0x00000001067f4780 cpsr: 0x20000000
   far: 0x0000000106588000  esr: 0x92000007

Binary Images:
       0x1047f8000 -        0x105a17fff +org.clementine-player.clementine (1.4 rc2 - 4096.1.4.0.0) <7388C9FE-D43F-329C-B897-7FFF0E05E57C> /Applications/clementine.app/Contents/MacOS/clementine
       0x106798000 -        0x106813fff  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: 45543767
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=29.6M resident=0K(0%) swapped_out_or_unallocated=29.6M(100%)
Writable regions: Total=8544K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=8544K(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
STACK GUARD                       56.0M        1 
Stack                             8176K        1 
__DATA                             688K        4 
__DATA_CONST                       288K        2 
__LINKEDIT                        11.0M        3 
__TEXT                            18.6M        2 
mapped file                         16K        1 
===========                     =======  ======= 
TOTAL                             94.6M       14 

Model: MacBookAir10,1, BootROM 6723.81.1, proc 8:4:4 processors, 16 GB, SMC 
Graphics: kHW_AppleM1Item, Apple M1, spdisplays_builtin
Memory Module: lp_ddr4
AirPort: spairport_wireless_card_type_airport_extreme, wl0: Dec 31 2020 21:39:03 version 18.20.222.20.7.8.104 FWID 01-1b2645bc
Bluetooth: Version 8.0.3d9, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB 3.1 Bus
USB Device: USB 3.1 Bus
Thunderbolt Bus: MacBook Air, Apple Inc.
Thunderbolt Bus: MacBook Air, Apple Inc.

Does somebody have any clue what to do with it? Of course I'll share my environment with which build is successful if needed

jbroadus commented 3 years ago

I'm not sure how code signing works on Macs, but it looks like others have had this problem with Homebrew signing on M1. Most of the suggestions are to reinstall the problematic package.

trg818 commented 3 years ago

In the meantime I uninstalled Qt6, which was apparently only installed because it was in the list from those old instructions, and then the compilation proceeded a bit further. But then it failed again, this time with the following messages

/Users/ruedas/Desktop/clm_tmp/Clementine/bin/ext/libclementine-tagreader/tagreadermessages.pb.h:17:2: error: 
      This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
 ^
/Users/ruedas/Desktop/clm_tmp/Clementine/bin/ext/libclementine-tagreader/tagreadermessages.pb.h:18:2: error: 
      incompatible with your Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
 ^
/Users/ruedas/Desktop/clm_tmp/Clementine/bin/ext/libclementine-tagreader/tagreadermessages.pb.h:19:2: error: 
      regenerate this file with a newer version of protoc.
...
/Users/ruedas/Desktop/clm_tmp/Clementine/bin/ext/libclementine-tagreader/tagreadermessages.pb.cc:17:94: error: 
      no template named 'SCCInfo' in namespace 'google::protobuf::internal'
  ...::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_IsMediaFileReques...
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

and similar stuff. I don't know where it gets its protoc from, but I do know that it is not installed with Homebrew.

kfr2359 commented 3 years ago

It's possible that protoc is generated according to protobuf files in the project during build, didn't check the code. Maybe make clean will solve it

trg818 commented 3 years ago

No, I just tried that to be sure, but the error remains.

kfr2359 commented 3 years ago

About my error: reinstalling protobuf and building from source didn't help, but manual codesign -s (https://github.com/pypa/virtualenv/issues/2023#issuecomment-748636276) for all needed binaries in clementine.app/ after make but before make dmg did help, it works, even with sound. Was surprised to see that CPU usage in activity monitor didn't decrease at all, thought Rosetta 2 is the reason for relatively high usage.