是否可以在 contiki-cooja 模拟器中使用 math.h 库?我在 ubuntu 18.04 LTS 上使用 contiki 3.0
我尝试在 hello-world 应用程序的 makefile 中添加 LDFLAGS += -lm 。此外,我还尝试在 Makefile.include 文件中添加 -lm 。事情行不通。添加-lm的正确位置是什么?
你好世界.c
#include "contiki.h"
#include <stdio.h> /* For printf() /
#include <math.h>
#define DEBUG DEBUG_PRINT
static float i;
/---------------------------------------------------------------------------/
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
/---------------------------------------------------------------------------/
PROCESS_THREAD(hello_world_process, ev, data)
{
PROCESS_BEGIN();
i = 2.1;
printf("Hello, world\n");
printf("%i\n", (int)pow(10,i));
printf("%i\n", (int)(M_LOG2Ei));
PROCESS_END();
}
/---------------------------------------------------------------------------/
生成文件
CONTIKI_PROJECT = hello-world
all: $(CONTIKI_PROJECT)
CONTIKI = ../..
include $(CONTIKI)/Makefile.include
LDFLAGS += -lm