Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Cross compilation std::to_string error based on OpenWRT toolchain #77

Closed
CarlosHua opened this issue Aug 15, 2017 · 19 comments
Closed

Cross compilation std::to_string error based on OpenWRT toolchain #77

CarlosHua opened this issue Aug 15, 2017 · 19 comments

Comments

@CarlosHua
Copy link

As Amazon-Ori Neidich/Clint Ory mentioned, file the ticket directly here, so
We got the compilation error on std::to_string function when porting AVS SDK-v1.0. We have try our cross compiler of gcc version as 4.8.3 and 5.2.0. But the error persists based on these gcc version. The to_string function supported since gcc4.8.0 standard C++ 11 which is means that our current version should meet the requirements.

But we still got an error based on OpenWRT toolchain with uClibc, please help on it. Thanks.

There is cmake with the compiler options,

-DCMAKE_CXX_FLAGS="-g -std=c++11 -Wall"
-DCMAKE_BUILD_TYPE="MINSIZEREL"
-DCMAKE_INSTALL_PREFIX=/usr
-DCURL_LIBRARY="$(TOP)/curl-7.54.1/lib/.libs/libcurl.so.4.4.0"
-DCURL_INCLUDE_DIR="$(TOP)/curl-7.54.1/include/"
-DDOXYGEN_EXECUTABLE="$(STAGEDIR)/usr/bin/doxygen"
-DSQLITE_sqlite3_LIBDIR="$(TOP)/sqlite-3.19.3/.libs/libsqlite3.so.0"
-DSQLITE_LIBDIR="$(TOP)/sqlite-3.19.3/.libs/libsqlite3.so.0"
-DSQLITE_INCLUDEDIR="$(TOP)/sqlite-3.19.3/"

Compiler error log as follows,
carlos@SW5-Server-50:~/Working/release/asuswrt/release/src-qca-dakota/router$ make alexa-client
"CLM In /wl/clm/src/ NOT CREATING new clm_blob ..."
rm -rf alexa-client-build && mkdir -p alexa-client-build && cd alexa-client-build &&
cmake ../alexa-client-v1.0
-DCMAKE_CXX_FLAGS="-g -std=c++11 -Wall"
-DCMAKE_BUILD_TYPE="MINSIZEREL"
-DCMAKE_INSTALL_PREFIX=/usr
-DCURL_LIBRARY="/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/curl-7.54.1/lib/.libs/libcurl.so.4.4.0"
-DCURL_INCLUDE_DIR="/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/curl-7.54.1/include/"
-DDOXYGEN_EXECUTABLE="/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/arm-uclibc/stage/usr/bin/doxygen"
-DSQLITE_sqlite3_LIBDIR="/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/sqlite-3.19.3/.libs/libsqlite3.so.0"
-DSQLITE_LIBDIR="/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/sqlite-3.19.3/.libs/libsqlite3.so.0"
-DSQLITE_INCLUDEDIR="/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/sqlite-3.19.3/"
-- The CXX compiler identification is GNU 4.8.3
-- Check for working CXX compiler: /opt/openwrt-gcc483.arm/bin/arm-openwrt-linux-uclibcgnueabi-g++
-- Check for working CXX compiler: /opt/openwrt-gcc483.arm/bin/arm-openwrt-linux-uclibcgnueabi-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Creating the build directory for the AlexaClientSDK with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
CMake Warning (dev) at ThirdParty/googletest-release-1.8.0/CMakeLists.txt:3 (project):
Policy CMP0048 is not set: project() command manages VERSION variables.
Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH

This warning is for project developers. Use -Wno-dev to suppress it.

-- The C compiler identification is GNU 4.8.3
-- Check for working C compiler: /opt/openwrt-gcc483.arm/bin/arm-openwrt-linux-uclibcgnueabi-gcc
-- Check for working C compiler: /opt/openwrt-gcc483.arm/bin/arm-openwrt-linux-uclibcgnueabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Warning (dev) at ThirdParty/googletest-release-1.8.0/googlemock/CMakeLists.txt:40 (project):
Policy CMP0048 is not set: project() command manages VERSION variables.
Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH

This warning is for project developers. Use -Wno-dev to suppress it.

-- The C compiler identification is GNU 4.8.3
-- Check for working C compiler: /opt/openwrt-gcc483.arm/bin/arm-openwrt-linux-uclibcgnueabi-gcc
-- Check for working C compiler: /opt/openwrt-gcc483.arm/bin/arm-openwrt-linux-uclibcgnueabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Warning (dev) at ThirdParty/googletest-release-1.8.0/googlemock/CMakeLists.txt:40 (project):
Policy CMP0048 is not set: project() command manages VERSION variables.
Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH

This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at ThirdParty/googletest-release-1.8.0/googletest/CMakeLists.txt:47 (project):
Policy CMP0048 is not set: project() command manages VERSION variables.
Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH

This warning is for project developers. Use -Wno-dev to suppress it.

-- Found PythonInterp: /usr/local/bin/python (found version "2.7.9")
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found CURL: /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/curl-7.54.1/lib/.libs/libcurl.so.4.4.0 (found suitable version "7.54.1", minimum required is "7.43.0")
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
Creating the build directory for the ACL with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
Creating the build directory for the AuthDelegate with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
Creating the build directory for the ADSL with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
Creating the build directory for the AFML with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
Creating the build directory for the ContextManager with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
Creating the build directory for the MediaPlayer with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
GStreamer based media player will not be built.
Creating the build directory for the PlaylistParser with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
Totem-Pl-Parser based playlist parser will not be built, and the playlist parser is disabled.
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
Creating the build directory for the CapabilityAgents with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
Creating the build directory for the AIP with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
Creating the build directory for the Alerts with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- checking for module 'sqlite3'
-- found sqlite3, version 3.19.3
Creating the build directory for the AudioPlayer with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
Creating the build directory for the SpeechSynthesizer with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
Creating the build directory for the Integration with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
-- Please fill /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-build/Integration/AlexaClientSDKConfig.json before you execute integration tests.
Creating the build directory for the ApplicationUtilities with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
Creating the build directory for the DefaultClient with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
Creating the build directory for the SampleApp with build type: MINSIZEREL
No keyword detector type specified, skipping build of keyword detector.
/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/arm-uclibc/stage/usr/bin/doxygen: /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/arm-uclibc/stage/usr/bin/doxygen: cannot execute binary file
-- Found Doxygen: /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/arm-uclibc/stage/usr/bin/doxygen
-- Configuring done
-- Generating done
-- Build files have been written to: /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-build
make -C alexa-client-build && make alexa-client-build-stage
make[1]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' make[2]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' Scanning dependencies of target gmock make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' [ 0%] Building CXX object ThirdParty/googletest-release-1.8.0/googlemock/CMakeFiles/gmock.dir/__/googletest/src/gtest-all.cc.o [ 1%] Building CXX object ThirdParty/googletest-release-1.8.0/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o Linking CXX static library libgmock.a make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
[ 1%] Built target gmock
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' Scanning dependencies of target gmock_main make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' [ 2%] Building CXX object ThirdParty/googletest-release-1.8.0/googlemock/CMakeFiles/gmock_main.dir/__/googletest/src/gtest-all.cc.o [ 2%] Building CXX object ThirdParty/googletest-release-1.8.0/googlemock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.o [ 3%] Building CXX object ThirdParty/googletest-release-1.8.0/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o Linking CXX static library libgmock_main.a make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
[ 3%] Built target gmock_main
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' Scanning dependencies of target gtest make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' [ 4%] Building CXX object ThirdParty/googletest-release-1.8.0/googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o Linking CXX static library libgtest.a make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
[ 4%] Built target gtest
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' Scanning dependencies of target gtest_main make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' [ 5%] Building CXX object ThirdParty/googletest-release-1.8.0/googlemock/gtest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o Linking CXX static library libgtest_main.a make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
[ 5%] Built target gtest_main
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' Scanning dependencies of target AVSCommon make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' [ 5%] Building CXX object AVSCommon/CMakeFiles/AVSCommon.dir/AVS/src/AlexaClientSDKInit.cpp.o [ 6%] Building CXX object AVSCommon/CMakeFiles/AVSCommon.dir/AVS/src/Attachment/Attachment.cpp.o In file included from /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/SDS/SharedDataStream.h:468:0, from /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/SDS/InProcessSDS.h:27, from /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/AVS/include/AVSCommon/AVS/Attachment/Attachment.h:27, from /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/AVS/src/Attachment/Attachment.cpp:18: /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/SDS/BufferLayout.h: In member function 'bool alexaClientSDK::avsCommon::utils::sds::SharedDataStream<T>::BufferLayout::attach()': /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/SDS/BufferLayout.h:514:43: error: 'to_string' is not a member of 'std' .d("expectedMagicNumber", std::to_string(MAGIC_NUMBER))); ^ /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/SDS/BufferLayout.h:521:39: error: 'to_string' is not a member of 'std' .d("expectedVersion", std::to_string(VERSION))); ^ make[3]: *** [AVSCommon/CMakeFiles/AVSCommon.dir/AVS/src/Attachment/Attachment.cpp.o] Error 1 make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[2]: *** [AVSCommon/CMakeFiles/AVSCommon.dir/all] Error 2
make[2]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' make[1]: *** [all] Error 2 make[1]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make: *** [alexa-client] Error 2

@alexsalnikov
Copy link

alexsalnikov commented Aug 15, 2017

std::string to_string ( added since c++ 11)
Try simple tests
create a file test.cpp
inside file

#include <string>
int main()
{
    std::to_string(0);
    return 0;
}

now try to compile this code with
$ g++ -std=c++11 -Wall test.cpp -o test

do you get same compile errors ?
if yes your compiler doesn't support c++11
find why or you can have workaround
like

namespace std {
    template<typename T>
    std::string to_string(const T &n) {
        std::ostringstream s;
        s << n;
        return s.str();
    }
}

@dhpp
Copy link
Contributor

dhpp commented Aug 15, 2017

Hi there - you may also want to confirm your dependencies are up to date, and pass -std=c++11 to the compiler.

This has also been reported by others per the following links, and suggests either gcc 4.8.1 is simply non-compliant to the C++11 std::string, or you need to invoke it differently:

https://stackoverflow.com/questions/12975341/to-string-is-not-a-member-of-std-says-g-mingw
https://stackoverflow.com/questions/20534679/is-gcc-4-8-1-c11-complete

Let us know if the problem persists, thanks.

@CarlosHua
Copy link
Author

Thanks for the reply.
We have try the simple test.cpp based on our cross compiler with "g++ -std=c++11 -Wall" option, still got the same error. So try to workaround, I create patch_to_string.h,then put it at

  • alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/patch_to_string.h

and the code as follows,

`
#ifndef __PATCH_TO_STRING_H__
#define __PATCH_TO_STRING_H__
#include <sstream>

namespace std  {
    template<typename T>
    std::string to_string(const T &n) {
            std::ostringstream s;
            s << n;
            return s.str();
    }
}

#endif
`
Then let used function of "std::to_string" files to include patch_to_string.h header file such as following

  • alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/SDS/BufferLayout.h
  • alexa-client-v1.0/AVSCommon/AVS/test/ExceptionEncounteredSenderTest.cpp

It's seems can avoided "to_string' is not a member of 'std'" error in BufferLayout.h and ExceptionEncounteredSenderTest.cpp files, but got an another error regarding undefined reference to `alexaClientSDK::xxxxxx, due to unfamiliarity with the alexa SDK, have any suggestion on it. Thanks.

Error log:
...
[ 39%] Built target LogEntryStreamTest
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' Scanning dependencies of target LoggerTest make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' [ 40%] Building CXX object AVSCommon/Utils/test/CMakeFiles/LoggerTest.dir/LoggerTest.cpp.o Linking CXX executable LoggerTest make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
[ 40%] Built target LoggerTest
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' Scanning dependencies of target SharedDataStreamTest make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' [ 41%] Building CXX object AVSCommon/Utils/test/CMakeFiles/SharedDataStreamTest.dir/SharedDataStreamTest.cpp.o Linking CXX executable SharedDataStreamTest CMakeFiles/SharedDataStreamTest.dir/SharedDataStreamTest.cpp.o: In function alexaClientSDK::avsCommon::utils::sds::SharedDataStreamalexaClientSDK::avsCommon::utils::sds::test::MinimalTraits::BufferLayout::attach()':
/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/SDS/BufferLayout.h:562: undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStream<alexaClientSDK::avsCommon::utils::sds::test::MinimalTraits>::BufferLayout::MAGIC_NUMBER' /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/SDS/BufferLayout.h:562: undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStreamalexaClientSDK::avsCommon::utils::sds::test::MinimalTraits::BufferLayout::VERSION'
CMakeFiles/SharedDataStreamTest.dir/SharedDataStreamTest.cpp.o: In function alexaClientSDK::avsCommon::utils::sds::SharedDataStream<alexaClientSDK::avsCommon::utils::sds::test::MinimalTraits2>::BufferLayout::attach()': /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/SDS/BufferLayout.h:562: undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStreamalexaClientSDK::avsCommon::utils::sds::test::MinimalTraits2::BufferLayout::MAGIC_NUMBER'
/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/AVSCommon/Utils/include/AVSCommon/Utils/SDS/BufferLayout.h:562: undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStream<alexaClientSDK::avsCommon::utils::sds::test::MinimalTraits2>::BufferLayout::VERSION' collect2: error: ld returned 1 exit status make[3]: *** [AVSCommon/Utils/test/SharedDataStreamTest] Error 1 make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[2]: *** [AVSCommon/Utils/test/CMakeFiles/SharedDataStreamTest.dir/all] Error 2
make[2]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' make[1]: *** [all] Error 2 make[1]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make: *** [alexa-client] Error 2
Thanks for your support.

@alexsalnikov
Copy link

alexsalnikov commented Aug 16, 2017

in ExceptionEncounteredSenderTest.cpp
they create UnitTest case with another SharedDataStream
with different MAGIC_NUMBER and VERSION and try to see
that code below will verify proper MAGIC_NUMBER (otherwise print some error)
forget about std::to_string conversion that just converts uint32_t to string

BufferLayout.h

template <typename T>
bool SharedDataStream<T>::BufferLayout::attach() {
    // Verify compatibility.
    auto header = getHeader();
    if (header->magic != MAGIC_NUMBER) {
        logger::acsdkError(logger::LogEntry(TAG, "attachFailed")
                .d("reason", "magicNumberMismatch")
                .d("magicNumber", header->magic)
                .d("expectedMagicNumber", std::to_string(MAGIC_NUMBER)));
        return false;
    }
    if (header->version != VERSION) {
        logger::acsdkError(logger::LogEntry(TAG, "attachFailed")
                .d("reason", "incompatibleVersion")
                .d("version", header->version)
                .d("expectedVersion", std::to_string(VERSION)));
        return false;
    }
    if (header->traitsNameHash != stableHash(T::traitsName)) {
        logger::acsdkError(logger::LogEntry(TAG, "attachFailed")
                .d("reason", "traitsNameHashMismatch")
                .d("hash", header->traitsNameHash)
                .d("expectedHash", stableHash(T::traitsName)));
        return false;
    }

make this modification

BufferLayout.h

template <typename T>
bool SharedDataStream<T>::BufferLayout::attach() {
    // Verify compatibility.
    auto header = getHeader();
    if (header->magic != MAGIC_NUMBER) {
        logger::acsdkError(logger::LogEntry(TAG, "attachFailed")
                .d("reason", "magicNumberMismatch")
                .d("magicNumber", header->magic)
                .d("expectedMagicNumber", "0x53445348")));  // just expects text
        return false;
    }
    if (header->version != VERSION) {
        logger::acsdkError(logger::LogEntry(TAG, "attachFailed")
                .d("reason", "incompatibleVersion")
                .d("version", header->version)
                .d("expectedVersion", "0"));  //just expects text
        return false;
    }
    if (header->traitsNameHash != stableHash(T::traitsName)) {
        logger::acsdkError(logger::LogEntry(TAG, "attachFailed")
                .d("reason", "traitsNameHashMismatch")
                .d("hash", header->traitsNameHash)
                .d("expectedHash", stableHash(T::traitsName)));
        return false;
    }

maybe this conversion doesn't fit here

namespace std  {
    template<typename T>
    std::string to_string(const T &n) {
            std::ostringstream s;
            s << n;
            return s.str();
    }
}

you may need to make more specific conversion for each type
without template

string to_string(int val);
string to_string(unsigned val);
string to_string(long val);
string to_string(unsigned long val);
string to_string(long long val);
string to_string(unsigned long long val);
string to_string(float val);
string to_string(double val);
string to_string(long double val);

@dhpp
Copy link
Contributor

dhpp commented Aug 16, 2017

Thanks both for following up on this. Yes, this looks like a C++11 feature that was missed in at least GCC 4.8.1. Your workarounds for using that compiler, as posted above, look correct.

If you have further issues, would you consider updating gcc to at least 4.8.5? We've identified this as a minimum version with which you can fully compile our SDK code.

Please continue to update this thread if the above solutions are not sufficient, thanks.

@CarlosHua
Copy link
Author

Thanks for reply and check.
Actually I'm very confuse that we have using gcc 5.2.0 the toolchain generate by Qualcomm OpenWrt SDK, not sure why still missed standard function to_string.

Make changes in BufferLayout.h provide by alexsalnikov, seems can fix this compilation error. Hope it may not caused any side effect. Thanks.

That's means Alexa SDK can keep going compiler, but got an error as follows,

[ 74%] Built target AudioInputProcessorTest
make[3]: Entering directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build' Scanning dependencies of target Alerts make[3]: Leaving directory /home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
make[3]: Entering directory `/home/carlos/Working/release/asuswrt/release/src/router/alexa-client-build'
[ 75%] Building CXX object CapabilityAgents/Alerts/src/CMakeFiles/Alerts.dir/Renderer/Renderer.cpp.o
[ 75%] Building CXX object CapabilityAgents/Alerts/src/CMakeFiles/Alerts.dir/Storage/SQLiteAlertStorage.cpp.o
In file included from /home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/CapabilityAgents/Alerts/src/Storage/SQLiteAlertStorage.cpp:19:0:
/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.0/CapabilityAgents/Alerts/include/Alerts/Storage/SQLiteAlertStorage.h:23:21: fatal error: sqlite3.h: No such file or directory
compilation terminated.

Apparently, error on sqlite3.h can't found. I have check our environment, the header bas been in sqlite-3.19.3 dir. And do cmake with these options in makefile:

    rm -rf alexa-client-build && mkdir -p alexa-client-build && cd alexa-client-build && \
    cmake ../alexa-client-v1.0 \
    -DCMAKE_CXX_FLAGS="-g -std=c++11 -Wall -ldl" \
    -DCMAKE_BUILD_TYPE="MINSIZEREL" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCURL_LIBRARY="$(TOP)/curl-7.54.1/lib/.libs/libcurl.so.4.4.0" \
    -DCURL_INCLUDE_DIR="$(TOP)/curl-7.54.1/include/" \
    -DDOXYGEN_EXECUTABLE="$(STAGEDIR)/usr/bin/doxygen" \
    -DSQLITE_sqlite3_LIBDIR="$(TOP)/sqlite-3.19.3/.libs/libsqlite3.so.0" \
    -DSQLITE_sqlite3_INCLUDEDIR="$(TOP)/sqlite-3.19.3/" \
    -DSQLITE_LIBDIR="$(TOP)/sqlite-3.19.3/.libs/libsqlite3.so.0" \
    -DSQLITE_CFLAGS_I="-I $(TOP)/sqlite-3.19.3/" \
    -DSQLITE_CFLAGS="-I $(TOP)/sqlite-3.19.3/" \
    -DCMAKE_EXE_LINKER_FLAGS_MINSIZEREL="-I $(STAGEDIR)/usr/include/" \
    -DSQLITE_INCLUDEDIR="$(TOP)/sqlite-3.19.3/"

I have add regrading sqlite options with camke build. Is there anything missing? I can see compiler message as shown
-- checking for module 'sqlite3'
-- found sqlite3, version 3.19.3

Here is CMakeCache.txt
not sure why SQLITE_CFLAGS still null in CMakeCache.txt. Thanks.

@dhpp
Copy link
Contributor

dhpp commented Aug 17, 2017

Hi Carlos.

std::to_string is a utility function within the C++11 Standard Library, whose purpose is to convert various types into a std::string, so you shouldn't expect any side-effects from the implementation suggested above, especially since it will use an equivalent library implementation.

Your sqlite3.h issue looks like your include paths are not correct. If the file exists in your build environment, then either check that it's not hidden from the build by file / directory permissions, and also that your include dir:

"$(TOP)/sqlite-3.19.3/"

really expands to the directory you think it does. Per your CMakeCache.txt, this reads as:

/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/sqlite-3.19.3/

Let us know if this helps.

@CarlosHua
Copy link
Author

Hi dhpp,

Thanks for your help.
I expect that include dir path as
/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/sqlite-3.19.3/
this directory is correct which is mean "$(TOP)/sqlite-3.19.3/"

So I do not know which cmake options are missing or perhaps caused by other errors.

@CarlosHua
Copy link
Author

Hi
Due to blocking on sqlite3.h: No such file or directory error, during the this time, I also try Alexa SKD v1.1 and apply the to_string.patch provide by alexsalnikov/dhpp to fix std::to_string compilation error. however still got error as follows,

[ 19%] Building CXX object AVSCommon/CMakeFiles/AVSCommon.dir/Utils/src/Logger/LoggerSinkManager.cpp.o
[ 20%] Building CXX object AVSCommon/CMakeFiles/AVSCommon.dir/Utils/src/Logger/LoggerUtils.cpp.o
/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.1/AVSCommon/Utils/src/Logger/LoggerUtils.cpp: In function 'std::__cxx11::string alexaClientSDK::avsCommon::utils::logger::formatLogString(alexaClientSDK::avsCommon::utils::logger::Level, std::chrono::_V2::system_clock::time_point, const char*, const char*)':
/home/carlos/Working/release/asuswrt/release/src-qca-dakota/router/alexa-client-v1.1/AVSCommon/Utils/src/Logger/LoggerUtils.cpp:135:90: error: 'snprintf' was not declared in this scope
if (snprintf(millisString, sizeof(millisString), MILLIS_FORMAT_STRING, timeMillisPart) < 0) {
^
make[3]: *** [AVSCommon/CMakeFiles/AVSCommon.dir/Utils/src/Logger/LoggerUtils.cpp.o] Error 1

Thanks.

@dhpp
Copy link
Contributor

dhpp commented Aug 18, 2017

Hi Carlos,

The error you're getting tells us that the file LoggerUtils.cpp is missing a required include, and it would seem that our own test and build environment did not require us to explicitly include it.

Please add this line:

#include <stdio.h>

just before the namespace declarations in that file. I'll also have our SDK updated for the next release to include this header. This will resolve your snprintf error.

Thanks for helping us identify these issues. Please let us know if you have any further problems, or if you now get a complete build.

@dhpp
Copy link
Contributor

dhpp commented Aug 18, 2017

Hi Carlos - sorry I skipped over your earlier post with respect to sqlite3.h. This reads to me as simply an include directory issue. For some reason, the directory where the file is located cannot be accessed by your build tools.

This is either caused by misconfigured CMake instructions (particularly telling it which directories to look for header files), or some other aspect of your build environment.

I find in cases like this an easy way to debug is to try moving the problematic header file somewhere else, where you know other files are being included OK, to see if that works. If it doesn't you have other problems. If it does work, then you can either decide to simply place the file somewhere else (if in the end you can't determine why CMake can't find it), or it may give you enough extra information to solve what's confusing CMake.

Hope this helps.

@CarlosHua
Copy link
Author

CarlosHua commented Aug 22, 2017

Hi dhpp,
Add #include <stdio.h> in LoggerUtils.cpp, it can fix sprintf build error. Thanks.

For sqlite3.h, follow your suggestions, I have move the header file to simply place, but the issue still persist.
Thus we also try put sqlite3.h at CapabilityAgents/Alerts/include/Alerts/Storage/, then modify to #include "Alerts/Storage/sqlite3.h" in CapabilityAgents/Alerts/src/Storage/SQLiteAlertStorage.cpp directly. seems it can works.

Then my solution is added relative path for sqlite in CMakeLists.txt which is includes the sqlite3.h file. as follows,
include_directories(../../../sqlite-3.19.3/)
link_directories(../../../sqlite-3.19.3/.libs/)
Although I do not know if this way is appropriate, but it can fix sqlite3.h not found build error now.

So I think CMake with the SQLITE_XXXXX series options are not working properly on our build environment.

Thanks for your support.

In addition, refering the README.md, in order to get the token that in Integration/AlexaClientSDKConfig.json file , it should using python tool to build-up local server. Have any possible have others way to generate the token? We do not consider porting python to an embedded system.

So if not get the token, then run make test all, it will get all cases failed ? Is it correct? Thanks.

@sanjayrd
Copy link
Contributor

Hi @CarlosHua,

You don't necessarily need need to port the python to your embedded system. You only need to get the refresh token once, so this can be done on your local system. This same refresh token is used every time you connect to AVS. Hope that helps and apologies for the delay!

Thanks,
Sanjay

jjishnu pushed a commit that referenced this issue Sep 20, 2017
    Changes in this update
    - Implemented `setOffSet` in `MediaPlayer`.
    - Updated `LoggerUtils.cpp` to address
      (#77).

    - Bug fix to address incorrect stop behavior caused when Audio Focus
      is set to `NONE` and released. This addresses
      (#129).
    - Bug fix for intermittent failure in `handleMultipleConsecutiveSpeaks`.
    - Bug fix for `jsonArrayExist` incorrectly parsing JSON when trying
      to locate array children.
    - Bug fix for ADSL test failures with `sendDirectiveWithoutADialogRequestId`.
    - Bug fix for `SpeechSynthesizer` showing the wrong UX state when a
      burst of `Speak` directives are received.
    - Bug fix for recursive loop in `AudioPlayer.Stop`.
@future1122
Copy link

Hi, I also use the openwrt cross compiler to compile the c++ alexa-device-sdk .I solve the above problems with your solutions .Thanks very much . But There is another error when linking the libSENSORY.so as follows:

[ 66%] Built target KWD
[ 67%] Built target AbstractKeywordDetectorTest
[ 68%] Built target SENSORY
[ 68%] Linking CXX executable SensoryKeywordDetectorTest
arm-openwrt-linux-uclibcgnueabi-g++: warning: environment variable 'STAGING_DIR' not defined
arm-openwrt-linux-uclibcgnueabi-g++: warning: environment variable 'STAGING_DIR' not defined
../src/libSENSORY.so: undefined reference to __stack_chk_guard' ../src/libSENSORY.so: undefined reference to __ctype_b_loc'
../src/libSENSORY.so: undefined reference to __printf_chk' ../src/libSENSORY.so: undefined reference to __isoc99_sscanf'
../src/libSENSORY.so: undefined reference to __stack_chk_fail' ../src/libSENSORY.so: undefined reference to __vsnprintf_chk'
../src/libSENSORY.so: undefined reference to __snprintf_chk' ../src/libSENSORY.so: undefined reference to __sprintf_chk'
../src/libSENSORY.so: undefined reference to `__fprintf_chk'
collect2: error: ld returned 1 exit status
KWD/Sensory/test/CMakeFiles/SensoryKeywordDetectorTest.dir/build.make:102: recipe for target 'KWD/Sensory/test/SensoryKeywordDetectorTest' failed
make[2]: *** [KWD/Sensory/test/SensoryKeywordDetectorTest] Error 1
CMakeFiles/Makefile2:4445: recipe for target 'KWD/Sensory/test/CMakeFiles/SensoryKeywordDetectorTest.dir/all' failed
make[1]: *** [KWD/Sensory/test/CMakeFiles/SensoryKeywordDetectorTest.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

I have searched the error but no solutions .If you have any ideas Please tell me. Thanks!!!

@thevamad
Copy link

thevamad commented Dec 12, 2017

@future1122 : I had this same issue.
I changed CMakeLists.txt inside the src folder & got the printf and string functions to work properly without additional code modifications.

set(CMAKE_CXX_STANDARD 11) # C++11...
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
add_definitions(-D_GLIBCXX_USE_C99=1)

@future1122
Copy link

@thevamad yes it works .Thanks!

@subjectxbj
Copy link

subjectxbj commented Jan 8, 2018

Hi @future1122 and @thevamad,

I met the same problem.
[ 67%] Building CXX object KWD/Sensory/src/CMakeFiles/SENSORY.dir/SensoryKeywordDetector.cpp.o
[ 67%] Linking CXX shared library libSENSORY.so
make[5]: Leaving directory /media/work/lede/source/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/alexa' [ 67%] Built target SENSORY make[5]: Entering directory /media/work/lede/source/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/alexa'
Scanning dependencies of target SensoryKeywordDetectorTest
make[5]: Leaving directory /media/work/lede/source/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/alexa' make[5]: Entering directory /media/work/lede/source/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/alexa'
[ 68%] Building CXX object KWD/Sensory/test/CMakeFiles/SensoryKeywordDetectorTest.dir/SensoryKeywordDetectorTest.cpp.o
[ 68%] Linking CXX executable SensoryKeywordDetectorTest
../src/libSENSORY.so: undefined reference to __fprintf_chk' ../src/libSENSORY.so: undefined reference to __vsnprintf_chk'
../src/libSENSORY.so: undefined reference to __snprintf_chk' ../src/libSENSORY.so: undefined reference to __printf_chk'
../src/libSENSORY.so: undefined reference to `__sprintf_chk'
collect2: error: ld returned 1 exit status
make[5]: *** [KWD/Sensory/test/SensoryKeywordDetectorTest] Error 1

There is a lot of "CMakelists.txt". Did you make change to the file in the root folder, or just under "KWD/Sensory/src", or "KWD/Sensory/test"?

Thanks

@future1122
Copy link

Hi @subjectxbj the solution @thevamad given is to support c++11 to fix this issue:
error: 'to_string' is not a member of 'std'

How do i fix my issue like yours mentioned above:

My boss asked others to build the libsnsr.a with our toolchain.

But the source code of libsnsr.a is not available .So you can try to ask who built the libsnsr.a here.
Hope it helps.

@subjectxbj
Copy link

Hi @future1122 ,
Ok, I thought the solution provided by thevamad fixed your problem.

And you mean the link error is actually introduced by "libsnsr.a" that is linked in libSENSORY.so. Right? And we need to ask sensory to build a new libsnsr.a for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants