问题描述
我对与介子交叉编译STM32有一些问题。我是介子的新手,请尝试使用它来编译STM32代码。我找到了这个存储库https://github.com/hwengineer/STM32F3Discovery-meson-example 并尝试更改它,我需要它。
我的交叉文件就像
[binaries]
c = 'arm-none-eabi-gcc'
cpp = 'arm-none-eabi-g++'
ld = 'arm-none-eabi-ld'
ar = 'arm-none-eabi-ar'
as = 'arm-none-eabi-as'
size = 'arm-none-eabi-size'
objdump = 'arm-none-eabi-objdump'
objcopy = 'arm-none-eabi-objcopy'
strip = 'arm-none-eabi-strip'
gdb = 'arm-none-eabi-gdb'
terminal= 'x-terminal-emulator'
openocd = '/usr/local/bin/openocd'
exe_wrapper = 'meson_exe_wrapper.sh'
[properties]
c_args = [
'-mthumb',# define language
#------------------------------------
'-fshort-enums',# otherwise errors at linking...
'-fmessage-length=0',# all error warnings in a single line (default 72)
'-fsigned-char',# char is per default unsigned
'-ffunction-sections',# each function to a seperate section ==> Code-optimization / deletion
'-fdata-sections',# each variable to a seperate section ==> Code-optimization / deletion
'-Wall','-ffreestanding',#------------------------------------
# '-flto',]
c_link_args = [
'-nostdlib',# do not import the standard library's
# '-flto',]
[host_machine]
system = 'none'
cpu_family = 'arm'
cpu = 'cortex-m3'
endian = 'little'
但是当我尝试编译介子时,会给出
Build type: native build
Project name: thermometer_with_meson
Project version: undefined
C compiler for the host machine: cc (gcc 10.2.0 "cc (GCC) 10.2.0")
C linker for the host machine: cc ld.bfd 2.35
Host machine cpu family: x86_64
Host machine cpu: x86_64
主机应为arm cortex-m3,但似乎有误。
为什么介子会忽略交叉文件?为什么要使用主机x86-64?
顺便说一句,它给出了错误,例如x86_64应该是x86-64。
解决方法
据我所见,输出日志中有
Build type: native build
但是,您应该:
Build type: cross build
因此,检查构建的配置方式,应将交叉文件设置为安装构建目录,然后将其用于构建:
$ meson build/ --cross-file cross_file.build
$ ninja -C build/