d99kris / nchat

Terminal-based Telegram / WhatsApp client for Linux and macOS
MIT License
619 stars 43 forks source link

Build fails on M1 macos at libssl #59

Closed Bellavene closed 2 years ago

Bellavene commented 2 years ago
[ 98%] Linking CXX shared library ../../../libtdclientshared.dylib
ld: warning: ignoring file /usr/local/opt/openssl/lib/libssl.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /usr/local/opt/openssl/lib/libcrypto.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
d99kris commented 2 years ago

Hi @Bellavene - I don't see this problem on my M1 macOS.

Could you share the entire build output on terminal, perhaps attach as a txt file, or at least the output from cmake?

On my M1 homebrew installs (arm64) packages under /opt/homebrew/opt, so when cmake runs it detects openssl there:

-- Found OpenSSL: /opt/homebrew/opt/openssl/lib/libcrypto.dylib (found version "3.0.2")  
-- Found OpenSSL: /opt/homebrew/opt/openssl/include /opt/homebrew/opt/openssl/lib/libssl.dylib;/opt/homebrew/opt/openssl/lib/libcrypto.dylib

But it looks like it detects it wrongly on your system.

Btw, are you using brew, and have installed openssl using it?

Bellavene commented 2 years ago

Hi @Bellavene - I don't see this problem on my M1 macOS.

Could you share the entire build output on terminal, perhaps attach as a txt file, or at least the output from cmake?

On my M1 homebrew installs (arm64) packages under /opt/homebrew/opt, so when cmake runs it detects openssl there:

-- Found OpenSSL: /opt/homebrew/opt/openssl/lib/libcrypto.dylib (found version "3.0.2")  
-- Found OpenSSL: /opt/homebrew/opt/openssl/include /opt/homebrew/opt/openssl/lib/libssl.dylib;/opt/homebrew/opt/openssl/lib/libcrypto.dylib

But it looks like it detects it wrongly on your system.

Btw, are you using brew, and have installed openssl using it?

Hello @d99kris I am a bit busy last days, will come back with that. Honestly I don't remember, but most likely yes, installed through brew. Will check that. Maybe there is some leftover from intel brew, because I have migrated the user data last time. Thank You.

Bellavene commented 2 years ago

https://send.vis.ee/download/5946b153b4069ce6/#tkIOhDiCKj-SKtPDprE-TA

d99kris commented 2 years ago

Looks like I was too slow, the above link shows: "This link has expired"

Anyway, I believe Github issues allow attaching files directly. It should be possible to just drag and drop onto this web page form.

Bellavene commented 2 years ago

nchat make.txt

Thank you, did not knew that.

d99kris commented 2 years ago

Thanks! Yeah, the Github issues UI could perhaps be improved with a paperclip button to make it more obvious it's supported.

So from the log you shared I see this:

-- Found OpenSSL: /usr/local/opt/openssl/lib/libcrypto.dylib (found version "1.1.1k")
-- Found OpenSSL: /usr/local/opt/openssl/include /usr/local/opt/openssl/lib/libssl.dylib;/usr/local/opt/openssl/lib/libcrypto.dylib

which indicates openssl was found in /usr/local/opt/openssl, which is the default location for x86_64 installation.

The default location for arm64 is /opt/homebrew/opt/openssl. Could you check if you have that dir, and perhaps also that the installed openssl there is arm64? One can use the following command:

file /opt/homebrew/opt/openssl/bin/openssl 
/opt/homebrew/opt/openssl/bin/openssl: Mach-O 64-bit executable arm64

Assuming your system does have openssl arm64 installed, perhaps you could try to edit the nchat source file lib/tgchat/CMakeLists.txt and remove the following line: list(APPEND OPENSSL_ROOT_DIR /usr/local/opt/openssl)

If this works, I will try prepare a proper fix in nchat. Thanks!

Bellavene commented 2 years ago

Thank you! That worked flawlessly

d99kris commented 2 years ago

Thanks for the feedback! In the above commit I've implemented a proper fix to support M1 systems which have both arm64 and x86_64 installations of openssl, by prioritizing the native (arm64) openssl search path.