tpoechtrager / osxcross

Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)
GNU General Public License v2.0
2.85k stars 320 forks source link

Rust openssl dependency doesnt see openssl header files in osxcross Clang toolchain #306

Closed lostiniceland closed 2 years ago

lostiniceland commented 2 years ago

Goal: cross-compile a Rust programm for OSX on Linux

My application has a dependency on openssl which requires openssl header files to be present on the Linux system. So on my Suse box I have to run zypper install openssl-devel to be able to compile. Cross-compiling to Windows also works with the GNU toolchain. After setting up osxcross with XCode 13, compilation works but when linking kicks in the rust-linker is not able to "see" the openssl headers anymore. Since it works for the other two I can only assume that osxcross toolchain (x86_64-apple-darwin20.4-clang) does not have access to the header files on my Linux system (it may technically not even possible). I also read that OSX in general seems to be moving away from openssl. So I tried with XCode 11 SDK but got the same result.

Is this a known limitation of osxcross? Can you include openssl in the toolchain so the linker is satisfied (and it works).

Coming from Java, this cross-compiling is quite new to me, so please bear with me :-)

tpoechtrager commented 2 years ago

You can't use your host OSs headers with OSXCross. You can install openssl with osxcross-macports:

export MACOSX_DEPLOYMENT_TARGET=10.15 # or whatever version you want
osxcross-macports install openssl
export OSXCROSS_MP_INC=1

Have a look at https://github.com/tpoechtrager/osxcross/blob/master/README.MACPORTS.md

lostiniceland commented 2 years ago

Thanks for the quick reply and indeed compilation now works.

This project is awesome...and to me black magic :-)