2016-05-20 33 views
1

我刚刚开始使用Iotivity并已阅读文档。在this setup page的标题下运行C++示例,它讲述了如何运行这些示例,但在此之前,我应该先构建这些示例,并且似乎页面Build the C++ samples所指的页面缺失。Iotivity:构建C++示例

当我尝试使用g++以正常方式构建示例时,它给出了一些缺少的标题错误,这意味着这不是正确的方式或将花费大量的努力。

是否有人知道如何使用iotivity发布构建示例包?

+0

@Amadeus:哎呀对不起......现在好了 –

+0

在你提供的链接上,没有标题**运行C++样本** – Amadeus

+0

@Amadeus:搜索**运行样本** –

回答

0

放入iotivity /资源/实例目录下面生成文件:

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 [email protected] $^ $(CFLAGS) 

#Build the simpleserver executable 
all:simpleserver simpleclient 
simpleserver:$(SERV_OBJ) 
    $(CC) -o [email protected] $^ $(CFLAGS) 

#Build the simpleclient executable 
simpleclient:$(CLIENT_OBJ) 
    $(CC) -o [email protected] $^ $(CFLAGS) 

,然后在终端上击中make。然后在两个不同的终端上执行simpleclientsimpleserver。如果你的错误:

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

检查支持这一页约IoTivity(和不支持的)例子:

https://wiki.iotivity.org/examples#

cd ${project_dir}/out/${TARGET_OS}/${TARGET_ARCH}/${BUILD_MODE}/resource/examples/ 
killall simpleserver simpleclient # make sure none are running 

./simpleserver 2>&1 | tee simpleserver.log.txt & 
./simpleclient 2>&1 | tee simpleclient.log.txt 

以下一些

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

类型C++的例子不能在1.3.0中工作,而1.2.1应该可以的

但是,如果你想从主树外部构建其他例子,我做了一个使用gnu make的专用项目。

希望这有助于

0

我研究了很多寻找到可执行文件获得了C++样本生成,终于找到了路径。

在64位的Ubuntu 14.04 LTS, 当iotivity如下建:

$ scons的

可执行文件获得路径/iotivity/out/linux/x86_64/release/resource/examples/iotivity/resource/examples这样你就可以创建了目前的代码只需去/iotivity/out/linux/x86_64/release/resource/examples并执行简单服务器(./simpleserver)和simpleclient(./simpleclient