我正在尝试在IMPINJ提供的辛烷值ETK示例应用程序(在C ++中)中包括PAHO MQTT 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;
您需要在每个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
。 else位于Makefile中(由@stark建议)。 make的大多数用户期望g++
编译规则会尊重此变量。
在Makefile的顶部添加:
CXXFLAGS = std=c++11
例如,您还可以附加任何其他需要的标志
CXXFLAGS = std=c++11 -O2 -DDEBUG