【问题标题】:<command-line>:0:1: error: macro names must be identifiers ........ Solution for this error?<command-line>:0:1: error: 宏名必须是标识符........ 这个错误的解决方法?
【发布时间】:2019-07-01 09:34:48
【问题描述】:

我正在尝试按照Github 上的本指南将 ssd1963 LCD 与 Raspberry Pi3 型号 B+ 连接。

https://github.com/matusnovak/rpi-tftgl

尝试在rpi-tftgl/tftgl 目录中安装为rpi-tftgl 提供的makefile 时,运行make 命令时出现此错误。 这是我捕获的 pi 终端窗口图像的链接,显示了确切的错误:

以下是我执行make 命令时收到的错误:

gcc -c src/tftgl.c -o src/tftgl.o -I/opt/vc/include -I. -Iinclude -D:0 -O3
<command-line>:0:1: error: macro names must be identifiers
Makefile:18: recipe for target 'src/tftgl.o' failed
make: *** [src/tftgl.o] Error 1

我是否可以为此获得解决方案或任何其他来源或链接的任何建议,我可以按照这些来源或链接来连接 ssd1963 LCD 并使用 Raspberrypi3 启用触摸。 添加makefile,

 CC=gcc
 AR=ar
 DISPLAY?=ERROR
 CFLAGS=-I/opt/vc/include -I. -Iinclude -D$(DISPLAY) -O3
 prefix?=/usr/local

 .PHONY: default all clean

  default: tftgl
  all: default

  tftgl: libtftgl.a

  libtftgl.a: src/tftgl.o
     $(AR) rcs libtftgl.a src/tftgl.o

  src/tftgl.o: src/tftgl.c src/tftgl_ssd1963.h src/tftgl_ads7843.h
     $(CC) -c src/tftgl.c -o src/tftgl.o $(CFLAGS)

  install: tftgl
     install -m 0755 libtftgl.a $(prefix)/lib
     install -m 0644 include/tftgl.h $(prefix)/include

  clean:
     -rm -f src/*.o
     -rm -f libtftgl.a

我在这里提供 tftgl.c 的链接, https://github.com/matusnovak/rpi-tftgl/blob/master/tftgl/src/tftgl.c

【问题讨论】:

  • 请显示代码和/或说明错误。请不要使用图片链接。问题中缺少文本。图片上的文字太小,有些人看不懂。图像上的文本无法被搜索引擎索引以供未来的访问者使用。另见Why not upload images of code on SO when asking a question?
  • -D0:0 不正确。多说,我们需要查看 Makefile 的相关部分以及可能的配置脚本。另见How to create a Minimal, Complete, and Verifiable example
  • @jww 我已经在代码块中添加了makefile,但是我不知道从哪里获取配置脚本。你能不能用它说点什么,这样我也明白我接下来要做什么。请帮我学习
  • 显示定义应该类似于CFLAGS=... -DDISPLAY="$(DISPLAY)"(可能带有一些额外的箍来保留引号)。这只是一个猜测。我们需要看看它是如何在src/tftgl.c 中使用的。
  • @jww 我尝试使用您的建议更改生成文件并收到以下错误,gcc -c src/tftgl.c -o src/tftgl.o -I/opt/vc/include -I . -Iinclude --DDISPLAY=":0" gcc: error: unrecognized command line option '--DDISPLAY=:0' Makefile:18: recipe for target 'src/tftgl.o' failed make: *** [src/tftgl .o] 错误 1

标签: linux raspberry-pi3


【解决方案1】:

Makefile 的(作者)没有考虑到环境变量DISPLAY 可以定义为宏定义以外的其他内容。由于没有记录您是否需要以及如何定义它,您可以做的最好的事情是 make 使用未设置的变量:

(unset DISPLAY; make)

如果您希望更改 makefile,只需从 DISPLAY?=ERROR 中删除 ?,留下 DISPLAY=ERROR

【讨论】:

  • 先生,我应该在 makefile 中进行此更改吗? -D$(unset DISPLAY) -O3 或此处定义的 DISPLAY。取消设置显示?=错误
  • @Shreyansh Dubey - 此更改将在您启动 make 的终端命令行上使用。我用 makefile 中的替代更改修改了答案。
  • 谢谢我去试试
猜你喜欢
  • 2012-06-02
  • 2010-09-30
  • 1970-01-01
  • 1970-01-01
  • 2023-02-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多