open-quantum-safe / liboqs

C library for prototyping and experimenting with quantum-resistant cryptography
https://openquantumsafe.org/
Other
1.82k stars 447 forks source link

Can't cross compile the lib on Linux for Windows #1826

Closed maroueneboubakri closed 3 months ago

maroueneboubakri commented 3 months ago

Hello,

Taking library version 0.10.0 or 0.10.1

I'm expecting the following command to work

cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=.CMake/toolchain_windows_x86.cmake -DOQS_ALGS_ENABLED=STD -DOQS_BUILD_ONLY_LIB=ON -DOQS_MINIMAL_BUILD="SIG_dilithium_3" -DOQS_DIST_BUILD=ON -DOQS_USE_OPENSSL=ON $CMAKE_OPENSSL_ROOT_DIR -DOQS_USE_PTHREADS=OFF -DCMAKE_INSTALL_PREFIX=$(pwd)/build -S . -B _build && cd _build && ninja

Result:

CMake Error at CMakeLists.txt:21 (project):
  Generator

    Ninja

  does not support platform specification, but platform

    Win32

  was specified.

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage

My env:

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"

$ ninja --version
1.10.0

$ cmake --version
cmake version 3.27.7

What is wrong with this ?

Thanks Maro

SWilson4 commented 3 months ago

Hi @maroueneboubakri, we don't support cross-compiling for Windows / x86; only for Windows / amd64. (Please see https://github.com/open-quantum-safe/liboqs/wiki/Platform-specific-notes-for-building-liboqs#cross-compiling-on-debianubuntu-linux-for-windows). In fact, you will see that the toolchain file you're using sets CMAKE_CROSSCOMPILING to OFF: https://github.com/open-quantum-safe/liboqs/blob/51ddd33cc04d12bd47c8639c1254714879f4cdf3/.CMake/toolchain_windows_x86.cmake#L7

If this is a feature that would be useful to you, please feel free to submit a PR!

SWilson4 commented 3 months ago

Since this is not a bug, I'm going to convert the issue to a discussion.