物联网性:构建C++示例
Iotivity : Build the C++ examples
我刚刚开始使用 iotivity,并且一直在阅读文档。在此设置页面上,在运行 c++ 示例的标题下,它讲述了如何运行示例,但在此之前,我应该先构建它们,它所引用的页面似乎Build the C++ samples
缺失。
当我尝试使用 g++
以正常方式构建示例时,它给出了一些缺失的标头错误,这意味着这不是正确的方法或需要付出很多努力。
有没有人知道如何使用物联网发布构建示例数据包?
将以下生成文件放在 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
。然后在两个不同的终端上执行simpleclient
和simpleserver
。如果您收到错误:
./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++ 示例生成可执行文件的位置,最终找到了路径。
在 64 位 Ubuntu 14.04 LTS 上,当 IoT 构建如下时:
$ 斯康斯
可执行文件在路径 /iotivity/out/linux/x86_64/release/resource/examples
中为 /iotivity/resource/examples
中存在的代码创建,因此您只需转到/iotivity/out/linux/x86_64/release/resource/examples
并执行 simpleserver(./simpleserver) 和 simpleclient(./simpleclient)
查看此页面,了解 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
一些 c++ 示例在 1.3.0 中不起作用,而 1.2.1 应该没问题
但是如果你想从主树之外构建其他示例,我做了一个使用 gnu make 的专用项目。
希望这有帮助
- 激励'inline'说明符的真实世界示例?
- 为什么示例代码访问IUnknown中已删除的内存
- 以下示例中如何避免代码复制?C++/库达
- "类模板示例<int>;"语句对 C++11 是什么意思?
- 示例C++项目编译中的警告
- 示例外壳应用程序显示的 V8 "segmentation fault (core dumped)"错误
- 当Microsoft文档仅包含 C# 示例时,如何查找 C++ 包含文件名
- 在简单示例中,Python3 + ctypes 回调会导致内存泄漏
- 为什么理解这个递归示例如此难以转化为直觉?
- Eventloop 卡住:NAO C++ SDK OnFaceDetection 示例
- 如何替换此示例代码片段中已弃用的handler_type_t或 boost::asio::handler_type?
- 适用于 WebView2 旧版本的示例应用程序
- 即使直接从官方示例中复制,也找不到未知类型名称QML_ELEMENT和 QML 模块
- 将数组/向量发送到 c++ 脚本的 cython 示例
- 了解提升执行器示例
- 请求最简单的 OpenMP 目标 GPU 示例
- 两种模板示例有什么区别?
- 有人可以在下面的示例 C++ 程序中解释字符数组 KCHAR1 的奇怪行为吗?
- Distirbute Candy - 查找问题的最小可重现示例
- Frank Luna 在他的书"使用 DirectX12 进行 3D 游戏编程"的介绍中盒子示例的问题