2016-05-20 82 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