Crosscompiling for Android on Windows (MinGW32)
Hello,
I'm having trouble compiling the app for Android from Windows x64, using MinGW32. I get an error as soon as compilation starts:
clang++.exe: error: unsupported option '--sysroot C:/AndroidPlayerNDK/toolchains/llvm/prebuilt/windows-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa -Wformat -Werror=format-security -stdlib=libc++ ' CMakeFiles\cryptopp-object.dir\build.make:74: recipe for target 'CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o' failed
The library does compile with no problem for Windows, MacOS and iOS and I do succeed in cross-compiling other libraries (such as OpenCV) for Android so I don't really know where the problem can come from. I can also cross-compile the library using the official Makefile (following those instructions) so it really does not seem to be a minGW32 setup problem.
Does anybody have any idea on how to fix this, or any pointer on how to debug this? Thank you, PS: I'm not sure if this is the right place to post, I apologize if it's not.
As you see the error I would first start to remove options one after another to get the one that is problematic.
Alright, I got some more time to work on this issue and finally found what was causing it. It seems there are two sources of this problem:
- When crosscompiling for Android on Windows, the
DumpMachinefunction does not set any CRYPTOPP_ARCH variable (the-dumpmachinereturnx86_64-w64-windows-gnu) - Using a CMAKE_TOOLCHAIN_FILE causes the compiler option to appear twice, once in a valid form and the second time between quotes, which confuses the compiler.
Hopefully this will help someone who encounters the same issue.