gpt4 book ai didi

c++ - Iotivity : Build the C++ examples

转载 作者:太空宇宙 更新时间:2023-11-04 14:33:24 27 4
gpt4 key购买 nike

刚开始接触iotivity,一直在看文档。在 this setup page ,在标题running the c++ samples 下,它告诉我们如何运行这些示例,但在此之前我应该​​先构建它们并且它似乎是页面Build the C++ samples到,不见了。

当我尝试使用 g++ 以正常方式构建示例时,它给出了一些缺少 header 的错误,这意味着这不是正确的方法,或者会花费很多精力。

有人知道如何使用 iotivity release 构建示例数据包吗?

最佳答案

将以下 makefile 放在 iotivity/resource/examples 目录中:

IDIR=-I../include -I./../csdk/stack/include/ -I./../c_common/ -I./../oc_logger/include
CC=g++
CFLAGS=-Wall -std=c++11 $(IDIR) -loc -loctbstack -loc_logger -lpthread
SERV_OBJ = simpleserver.o
CLIENT_OBJ = simpleclient.o

%.o: %.cpp
$(CC) -c -o $@ $^ $(CFLAGS)

#Build the simpleserver executable
all:simpleserver simpleclient
simpleserver:$(SERV_OBJ)
$(CC) -o $@ $^ $(CFLAGS)

#Build the simpleclient executable
simpleclient:$(CLIENT_OBJ)
$(CC) -o $@ $^ $(CFLAGS)

然后在终端上点击make。然后在两个不同的终端上执行simpleclientsimpleserver。如果您收到错误:

./simpleclient: error while loading shared libraries: liboc.so: cannot open shared object file: No such file or directory

输入以下内容:

export LD_LIBRARY_PATH=../../out/linux/x86_64/release

关于c++ - Iotivity : Build the C++ examples,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37355134/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com