我下载并提取了以下内容:
http : //releases.llvm.org/5.0.1/llvm-5.0.1.src.tar.xz
http://releases.llvm.org/5.0.1/cfe-5.0.1。 src.tar.xz
然后:
$ mv cfe-5.0.1.src llvm-5.0.1.src/tool/clang
llvm-5.0.1.src/mingw_cross_toolchain.cmake
文件: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
build/NATIVE/include/llvm/Config/llvm-config.h
我有:/* Define if this is Unixish platform */
#define LLVM_ON_UNIX 1
/* Define if this is Win32ish platform */
/* #undef LLVM_ON_WIN32 */
这会使构建失败。由于LLVM_ON_WIN32依赖于WIN32标志,因此我尝试在命令行上以及在mingw_cross_toolchain.cmake
可惜的情况下定义该标志,但对generate无效build/NATIVE/include/llvm/Config/llvm-config.h
。
我们如何正确定义WIN32标志?
cmake/modules/HandleLLVMOptions.cmake
执行: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"
现在,我将能够正确交叉编译所有内容!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句