[其他ST产品] 如何在Linux上通过命令行编译STM32CubeIDE代码?

[复制链接]
543|10
HomeKit 发表于 2025-9-3 08:42 | 显示全部楼层 |阅读模式
根据本网站上搜索,似乎应该执行类似以下的操作:

~/st/stm32cubeide_1.8.0/stm32cubeide --launcher.suppressErrors -nosplash -application org.eclipse.cdt.managedbuilder.core.headlessbuild -data "./" -build *、
在包含.mxproject、.project和.cproject文件的同一文件夹中运行上述命令。
错误是:
Invalid Arguments: [-build, Core, Drivers, stm32 Project.ioc, Middlewares]
Error: Unknown argument: Drivers
Usage: PROGRAM -data <workspace> -application org.eclipse.cdt.managedbuilder.core.headlessbuild [ OPTIONS ]

   -data       {/path/to/workspace}
   -import     {[uri:/]/path/to/project}
   -importAll  {[uri:/]/path/to/projectTreeURI} Import all projects under URI
   -build      {project_name_reg_ex{/config_reg_ex} | all}
   -cleanBuild {project_name_reg_ex{/config_reg_ex} | all}
   -markerType Marker types to fail build on {all | cdt | marker_id}
   -no-indexer Disable indexer
   -printErrorMarkers Print all error markers
   -I          {include_path} additional include_path to add to tools
   -include    {include_file} additional include_file to pass to tools
   -D          {prepoc_define} addition preprocessor defines to pass to the tools
   -E          {var=value} replace/add value to environment variable when running all tools
   -Ea         {var=value} append value to environment variable when running all tools
   -Ep         {var=value} prepend value to environment variable when running all tools
   -Er         {var} remove/unset the given environment variable
   -T          {toolid} {optionid=value} replace a tool option value in each configuration built
   -Ta         {toolid} {optionid=value} append to a tool option value in each configuration built
   -Tp         {toolid} {optionid=value} prepend to a tool option value in each configuration built
   -Tr         {toolid} {optionid=value} remove a tool option value in each configuration built
               Tool option values are parsed as a string, comma separated list of strings or a boolean based on the options type

Stm32cubeide:
JVM terminated. Exit code=1
/home/victor/st/stm32cubeide_1.8.0//plugins/com.st.stm32cube.ide.jre.linux64_2.0.100.202110150814/jre/bin/java
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=@user.home/STM32CubeIDE/workspace_1.8.0
-Declipse.buildId=Version 1.8.0
-DproductMaturityGrade=mm
-XX:+UseG1GC
-XX:+UseStringDeduplication
-Xms256m
-Xmx1024m
-jar /home/victor/st/stm32cubeide_1.8.0//plugins/org.eclipse.equinox.launcher_1.6.100.v20201223-0822.jar
-os linux
-ws gtk
-arch x86_64
-launcher /home/victor/st/stm32cubeide_1.8.0/stm32cubeide
-name Stm32cubeide
--launcher.library /home/victor/st/stm32cubeide_1.8.0//plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.100.v20210209-1541/eclipse_11301.so
-startup /home/victor/st/stm32cubeide_1.8.0//plugins/org.eclipse.equinox.launcher_1.6.100.v20201223-0822.jar
--launcher.overrideVmargs
-exitdata 2b8002
-application org.eclipse.cdt.managedbuilder.core.headlessbuild
-data ./
-build Core Drivers L073 - 100 pin.ioc Middlewares
-vm /home/victor/st/stm32cubeide_1.8.0//plugins/com.st.stm32cube.ide.jre.linux64_2.0.100.202110150814/jre/bin/java
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=@user.home/STM32CubeIDE/workspace_1.8.0
-Declipse.buildId=Version 1.8.0
-DproductMaturityGrade=mm
-XX:+UseG1GC
-XX:+UseStringDeduplication
-Xms256m
-Xmx1024m

-jar /home/victor/st/stm32cubeide_1.8.0//plugins/org.eclipse.equinox.launcher_1.6.100.v2020

公羊子丹 发表于 2025-9-29 07:26 | 显示全部楼层
你这个错误提示里,-build 后面跟的不是项目名,而是把子目录也写上了,IDE 解析不了。
周半梅 发表于 2025-9-29 07:27 | 显示全部楼层
可以先 -import 项目,再用 -build 项目名,不要写 Core、Drivers 这些。
帛灿灿 发表于 2025-9-29 07:28 | 显示全部楼层
我试过的命令是这样的:stm32cubeide -nosplash -application org.eclipse.cdt.managedbuilder.core.headlessbuild -data ./workspace -build 项目名。
童雨竹 发表于 2025-9-29 07:29 | 显示全部楼层
注意 项目名 必须和 .project 文件里 <name> 的内容一致,不是文件夹名。
万图 发表于 2025-9-29 07:30 | 显示全部楼层
其实最简单的办法是用 -build all,这样会构建整个 workspace 里的所有工程。
Wordsworth 发表于 2025-9-29 07:31 | 显示全部楼层
如果只是想编译,可以考虑直接调用 make,CubeIDE 会在 Debug/Release 目录里生成 Makefile。
Bblythe 发表于 2025-9-29 07:33 | 显示全部楼层
建议加上 -no-indexer,这样能加快编译速度,命令行模式下没必要启用索引器。
Pulitzer 发表于 2025-9-29 07:34 | 显示全部楼层
你这个 Exit code=1 主要还是参数问题,和 Java 虚拟机崩溃无关。
Uriah 发表于 2025-9-29 07:35 | 显示全部楼层
我之前在 CI/CD 里跑过,都是 -importAll + -build all,比较稳妥。
Clyde011 发表于 2025-9-29 07:36 | 显示全部楼层
要是觉得 CubeIDE 太麻烦,可以用 STM32CubeMX 生成代码,再自己维护 Makefile,配合 arm-none-eabi-gcc 编译会更轻量。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

55

主题

55

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部