I've C++ application which runs on CentOS Linux 6.6, this machine contains two GCC with versions 4.4.7 and 4.9.3.
I started to use Mozilla SpiderMonkey JS engine 60, in which I need to convert some of my std::string
to std::u16string
, I used the way they provide in their examples:
static inline std::u16string StringtoU16(const std::string &str) {
std::u16string wstr = u"";
char16_t c16str[3] = u"\0";
mbstate_t mbs;
for (const auto& it : str) {
memset(&mbs, 0, sizeof (mbs)); //set shift state to the initial state
memmove(c16str, u"\0\0\0", 3);
mbrtoc16(c16str, &it, 3, &mbs);
wstr.append(std::u16string(c16str));
}//for
return wstr;
}
However, when I started to build the application on the previously mentioned environment, I found that the <uchar.h>
is not found.
But when I built it on my PC using GCC 6.3.0, the code works fine.
I searched for other methods to do the conversion Convert between string, u16string & u32string but also It worked fine on my machine but on the application machine I got <codecvt>
is not found.
I tried to take the output of building the application on my PC (GCC 6.3.0) and run it on the application machine (CentOS 6.6) using the following procedure:
- Copied the libstdc++.so.6.0.22 to CentOS machine
- Updated the LD_LIBRARY_PATH
- Started the application
But I got that libstdc++ needs libc.so.6. I stopped here because when I copied it, it needs another library.
So, what is the Solution? Is there any way to compile on my PC and run on the app machine?