04月22, 2019

Ubuntu 中 clang5.0 交叉编译遇到问题以及解决方案

fatal error: 'asm/socket.h' file not found

解决方案: sudo apt-get install build-essential flex libelf-dev libc6-dev-amd64 binutils-dev libdwarf-dev
还是各种报错 手动改路径或者可以用软连接 一般是找不到asm文件下的。h文件

Cross-compilation using Clang

https://clang.llvm.org/docs/CrossCompilation.html

How To Cross-Compile Clang/LLVM using Clang/LLVM

https://llvm.org/docs/HowToCrossCompileLLVM.html

-target x86_64-pc-linux-elf to creat x86 file

https://blog.csdn.net/qiusi0225/article/details/80451017

报错:

usr/include/linux/types.h:24:9: error: unknown type name '__u16'
typedef __u16 __bitwise __le16;
        ^
/usr/include/linux/types.h:25:9: error: unknown type name '__u16'
typedef __u16 __bitwise __be16;
        ^
/usr/include/linux/types.h:26:9: error: unknown type name '__u32'
typedef __u32 __bitwise __le32;
        ^
/usr/include/linux/types.h:27:9: error: unknown type name '__u32'
typedef __u32 __bitwise __be32;
        ^
/usr/include/linux/types.h:28:9: error: unknown type name '__u64'
typedef __u64 __bitwise __le64;
        ^
/usr/include/linux/types.h:29:9: error: unknown type name '__u64'
typedef __u64 __bitwise __be64;
        ^
/usr/include/linux/types.h:31:9: error: unknown type name '__u16'
typedef __u16 __bitwise __sum16;
        ^
/usr/include/linux/types.h:32:9: error: unknown type name '__u32'

https://codeday.me/bug/20190222/702522.html

https://stackoverflow.com/questions/9680399/what-does-typedef-u16-bitwise-le16-mean-in-linux-kernel

内核提供的数据类型都在头文件声明,可以在程序中加上#include 头文件。详细类型可参考 https://www.linuxidc.com/Linux/2011-06/37157.htm 2、认识u8,u16,u32,u64的大小及作用

本文链接:https://harry.ren/post/clang-crosscompiler.html

-- EOF --

Comments