1

I have just started with iotivity and have been reading the documentation. On this setup page, under the heading running the c++ samples, it tells how to run the examples, but before that I should build them first and it seems the page Build the C++ samples it refers to, is missing.

When I tried to build the examples in a normal way using g++, it gave some missing header errors, meaning that's not the right way or will take a lot of effort.

Do any one know how to build the examples packet with iotivity release?

Naveen
  • 7,944
  • 12
  • 78
  • 165

3 Answers3

0

Place the following makefile in the iotivity/resource/examples directory :

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)

and then hit make on the terminal. Then execute simpleclient and simpleserver on two different terminals. In case you get the error :

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

type the following:

export LD_LIBRARY_PATH=../../out/linux/x86_64/release
Naveen
  • 7,944
  • 12
  • 78
  • 165
0

I researched a lot to find where the executables get generated for the c++ samples, finally found the path.

On 64-bit Ubuntu 14.04 LTS , when iotivity is built as follows:

$ scons

the executables get created in path /iotivity/out/linux/x86_64/release/resource/examples for the code present in /iotivity/resource/examples so you can just go to /iotivity/out/linux/x86_64/release/resource/examples and execute simpleserver(./simpleserver) and simpleclient(./simpleclient)

Madhu
  • 16
  • 2
-2

Check this page about IoTivity supported (and unsupported) examples :

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 

Some c++ examples are not working in 1.3.0 while 1.2.1 should be ok

But if you want to build other examples from outside the main tree, I made a dedicated project that use gnu make.

Hope this helps

RzR
  • 3,068
  • 29
  • 26