我正在尝试将PAHO MQTT C++库包含在IMPINJ提供的octane etk示例应用程序(用C++编写)中。
我已经按照impinj门户中给出的步骤创建了示例应用程序,并且能够读取标记信息,但是当我尝试在示例应用程序中包含PAHO MQTT库时,以及当我创建impinj提供的示例应用程序时,它会显示
root@mindlogic-VirtualBox:/home/user/octane_etk_sample-6.0.0.240# make
mkdir -p ./bin
g++ \
-m32 -Wno-write-strings \
-Iinclude \
speedway_embedded_example.cpp \
-Llib -lltkcpp_x86 -lltkcppimpinj_x86 -lxml2_x86 \
-L/usr/bin -ldl -lssl -lcrypto \
-o bin/speedwayr_x86
In file included from /usr/include/c++/4.8/chrono:35:0,
from /usr/local/include/mqtt/types.h:29,
from /usr/local/include/mqtt/async_client.h:29,
from speedway_embedded_example.cpp:23:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
In file included from include/ltkcpp.h:41:0,
from speedway_embedded_example.cpp:19:
include/version.inc:1:21: error: too many decimal points in number
#define VERSION_STR 10.34.0.0
^
In file included from /usr/local/include/mqtt/async_client.h:29:0,
from speedway_embedded_example.cpp:23:
/usr/local/include/mqtt/types.h:37:7: error: expected nested-name-specifier before ‘byte’
using byte = uint8_t;有人能帮我启用C++11吗?
下面是MakeFile的内容。
SOURCES = speedway_embedded_example.cpp
LIB_DIR = /usr/bin
MPNJ_LIB_DIR = lib
HEADER_DIR = include
ETK_DEFAULT_INSTALL_DIR = /home/etk/impinj_etk
INSTALL_TOOL_HELP = \
"Failed to find the arm-none-linux-gnueabi-g++ compiler." \
"Please make sure that /home/etk/impinj_etk/arm-toolchain/bin is in your PATH."
INSTALL_ETK_HELP = "Please follow the ETK install instructions and make sure that" \
"/home/etk/impinj_etk is in your PATH, or that the ETK_INSTALL_DIR is defined."
# The cap_gen tool may be in the PATH, the install dir, or in the current dir.
CAP_GEN_EXE = cap_gen.sh
CAP_GEN_IN_PATH=$(shell which $(CAP_GEN_EXE))
CAP_GEN_CWD=$(shell ls ./$(CAP_GEN_EXE) 2>/dev/null)
CAP_GEN_DEFAULT=$(shell ls $(ETK_DEFAULT_INSTALL_DIR)/$(CAP_GEN_EXE) 2>/dev/null)
ifneq (,$(CAP_GEN_IN_PATH))
CAP_GEN=$(CAP_GEN_IN_PATH)
else
ifneq (,$(ETK_INSTALL_DIR))
CAP_GEN=$(ETK_INSTALL_DIR)/$(CAP_GEN_EXE)
else
ifneq (,$(CAP_GEN_DEFAULT))
CAP_GEN=$(CAP_GEN_DEFAULT)
else
ifneq (,$(CAP_GEN_CWD))
CAP_GEN=$(CAP_GEN_CWD)
endif
endif
endif
endif
all: x86 arm
help:
@echo Example use:
@echo ‘make arm’ to build the sample for on-reader use
@echo ‘make x86’ to build the sample for the (x86) host
@echo ‘make cap’ to build a CAP upgrade file
bin/speedwayr_x86:
mkdir -p ./bin
g++ \
-m32 -Wno-write-strings \
-I$(HEADER_DIR) \
$(SOURCES) \
-L$(MPNJ_LIB_DIR) -lltkcpp_x86 -lltkcppimpinj_x86 -lxml2_x86 \
-L$(LIB_DIR) -ldl -lssl -lcrypto \
-o bin/speedwayr_x86
x86: bin/speedwayr_x86
bin/speedwayr_arm: check_env
mkdir -p ./bin
arm-none-linux-gnueabi-g++ \
-Wno-write-strings \
-I$(HEADER_DIR) \
$(SOURCES) \
-L$(MPNJ_LIB_DIR) \
-static -lltkcpp_atmel -lltkcppimpinj_atmel -lxml2_atmel \
-lssl_atmel -lcrypto_atmel -ldl_atmel \
-o bin/speedwayr_arm
arm-none-linux-gnueabi-strip bin/speedwayr_arm
arm: bin/speedwayr_arm
cap: arm check_env
$(CAP_GEN) -d cap_description.in -o speedwayr_cap.upg
clean:
rm -rf bin/*
rm -rf speedwayr_cap.upg
.PHONY: check_env
check_env:
@if ! which $(CAP_GEN_EXE) > /dev/null && \
[ ! -f $(ETK_INSTALL_DIR)/$(CAP_GEN_EXE) > /dev/null ] && \
[ ! -f ./$(CAP_GEN_EXE) > /dev/null ]; then \
echo "Failed to find $(CAP_GEN_EXE)."; \
echo $(INSTALL_ETK_HELP); \
exit 1; \
fi
@if ! which arm-none-linux-gnueabi-g++ > /dev/null; then \
echo $(INSTALL_TOOL_HELP); \
exit 1; \
fi注:--根据@Mikel Rychliski给出的建议,在Makefile中的每个g++上添加-std=c++11,并得到以下错误:
root@mindlogic-VirtualBox:/home/user/octane_etk_sample-6.0.0.240# make
mkdir -p ./bin
g++ \
-m32 -Wno-write-strings -std = c++11 \
-Iinclude \
speedway_embedded_example.cpp \
-Llib -lltkcpp_x86 -lltkcppimpinj_x86 -lxml2_x86 \
-L/usr/bin -ldl -lssl -lcrypto \
-o bin/speedwayr_x86
g++: error: =: No such file or directory
g++: error: c++11: No such file or directory
g++: error: unrecognized command line option ‘-std’
Makefile:45: recipe for target 'bin/speedwayr_x86' failed
make: *** [bin/speedwayr_x86] Error 1注2:添加-std=c++11时没有空格,得到的错误为
root@mindlogic-VirtualBox:/home/mindlogic/octane_etk_sample-6.0.0.240# make
mkdir -p ./bin
g++ \
-m32 -Wno-write-strings -std=c++11 \
-Iinclude \
speedway_embedded_example.cpp \
-Llib -lltkcpp_x86 -lltkcppimpinj_x86 -lxml2_x86 \
-L/usr/bin -ldl -lssl -lcrypto \
-o bin/speedwayr_x86
In file included from include/ltkcpp.h:32:0,
from speedway_embedded_example.cpp:19:
include/ltkcpp_base.h:97:5: error: ‘llrp_u16_t’ does not name a type
llrp_u16_t m_nValue;发布于 2020-04-14 22:18:42
您需要在每个g++命令行中添加-std=c++11:
g++ \
-m32 -Wno-write-strings -std=c++11 \
-I$(HEADER_DIR) \
$(SOURCES) \
-L$(MPNJ_LIB_DIR) -lltkcpp_x86 -lltkcppimpinj_x86 -lxml2_x86 \
-L$(LIB_DIR) -ldl -lssl -lcrypto \
-o bin/speedwayr_x86
arm-none-linux-gnueabi-g++ \
-Wno-write-strings -std=c++11 \
-I$(HEADER_DIR) \
$(SOURCES) \
-L$(MPNJ_LIB_DIR) \
-static -lltkcpp_atmel -lltkcppimpinj_atmel -lxml2_atmel \
-lssl_atmel -lcrypto_atmel -ldl_atmel \
-o bin/speedwayr_arm为了避免重复,您可以添加$(CXXFLAGS)并设置CXXFLAGS += -std=c++11。其他的在Makefile中(根据@stark的建议)。make的大多数用户都希望g++编译规则会遵守这个变量。
https://stackoverflow.com/questions/61208895
复制相似问题