参考连接:
Ubuntu下VsCode+CMake 交叉编译
VSCode与CMake搭配使用之基本配置
VSCode与CMake搭配使用之交叉编译
step1:
Ctrl+Shift+p打开VSCode的指令面板,然后输入cmake:q ;
在窗口搜索:“ >CMake:Edit user-loacl CMake kits ”会打开一个cmake-tools-kits.json的文件.
如果搜索不到这个文件,先把cmake :quick start 执行一遍再说。
在文件末尾添加自己的工具链信息如下:
[
{
"name": "GCC 11.4.0 x86_64-linux-gnu",
"compilers": {
"C": "/usr/bin/gcc",
"CXX": "/usr/bin/g++"
},
"isTrusted": true
},
{
"name": "arm_corss_compiler_for_lockfox",
"toolchainFile": "/home/qiao/Desktop/my_test/toolchain.cmake"
}
]
会调用这个交叉编译链设置的文件:
toolchainFile 文件:文章来源:https://www.toymoban.com/news/detail-782948.html
### toolchain.cmake ###
# this is required
SET(CMAKE_SYSTEM_NAME Linux)
# specify the cross compiler
SET(CMAKE_C_COMPILER /home/qiao/Desktop/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /home/qiao/Desktop/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-g++)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /build_env/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/)
# search for programs in the build host directories (not necessary)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
重新设置交叉编译工具:
这个时候由于默认的是x86的GCC:
执行CMake:Reset CMake Tools …
文章来源地址https://www.toymoban.com/news/detail-782948.html
到了这里,关于Ubuntu下VsCode+CMake 交叉编译的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!