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

build error? #149

Closed
zuowanbushiwo opened this issue Sep 12, 2017 · 2 comments
Closed

build error? #149

zuowanbushiwo opened this issue Sep 12, 2017 · 2 comments

Comments

@zuowanbushiwo
Copy link

CMakeFiles/SharedDataStreamTest.dir/SharedDataStreamTest.cpp.o: In function alexaClientSDK::avsCommon::utils::sds::SharedDataStream<alexaClientSDK::avsCommon::utils::sds::test::MinimalTraits2>::BufferLayout::attach()': SharedDataStreamTest.cpp:(.text._ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test14MinimalTraits2EE12BufferLayout6attachEv[_ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test14MinimalTraits2EE12BufferLayout6attachEv]+0xb4): undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStreamalexaClientSDK::avsCommon::utils::sds::test::MinimalTraits2::BufferLayout::MAGIC_NUMBER'
SharedDataStreamTest.cpp:(.text._ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test14MinimalTraits2EE12BufferLayout6attachEv[_ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test14MinimalTraits2EE12BufferLayout6attachEv]+0xc0): undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStream<alexaClientSDK::avsCommon::utils::sds::test::MinimalTraits2>::BufferLayout::MAGIC_NUMBER' SharedDataStreamTest.cpp:(.text._ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test14MinimalTraits2EE12BufferLayout6attachEv[_ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test14MinimalTraits2EE12BufferLayout6attachEv]+0x34c): undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStreamalexaClientSDK::avsCommon::utils::sds::test::MinimalTraits2::BufferLayout::VERSION'
SharedDataStreamTest.cpp:(.text._ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test14MinimalTraits2EE12BufferLayout6attachEv[_ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test14MinimalTraits2EE12BufferLayout6attachEv]+0x358): undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStream<alexaClientSDK::avsCommon::utils::sds::test::MinimalTraits2>::BufferLayout::VERSION' CMakeFiles/SharedDataStreamTest.dir/SharedDataStreamTest.cpp.o: In function alexaClientSDK::avsCommon::utils::sds::SharedDataStreamalexaClientSDK::avsCommon::utils::sds::test::MinimalTraits::BufferLayout::attach()':
SharedDataStreamTest.cpp:(.text._ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test13MinimalTraitsEE12BufferLayout6attachEv[_ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test13MinimalTraitsEE12BufferLayout6attachEv]+0xb0): undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStream<alexaClientSDK::avsCommon::utils::sds::test::MinimalTraits>::BufferLayout::MAGIC_NUMBER' SharedDataStreamTest.cpp:(.text._ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test13MinimalTraitsEE12BufferLayout6attachEv[_ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test13MinimalTraitsEE12BufferLayout6attachEv]+0xbc): undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStreamalexaClientSDK::avsCommon::utils::sds::test::MinimalTraits::BufferLayout::MAGIC_NUMBER'
SharedDataStreamTest.cpp:(.text._ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test13MinimalTraitsEE12BufferLayout6attachEv[_ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test13MinimalTraitsEE12BufferLayout6attachEv]+0x344): undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStream<alexaClientSDK::avsCommon::utils::sds::test::MinimalTraits>::BufferLayout::VERSION' SharedDataStreamTest.cpp:(.text._ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test13MinimalTraitsEE12BufferLayout6attachEv[_ZN14alexaClientSDK9avsCommon5utils3sds16SharedDataStreamINS2_4test13MinimalTraitsEE12BufferLayout6attachEv]+0x350): undefined reference to alexaClientSDK::avsCommon::utils::sds::SharedDataStreamalexaClientSDK::avsCommon::utils::sds::test::MinimalTraits::BufferLayout::VERSION'
collect2: error: ld returned 1 exit status

only SharedDataStreamTest.cpp build error, if remove this file, the project can build right, how can I solve this problem? is that file right?

@sanjayrd
Copy link
Contributor

Hi @zuowanbushiwo,

Thank you for bringing this up. What compiler version are you using? To me it almost seems to be some sort of missing #include at the top of the file.

Thanks,
Sanjay

@zuowanbushiwo
Copy link
Author

zuowanbushiwo commented Sep 14, 2017

Hi @sanjayrd
thanks,I found that I made my own mistakes,I build this project on openwrt Chaos Calmer 15.05, ARCH:mips32, libc : uClibc, gcc: gcc-linaro-4.8 , as #77 discuss, std::to_string error will happen in this function :
template bool SharedDataStream::BufferLayout::attach() ,
so I copy a string util file:

#ifndef COMPAT_H
#define COMPAT_H
#include <string>
#ifdef NO_CPP11_STRING
#include  <sstream>
#include  <cstdlib>
#include  <cmath>
#include  <climits>
#include  <stdexcept>
#include  <cerrno>
#endif


namespace cpt
{
	template<typename T>
	static std::string to_string(const T& t)
	{
	#ifdef NO_CPP11_STRING
		std::stringstream ss;
		ss << t;
		return ss.str();
	#else
		return std::to_string(t);
	#endif
	}

	static long stoul(const std::string& str)
	{
	#ifdef NO_CPP11_STRING
		errno = 0;
		char *temp;
		long val = strtol(str.c_str(), &temp, 10);
		if (temp == str.c_str() || *temp != '\0')
			throw std::invalid_argument("stoi");
		if (((val == LONG_MIN) || (val == LONG_MAX)) && (errno == ERANGE))
			throw std::out_of_range("stoi");
		return val;
	#else
		return std::stoul(str);
	#endif
	}

	static int stoi(const std::string& str)
	{
	#ifdef NO_CPP11_STRING
		return cpt::stoul(str);
	#else
		return std::stoi(str);
	#endif
	}

	static double stod(const std::string& str)
	{
	#ifdef NO_CPP11_STRING
		errno = 0;
		char *temp;
		double val = strtod(str.c_str(), &temp);
		if (temp == str.c_str() || *temp != '\0')
			throw std::invalid_argument("stod");
		if ((val == HUGE_VAL) && (errno == ERANGE))
			throw std::out_of_range("stod");
		return val;
	#else
		return std::stod(str.c_str());
	#endif
	}

	static long double strtold(const char* str, char** endptr)
	{
	#ifdef NO_CPP11_STRING
		return cpt::stod(str);
	#else
		return std::strtold(str, endptr);
	#endif
	}

	static float strtof(const char* str, char** endptr)
	{
	#ifdef NO_CPP11_STRING
		return (float)cpt::stod(str);
	#else
		return std::strtof(str, endptr);
	#endif
	}
}


#endif

and use cpt::to_string() to replace std::to_string() , then make such a error .
but other replace places is right 。

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

2 participants