如何在Contiki OS中运行hello-world?

时间:2015-09-15 23:16:05

标签: c contiki

我是contiki os的新手,我尝试编译并运行位于contiki os 3.0的examples目录中的hello-world.c文件。但我得到了错误,

  

hello-world.c:40:21:致命错误:contiki.h:没有这样的文件或目录"。

我在root用户中尝试了这个。

enter image description here

任何有助于在contiki运行非常初学者计划的帮助表示赞赏。

2 个答案:

答案 0 :(得分:0)

使用make命令构建Contiki。这样做会调用特定于体系结构的gcc版本,其编译器标志指向正确的头文件路径:

默认情况下,make将为“本机”平台(即x86)构建,并创建可在主机PC上执行的应用程序映像。

要为特定硬件平台构建,请设置TARGET变量。例如,为Tmote Sky / TelosB节点构建:

make TARGET=sky hello-world

构建并运行本机平台:

make

输出:

TARGET not defined, using target 'native'
mkdir obj_native
...
CC        hello-world.c
LD        hello-world.native
rm hello-world.co

运行它:

./hello-world.native 

输出:

 Contiki-3.x-1457-g552408b started with IPV6, RPL
 Rime started with address 1.2.3.4.5.6.7.8
 MAC nullmac RDC nullrdc NETWORK sicslowpan
 Tentative link-local IPv6 address fe80:0000:0000:0000:0302:0304:0506:0708
 Hello, world

答案 1 :(得分:0)

感谢所有帮助回答我问题的人。最后,我能够在Contiki OS中运行第一个hello-world程序。我使用了以下代码语法。

$cd contiki
$cd examples/hello-world
$make TARGET=native

要运行已编译的代码,请使用以下代码。

$ ./hello-world.native

Out put:

Contiki 3.0 started with IPV6, RPL
Rime started with address 1.2.3.4.5.6.7.8
MAC nullmac RDC nullrdc NETWORK sicslowpan
Tentative link-local IPv6 address fe80:0000:0000:0000:0302:0304:0506:0708
Hello, world
相关问题