參考連接:
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 執(zhí)行一遍再說。
在文件末尾添加自己的工具鏈信息如下:
[
{
"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"
}
]
會調(diào)用這個交叉編譯鏈設(shè)置的文件:
toolchainFile 文件:文章來源:http://www.zghlxwxcb.cn/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)
重新設(shè)置交叉編譯工具:
這個時候由于默認(rèn)的是x86的GCC:
執(zhí)行CMake:Reset CMake Tools …文章來源地址http://www.zghlxwxcb.cn/news/detail-782948.html
到了這里,關(guān)于Ubuntu下VsCode+CMake 交叉編譯的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!