我有一个带有代码的文件,它引用了一个库(include<
图书馆
>)。我创造了一个
生成文件
具有
nspire tools new(文件)
,并使用命令编译文件(colors.c)
制作
在终点站。将引发有关缺少引用/库的错误,并且它不会创建已编译的文件(即.elf、.o、.prg.tns和.tns)。
user@user-System-Product-Name:~/Ndless/ndless-sdk/samples/colors$ make
nspire-gcc -Wall -W -marm -Os -c colors.c -o colors.o
colors.c: In function âmainâ:
colors.c:6:2: warning: implicit declaration of function âlcd_incolorâ; did you mean âlcd_initâ? [-Wimplicit-function-declaration]
lcd_incolor();
^~~~~~~~~~~
lcd_init
In file included from /home/rico/Ndless/ndless-sdk/bin/../include/os.h:24,
from colors.c:1:
/home/rico/Ndless/ndless-sdk/bin/../include/libndls.h:164:95: error: expected â;â before â}â token
ASE_ADDRESS ({"SCREEN_BASE_ADDRESS got removed in favor of the lcd_blit API."})
^
colors.c:7:37: note: in expansion of macro âSCREEN_BASE_ADDRESSâ
volatile unsigned char *scr_base = SCREEN_BASE_ADDRESS;
^~~~~~~~~~~~~~~~~~~
/home/rico/Ndless/ndless-sdk/bin/../include/libndls.h:164:30: warning: pointer targets in initialization of âvolatile unsigned char *â from âchar *â differ in signedness [-Wpointer-sign]
#define SCREEN_BASE_ADDRESS ({"SCREEN_BASE_ADDRESS got removed in favor of the lcd_blit API."})
^
colors.c:7:37: note: in expansion of macro âSCREEN_BASE_ADDRESSâ
volatile unsigned char *scr_base = SCREEN_BASE_ADDRESS;
^~~~~~~~~~~~~~~~~~~
colors.c:9:22: error: âSCREEN_BYTES_SIZEâ undeclared (first use in this function); did you mean âSCREEN_BASE_ADDRESSâ?
unsigned scr_size = SCREEN_BYTES_SIZE;
^~~~~~~~~~~~~~~~~
SCREEN_BASE_ADDRESS
colors.c:9:22: note: each undeclared identifier is reported only once for each function it appears in
Makefile:30: recipe for target 'colors.o' failed
make: *** [colors.o] Error 1
我正在编译的这个文件是ndless sdk中包含的一个示例代码片段,我已经把这个示例项目中包含的其他文件放在了一起,这样我就可以测试编译主文件了。
由于这些示例已经过预编译,我决定看看是否将原始的.o文件放入与.c文件完全相同的目录文件夹中。我用上面提到的相同命令编译,没有
致命的
抛出了错误(只是抛出了其他api错误)。
user@user-System-Product-Name:~/Ndless/ndless-sdk/samples/colors$ make
mkdir -p .
nspire-ld colors.o -o colors.c.elf
genzehn --input colors.c.elf --output colors.c.tns.zehn --name "colors.c"
Warning: Your application does not appear to support 240x320px displays!
If it does, override with '--240x320-support true'.
make-prg colors.c.tns.zehn colors.c.tns
rm colors.c.tns.zehn
似乎阻止的.o文件使
制作
不创建新的.o文件,而是继续生成其他文件?如何修复这些错误并仅从colors.c生成必要的文件?
颜色.c
以下内容:
#include <os.h>
int main(void) {
if (!has_colors)
return 0;
lcd_incolor();
volatile unsigned char *scr_base = SCREEN_BASE_ADDRESS;
volatile unsigned char *ptr;
unsigned scr_size = SCREEN_BYTES_SIZE;
// See http://en.wikipedia.org/wiki/High_color -> "16-bit high color" for the encoding of the screen buffer
for (ptr = scr_base; ptr < scr_base + scr_size / 3; ptr += 2)
*(volatile unsigned short*)ptr = 0b1111100000000000;
for (; ptr < scr_base + scr_size * 2 / 3; ptr += 2)
*(volatile unsigned short*)ptr = 0b0000011111100000;
for (; ptr < scr_base + scr_size; ptr += 2)
*(volatile unsigned short*)ptr = 0b0000000000011111;
wait_key_pressed();
return 0;
}