Cmake 如何在Ubuntu for Win32上交叉编译Clang?
我下载并提取:Cmake 如何在Ubuntu for Win32上交叉编译Clang?,cmake,Cmake,我下载并提取: 然后: 创建了以下llvm-5.0.1.src/mingw\u cross\u toolchain.cmake文件: 然后: 然后在下面的build/NATIVE/include/llvm/Config/llvm Config.h中,我有: 这将导致构建失败。由于WIN32上的LLVM_依赖于WIN32标志,因此我尝试在命令行和mingw_cross_toolchain.cmake中定义该标志,但对生成的build/NATIVE/include/LLVM/Config/LLV
llvm-5.0.1.src/mingw\u cross\u toolchain.cmake
文件:build/NATIVE/include/llvm/Config/llvm Config.h
中,我有:mingw_cross_toolchain.cmake
中定义该标志,但对生成的build/NATIVE/include/LLVM/Config/LLVM Config.h
没有任何影响
我们如何正确定义WIN32标志
cmake/modules/handlelvmoptions.cmake
中的标志设置为:现在我可以正确地交叉编译所有内容了 构建如何失败?是否有任何错误可以添加到问题帖子中?源文件使用UNIX上的LLVM_和WIN32上的LLVM_,因此如果设置不正确,则生成将失败,因为内部typedef不同。
$ mv cfe-5.0.1.src llvm-5.0.1.src/tool/clang
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
# cross compilers to use for C and C++
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc-posix)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++-posix)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
# target environment on the build host system
# set 1st to dir with the cross compiler's C/C++ headers/libs
set(CMAKE_FIND_ROOT_PATH /usr/lib/gcc/${TOOLCHAIN_PREFIX}/7.3-posix)
# modify default behavior of FIND_XXX() commands to
# search for headers/libs in the target environment and
# search for programs in the build host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
$ cd llvm-5.0.1.src
$ mkdir build
# cd build
$ cmake -D CMAKE_TOOLCHAIN_FILE=../mingw_cross_toolchain.cmake
/* Define if this is Unixish platform */
#define LLVM_ON_UNIX 1
/* Define if this is Win32ish platform */
/* #undef LLVM_ON_WIN32 */
set(WIN32 1)
set(UNIX 0)
$ sudo apt-get install wine-binfmt
$ sudo update-binfmts --import /usr/share/binfmts/wine
$ export WINEPATH="/usr/x86_64-w64-mingw32/lib/;/usr/lib/gcc/x86_64-w64-mingw32/7.3-posix"