一、错误现象
在虚拟机环境下使用LVGL仿真器进行开发时,对仿真器源代码执行编译操作过程中出现了报错信息。
cc: error: unrecognized command line option ‘-Wshift-negative-value'
cc: error: unrecognized command line option ‘-Wshift-negative-value'
cc: error: unrecognized command line option ‘-Wshift-negative-value'
Building project file: lvgl/examples/widgets/chart/lv_example_chart_6.c
Makefile:45: recipe for target 'build/obj/lvgl/examples/widgets/list/lv_example_list_1.o' failed
make: *** [build/obj/lvgl/examples/widgets/list/lv_example_list_1.o] Error 1
make: *** 正在等待未完成的任务....
Makefile:45: recipe for target 'build/obj/lvgl/examples/widgets/spinner/lv_example_spinner_1.o' failed
make: *** [build/obj/lvgl/examples/widgets/spinner/lv_example_spinner_1.o] Error 1
Makefile:45: recipe for target 'build/obj/lvgl/examples/widgets/led/lv_example_led_1.o' failed
make: *** [build/obj/lvgl/examples/widgets/led/lv_example_led_1.o] Error 1
cc: error: unrecognized command line option ‘-Wshift-negative-value'
Makefile:45: recipe for target 'build/obj/lvgl/examples/widgets/textarea/lv_example_textarea_3.o' failed
make: *** [build/obj/lvgl/examples/widgets/textarea/lv_example_textarea_3.o] Error 1
cc: error: unrecognized command line option ‘-Wshift-negative-value'
Makefile:45: recipe for target 'build/obj/lvgl/examples/widgets/textarea/lv_example_textarea_2.o' failed
make: *** [build/obj/lvgl/examples/widgets/textarea/lv_example_textarea_2.o] Error 1
cc: error: unrecognized command line option ‘-Wshift-negative-value'
cc: error: unrecognized command line option ‘-Wshift-negative-value'
Makefile:45: recipe for target 'build/obj/lvgl/examples/widgets/textarea/lv_example_textarea_1.o' failed
make: *** [build/obj/lvgl/examples/widgets/textarea/lv_example_textarea_1.o] Error 1
Makefile:45: recipe for target 'build/obj/lvgl/examples/widgets/checkbox/lv_example_checkbox_1.o' failed
make: *** [build/obj/lvgl/examples/widgets/checkbox/lv_example_checkbox_1.o] Error 1
cc: error: unrecognized command line option ‘-Wshift-negative-value'
Makefile:45: recipe for target 'build/obj/lvgl/examples/widgets/chart/lv_example_chart_6.o' failed
make: *** [build/obj/lvgl/examples/widgets/chart/lv_example_chart_6.o] Error 1
编译无法进行
二、错误分析
根据系统返回的错误提示进行分析,其中cc命令报出error错误,检查Makefile文件后发现其调用的是gcc编译器。

错误详情显示unrecognized command line option ‘-Wshift-negative-value’,即编译器无法识别该命令行参数。由此推断原因可能是当前安装的GCC版本过低,不支持此指令。解决思路包括升级GCC版本或直接从配置中删除该指令以验证是否能正常运行。
三、错误解决
首先尝试直接删除相关指令来排除干扰,使用grep命令定位该指令在配置文件中的具体行号。
grep -n "\-Wshift\-negative\-value" Makefile

打开对应文件编辑器,定位到指定行并删除该指令。
vim make file

保存修改后的文件,重新触发程序编译流程。

编译任务成功完成,随后执行demo程序,确认功能可正常运行:

至此关于Linux编译LVGL仿真器出错问题的解决方法介绍完毕,更多相关Linux LVGL仿真器出错内容请搜索本站以前的文章或继续浏览下面的相关文章希望大家以后多多支持本站!